Commit fa128e6a authored by Alexei Starovoitov's avatar Alexei Starovoitov Committed by David S. Miller

perf: pad raw data samples automatically

Instead of WARN_ON in perf_event_output() on unpaded raw samples,
pad them automatically.
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 63b11e75
...@@ -5286,9 +5286,15 @@ void perf_output_sample(struct perf_output_handle *handle, ...@@ -5286,9 +5286,15 @@ void perf_output_sample(struct perf_output_handle *handle,
if (sample_type & PERF_SAMPLE_RAW) { if (sample_type & PERF_SAMPLE_RAW) {
if (data->raw) { if (data->raw) {
perf_output_put(handle, data->raw->size); u32 raw_size = data->raw->size;
__output_copy(handle, data->raw->data, u32 real_size = round_up(raw_size + sizeof(u32),
data->raw->size); sizeof(u64)) - sizeof(u32);
u64 zero = 0;
perf_output_put(handle, real_size);
__output_copy(handle, data->raw->data, raw_size);
if (real_size - raw_size)
__output_copy(handle, &zero, real_size - raw_size);
} else { } else {
struct { struct {
u32 size; u32 size;
...@@ -5420,8 +5426,7 @@ void perf_prepare_sample(struct perf_event_header *header, ...@@ -5420,8 +5426,7 @@ void perf_prepare_sample(struct perf_event_header *header,
else else
size += sizeof(u32); size += sizeof(u32);
WARN_ON_ONCE(size & (sizeof(u64)-1)); header->size += round_up(size, sizeof(u64));
header->size += size;
} }
if (sample_type & PERF_SAMPLE_BRANCH_STACK) { if (sample_type & PERF_SAMPLE_BRANCH_STACK) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment