perf evsel: Fix swap for samples with raw data
authorJiri Olsa <jolsa@kernel.org>
Wed, 29 Nov 2017 18:43:46 +0000 (19:43 +0100)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 27 Dec 2017 15:15:56 +0000 (12:15 -0300)
commitf9d8adb345d7adbb2d3431eea73beb89c8d6d612
tree24027fd9ea3db42e6378009b0250e8cbab78877b
parentc588d158124d5b60184fc612e551a19720720d68
perf evsel: Fix swap for samples with raw data

When we detect a different endianity we swap event before processing.
It's tricky for samples because we have no idea what's inside. We treat
it as an array of u64s, swap them and later on we swap back parts which
are different.

We mangle this way also the tracepoint raw data, which ends up in report
showing wrong data:

  1.95%  comm=Q^B pid=29285 prio=16777216 target_cpu=000
  1.67%  comm=l^B pid=0 prio=16777216 target_cpu=000

Luckily the traceevent library handles the endianity by itself (thank
you Steven!), so we can pass the RAW data directly in the other
endianity.

  2.51%  comm=beah-rhts-task pid=1175 prio=120 target_cpu=002
  2.23%  comm=kworker/0:0 pid=11566 prio=120 target_cpu=000

The fix is basically to swap back the raw data if different endianity is
detected.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/20171129184346.3656-1-jolsa@kernel.org
[ Add util/memswap.c to python-ext-sources to link missing mem_bswap_64() ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/evsel.c
tools/perf/util/python-ext-sources