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

perf stat: Measure 't0' and 'ref_time' after enable_counters()

Take measurements of 't0' and 'ref_time' after enable_counters(), so
that they only measure the time consumed when the counters are enabled.

Signed-off-by: Song Liu <songliubraving@fb.com>
Acked-by: Andi Kleen <andi@firstfloor.org>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: kernel-team@fb.com
Link: http://lore.kernel.org/lkml/20210316211837.910506-3-songliubraving@fb.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Song Liu and committed by
Arnaldo Carvalho de Melo
435b46ef 7fac83aa

+7 -3
+7 -3
tools/perf/builtin-stat.c
··· 931 931 /* 932 932 * Enable counters and exec the command: 933 933 */ 934 - t0 = rdclock(); 935 - clock_gettime(CLOCK_MONOTONIC, &ref_time); 936 - 937 934 if (forks) { 938 935 evlist__start_workload(evsel_list); 939 936 err = enable_counters(); 940 937 if (err) 941 938 return -1; 939 + 940 + t0 = rdclock(); 941 + clock_gettime(CLOCK_MONOTONIC, &ref_time); 942 942 943 943 if (interval || timeout || evlist__ctlfd_initialized(evsel_list)) 944 944 status = dispatch_events(forks, timeout, interval, &times); ··· 960 960 err = enable_counters(); 961 961 if (err) 962 962 return -1; 963 + 964 + t0 = rdclock(); 965 + clock_gettime(CLOCK_MONOTONIC, &ref_time); 966 + 963 967 status = dispatch_events(forks, timeout, interval, &times); 964 968 } 965 969