Commit a11c9a6e authored by Dmitry Koshelev's avatar Dmitry Koshelev Committed by Arnaldo Carvalho de Melo

perf session: Fix swapping of cpu_map and stat_config records

'data' field in perf_record_cpu_map_data struct is 16-bit
wide and so should be swapped using bswap_16().

'nr' field in perf_record_stat_config struct should be
swapped before being used for size calculation.
Signed-off-by: default avatarDmitry Koshelev <karaghiozis@gmail.com>
Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20210506131244.13328-1-karaghiozis@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 7aa3c9ea
......@@ -904,7 +904,7 @@ static void perf_event__cpu_map_swap(union perf_event *event,
struct perf_record_record_cpu_map *mask;
unsigned i;
data->type = bswap_64(data->type);
data->type = bswap_16(data->type);
switch (data->type) {
case PERF_CPU_MAP__CPUS:
......@@ -937,7 +937,7 @@ static void perf_event__stat_config_swap(union perf_event *event,
{
u64 size;
size = event->stat_config.nr * sizeof(event->stat_config.data[0]);
size = bswap_64(event->stat_config.nr) * sizeof(event->stat_config.data[0]);
size += 1; /* nr item itself */
mem_bswap_64(&event->stat_config.nr, size);
}
......
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