Skip to content

Commit 81e70d7

Browse files
Leo Yanacmel
authored andcommitted
perf session: Dump PERF_RECORD_TIME_CONV event
Now perf tool uses the common stub function process_event_op2_stub() for dumping TIME_CONV event, thus it doesn't output the clock parameters contained in the event. This patch adds the callback function for dumping the hardware clock parameters in TIME_CONV event. Before: # perf report -D 0x978 [0x38]: event: 79 . . ... raw event: size 56 bytes . 0000: 4f 00 00 00 00 00 38 00 15 00 00 00 00 00 00 00 O.....8......... . 0010: 00 00 40 01 00 00 00 00 86 89 0b bf df ff ff ff ..@........<BF><DF><FF><FF><FF> . 0020: d1 c1 b2 39 03 00 00 00 ff ff ff ff ff ff ff 00 <D1><C1><B2>9....<FF><FF><FF><FF><FF><FF><FF>. . 0030: 01 01 00 00 00 00 00 00 ........ 0 0 0x978 [0x38]: PERF_RECORD_TIME_CONV : unhandled! [...] After: # perf report -D 0x978 [0x38]: event: 79 . . ... raw event: size 56 bytes . 0000: 4f 00 00 00 00 00 38 00 15 00 00 00 00 00 00 00 O.....8......... . 0010: 00 00 40 01 00 00 00 00 86 89 0b bf df ff ff ff ..@........<BF><DF><FF><FF><FF> . 0020: d1 c1 b2 39 03 00 00 00 ff ff ff ff ff ff ff 00 <D1><C1><B2>9....<FF><FF><FF><FF><FF><FF><FF>. . 0030: 01 01 00 00 00 00 00 00 ........ 0 0 0x978 [0x38]: PERF_RECORD_TIME_CONV ... Time Shift 21 ... Time Muliplier 20971520 ... Time Zero 18446743935180835206 ... Time Cycles 13852918225 ... Time Mask 0xffffffffffffff ... Cap Time Zero 1 ... Cap Time Short 1 : unhandled! [...] 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 050ffc4 commit 81e70d7

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

tools/perf/util/session.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "thread-stack.h"
3030
#include "sample-raw.h"
3131
#include "stat.h"
32+
#include "tsc.h"
3233
#include "ui/progress.h"
3334
#include "../perf.h"
3435
#include "arch/common.h"
@@ -451,6 +452,16 @@ static int process_stat_round_stub(struct perf_session *perf_session __maybe_unu
451452
return 0;
452453
}
453454

455+
static int process_event_time_conv_stub(struct perf_session *perf_session __maybe_unused,
456+
union perf_event *event)
457+
{
458+
if (dump_trace)
459+
perf_event__fprintf_time_conv(event, stdout);
460+
461+
dump_printf(": unhandled!\n");
462+
return 0;
463+
}
464+
454465
static int perf_session__process_compressed_event_stub(struct perf_session *session __maybe_unused,
455466
union perf_event *event __maybe_unused,
456467
u64 file_offset __maybe_unused)
@@ -532,7 +543,7 @@ void perf_tool__fill_defaults(struct perf_tool *tool)
532543
if (tool->stat_round == NULL)
533544
tool->stat_round = process_stat_round_stub;
534545
if (tool->time_conv == NULL)
535-
tool->time_conv = process_event_op2_stub;
546+
tool->time_conv = process_event_time_conv_stub;
536547
if (tool->feature == NULL)
537548
tool->feature = process_event_op2_stub;
538549
if (tool->compressed == NULL)

tools/perf/util/tsc.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// SPDX-License-Identifier: GPL-2.0
22
#include <errno.h>
3+
#include <inttypes.h>
4+
#include <string.h>
35

46
#include <linux/compiler.h>
57
#include <linux/perf_event.h>
@@ -110,3 +112,31 @@ u64 __weak rdtsc(void)
110112
{
111113
return 0;
112114
}
115+
116+
size_t perf_event__fprintf_time_conv(union perf_event *event, FILE *fp)
117+
{
118+
struct perf_record_time_conv *tc = (struct perf_record_time_conv *)event;
119+
size_t ret;
120+
121+
ret = fprintf(fp, "\n... Time Shift %" PRI_lu64 "\n", tc->time_shift);
122+
ret += fprintf(fp, "... Time Muliplier %" PRI_lu64 "\n", tc->time_mult);
123+
ret += fprintf(fp, "... Time Zero %" PRI_lu64 "\n", tc->time_zero);
124+
125+
/*
126+
* The event TIME_CONV was extended for the fields from "time_cycles"
127+
* when supported cap_user_time_short, for backward compatibility,
128+
* prints the extended fields only if they are contained in the event.
129+
*/
130+
if (event_contains(*tc, time_cycles)) {
131+
ret += fprintf(fp, "... Time Cycles %" PRI_lu64 "\n",
132+
tc->time_cycles);
133+
ret += fprintf(fp, "... Time Mask %#" PRI_lx64 "\n",
134+
tc->time_mask);
135+
ret += fprintf(fp, "... Cap Time Zero %" PRId32 "\n",
136+
tc->cap_user_time_zero);
137+
ret += fprintf(fp, "... Cap Time Short %" PRId32 "\n",
138+
tc->cap_user_time_short);
139+
}
140+
141+
return ret;
142+
}

tools/perf/util/tsc.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
#include <linux/types.h>
66

7+
#include "event.h"
8+
79
struct perf_tsc_conversion {
810
u16 time_shift;
911
u32 time_mult;
@@ -24,4 +26,6 @@ u64 perf_time_to_tsc(u64 ns, struct perf_tsc_conversion *tc);
2426
u64 tsc_to_perf_time(u64 cyc, struct perf_tsc_conversion *tc);
2527
u64 rdtsc(void);
2628

29+
size_t perf_event__fprintf_time_conv(union perf_event *event, FILE *fp);
30+
2731
#endif // __PERF_TSC_H

0 commit comments

Comments
 (0)