Skip to content

Commit 050ffc4

Browse files
Leo Yanacmel
authored andcommitted
perf session: Add swap operation for event TIME_CONV
Since commit d110162 ("perf tsc: Support cap_user_time_short for event TIME_CONV"), the event PERF_RECORD_TIME_CONV has extended the data structure for clock parameters. To be backwards-compatible, this patch adds a dedicated swap operation for the event PERF_RECORD_TIME_CONV, based on checking if the event contains field "time_cycles", it can support both for the old and new event formats. Fixes: d110162 ("perf tsc: Support cap_user_time_short for event TIME_CONV") Signed-off-by: Leo Yan <[email protected]> Acked-by: Adrian Hunter <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Gustavo A. R. Silva <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Kan Liang <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Steve MacLean <[email protected]> Cc: Yonatan Goldschmidt <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent aa616f5 commit 050ffc4

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

tools/perf/util/session.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -949,6 +949,19 @@ static void perf_event__stat_round_swap(union perf_event *event,
949949
event->stat_round.time = bswap_64(event->stat_round.time);
950950
}
951951

952+
static void perf_event__time_conv_swap(union perf_event *event,
953+
bool sample_id_all __maybe_unused)
954+
{
955+
event->time_conv.time_shift = bswap_64(event->time_conv.time_shift);
956+
event->time_conv.time_mult = bswap_64(event->time_conv.time_mult);
957+
event->time_conv.time_zero = bswap_64(event->time_conv.time_zero);
958+
959+
if (event_contains(event->time_conv, time_cycles)) {
960+
event->time_conv.time_cycles = bswap_64(event->time_conv.time_cycles);
961+
event->time_conv.time_mask = bswap_64(event->time_conv.time_mask);
962+
}
963+
}
964+
952965
typedef void (*perf_event__swap_op)(union perf_event *event,
953966
bool sample_id_all);
954967

@@ -985,7 +998,7 @@ static perf_event__swap_op perf_event__swap_ops[] = {
985998
[PERF_RECORD_STAT] = perf_event__stat_swap,
986999
[PERF_RECORD_STAT_ROUND] = perf_event__stat_round_swap,
9871000
[PERF_RECORD_EVENT_UPDATE] = perf_event__event_update_swap,
988-
[PERF_RECORD_TIME_CONV] = perf_event__all64_swap,
1001+
[PERF_RECORD_TIME_CONV] = perf_event__time_conv_swap,
9891002
[PERF_RECORD_HEADER_MAX] = NULL,
9901003
};
9911004

0 commit comments

Comments
 (0)