Skip to content

Commit 522283f

Browse files
committed
perf trace: Do not print from time delta for interrupted syscall lines
We were calculating the delta from a in-flight syscall that got its output interrupted by another syscall, which doesn't seem like useful information, we will print the syscall duration (sys_exit - sys_enter) when the raw_syscalls:sys_exit event happens. The problem here is how we're consuming the multiple ring buffers, without using the ordered_events code used by perf_session, which may cause some reordering of syscalls for diferent CPUs, so just stop printing that delta, to avoid things like: # trace --print-sample -p 9626 -e futex raw_syscalls:sys_enter 411967179.269 Timer 9609/9626 [2] raw_syscalls:sys_enter 411967179.213 file:// Content 9609/9609 [3] 328.038 (18446744073709.496 ms): Timer/9626 futex(uaddr: 0x7fc0d4027044, op: WAIT|PRIV, utime: 0x7fc0b0ffdb50 ) ... raw_syscalls:sys_exit 411967179.225 file:// Content 9609/9609 [3] 327.982 ( 0.012 ms): file:// Conten/9609 futex(uaddr: 0x7fc0d4027040, op: WAKE|PRIV, val: 1 ) = 1 This is a bandaid, we should better try and use the ordered_events code, possibly with some refactoring prep work, but for now at least we don't show those false long deltas for the lines ending in '...'. Cc: Adrian Hunter <[email protected]> Cc: David Ahern <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Wang Nan <[email protected]> Link: https://lkml.kernel.org/n/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 591421e commit 522283f

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

tools/perf/builtin-trace.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,7 @@ static size_t fprintf_duration(unsigned long t, bool calculated, FILE *fp)
821821
size_t printed = fprintf(fp, "(");
822822

823823
if (!calculated)
824-
printed += fprintf(fp, " ? ");
824+
printed += fprintf(fp, " ");
825825
else if (duration >= 1.0)
826826
printed += color_fprintf(fp, PERF_COLOR_RED, "%6.3f ms", duration);
827827
else if (duration >= 0.01)
@@ -1556,10 +1556,9 @@ static void thread__update_stats(struct thread_trace *ttrace,
15561556
update_stats(stats, duration);
15571557
}
15581558

1559-
static int trace__printf_interrupted_entry(struct trace *trace, struct perf_sample *sample)
1559+
static int trace__printf_interrupted_entry(struct trace *trace)
15601560
{
15611561
struct thread_trace *ttrace;
1562-
u64 duration;
15631562
size_t printed;
15641563

15651564
if (trace->current == NULL)
@@ -1570,9 +1569,7 @@ static int trace__printf_interrupted_entry(struct trace *trace, struct perf_samp
15701569
if (!ttrace->entry_pending)
15711570
return 0;
15721571

1573-
duration = sample->time - ttrace->entry_time;
1574-
1575-
printed = trace__fprintf_entry_head(trace, trace->current, duration, true, ttrace->entry_time, trace->output);
1572+
printed = trace__fprintf_entry_head(trace, trace->current, 0, false, ttrace->entry_time, trace->output);
15761573
printed += fprintf(trace->output, "%-70s) ...\n", ttrace->entry_str);
15771574
ttrace->entry_pending = false;
15781575

@@ -1627,7 +1624,7 @@ static int trace__sys_enter(struct trace *trace, struct perf_evsel *evsel,
16271624
}
16281625

16291626
if (!(trace->duration_filter || trace->summary_only || trace->min_stack))
1630-
trace__printf_interrupted_entry(trace, sample);
1627+
trace__printf_interrupted_entry(trace);
16311628

16321629
ttrace->entry_time = sample->time;
16331630
msg = ttrace->entry_str;
@@ -1941,7 +1938,7 @@ static int trace__event_handler(struct trace *trace, struct perf_evsel *evsel,
19411938
}
19421939
}
19431940

1944-
trace__printf_interrupted_entry(trace, sample);
1941+
trace__printf_interrupted_entry(trace);
19451942
trace__fprintf_tstamp(trace, sample->time, trace->output);
19461943

19471944
if (trace->trace_syscalls)

0 commit comments

Comments
 (0)