Skip to content

Commit

Permalink
perf session: Fix swapping of cpu_map and stat_config records
Browse files Browse the repository at this point in the history
'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: Dmitry Koshelev <[email protected]>
Acked-by: Jiri Olsa <[email protected]>
Cc: Adrian Hunter <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Kan Liang <[email protected]>
Cc: Leo Yan <[email protected]>
Cc: Mark Rutland <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lore.kernel.org/lkml/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
dmitry-koshelev authored and acmel committed May 10, 2021
1 parent 7aa3c9e commit a11c9a6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tools/perf/util/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit a11c9a6

Please sign in to comment.