Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf trace: Do not show the runtime_ms for a thread when not collecting it

That field is only updated when we use the "sched:sched_stat_runtime"
tracepoint, and that is only done so far when we use the '--stat' command line
option, without it we get just zeros, confusing the users:

Without this patch:

# trace -a -s sleep 1
<SNIP>
qemu-system-x86 (9931), 468 events, 9.6%, 0.000 msec

syscall calls total min avg max stddev
(msec) (msec) (msec) (msec) (%)
---------- ------ --------- --------- --------- --------- ------
ppoll 98 982.374 0.000 10.024 29.983 12.65%
write 34 0.401 0.005 0.012 0.027 5.49%
ioctl 102 0.347 0.002 0.003 0.007 3.08%

firefox (10871), 1856 events, 38.2%, 0.000 msec

(msec) (msec) (msec) (msec) (%)
---------- ------ --------- --------- --------- --------- ------
poll 395 934.873 0.000 2.367 17.120 11.51%
recvmsg 395 0.988 0.001 0.003 0.021 4.20%
read 106 0.460 0.002 0.004 0.007 3.17%
futex 24 0.108 0.001 0.004 0.010 10.05%
mmap 2 0.041 0.016 0.021 0.026 23.92%
write 6 0.027 0.004 0.004 0.005 2.52%

After this patch that ', 0.000 msecs' gets suppressed when --stat is not
in use.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Milian Wolff <milian.wolff@kdab.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-p7emqrsw7900tdkg43v9l1e1@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

+5 -1
+5 -1
tools/perf/builtin-trace.c
··· 2860 2860 printed += fprintf(fp, ", %lu majfaults", ttrace->pfmaj); 2861 2861 if (ttrace->pfmin) 2862 2862 printed += fprintf(fp, ", %lu minfaults", ttrace->pfmin); 2863 - printed += fprintf(fp, ", %.3f msec\n", ttrace->runtime_ms); 2863 + if (trace->sched) 2864 + printed += fprintf(fp, ", %.3f msec\n", ttrace->runtime_ms); 2865 + else if (fputc('\n', fp) != EOF) 2866 + ++printed; 2867 + 2864 2868 printed += thread__dump_stats(ttrace, trace, fp); 2865 2869 2866 2870 return printed;