]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
perf: pad raw data samples automatically
authorAlexei Starovoitov <ast@plumgrid.com>
Wed, 21 Oct 2015 03:02:33 +0000 (20:02 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 22 Oct 2015 13:42:13 +0000 (06:42 -0700)
Instead of WARN_ON in perf_event_output() on unpaded raw samples,
pad them automatically.

Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
kernel/events/core.c

index b11756f9b6dcfdf2673b2a396ac0e0de5c980101..64754bfecd700dd4a0fc7f6738f2d07a718100c6 100644 (file)
@@ -5286,9 +5286,15 @@ void perf_output_sample(struct perf_output_handle *handle,
 
        if (sample_type & PERF_SAMPLE_RAW) {
                if (data->raw) {
-                       perf_output_put(handle, data->raw->size);
-                       __output_copy(handle, data->raw->data,
-                                          data->raw->size);
+                       u32 raw_size = data->raw->size;
+                       u32 real_size = round_up(raw_size + sizeof(u32),
+                                                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 {
                        struct {
                                u32     size;
@@ -5420,8 +5426,7 @@ void perf_prepare_sample(struct perf_event_header *header,
                else
                        size += sizeof(u32);
 
-               WARN_ON_ONCE(size & (sizeof(u64)-1));
-               header->size += size;
+               header->size += round_up(size, sizeof(u64));
        }
 
        if (sample_type & PERF_SAMPLE_BRANCH_STACK) {