linux-stable/tools/perf
Namhyung Kim 3599705789 perf stat: Do not delay the workload with --delay
[ Upstream commit c587e77e10 ]

The -D/--delay option is to delay the measure after the program starts.
But the current code goes to sleep before starting the program so the
program is delayed too.  This is not the intention, let's fix it.

Before:

  $ time sudo ./perf stat -a -e cycles -D 3000 sleep 4
  Events disabled
  Events enabled

   Performance counter stats for 'system wide':

       4,326,949,337      cycles

         4.007494118 seconds time elapsed

  real	0m7.474s
  user	0m0.356s
  sys	0m0.120s

It ran the workload for 4 seconds and gave the 3 second delay.  So it
should skip the first 3 second and measure the last 1 second only.  But
as you can see, it delays 3 seconds and ran the workload after that for
4 seconds.  So the total time (real) was 7 seconds.

After:

  $ time sudo ./perf stat -a -e cycles -D 3000 sleep 4
  Events disabled
  Events enabled

   Performance counter stats for 'system wide':

       1,063,551,013      cycles

         1.002769510 seconds time elapsed

  real	0m4.484s
  user	0m0.385s
  sys	0m0.086s

The bug was introduced when it changed enablement of system-wide events
with a command line workload.  But it should've considered the initial
delay case.  The code was reworked since then (in bb8bc52e75) so I'm
afraid it won't be applied cleanly.

Fixes: d0a0a51149 ("perf stat: Fix forked applications enablement of counters")
Reported-by: Kevin Nomura <nomurak@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Tested-by: Thomas Richter <tmricht@linux.ibm.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
Link: https://lore.kernel.org/r/20221212230820.901382-1-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-12-31 13:26:31 +01:00
..
arch perf intel-pt: Fix system_wide dummy event for hybrid 2022-10-21 12:39:26 +02:00
bench
dlfilters perf dlfilter dlfilter-show-cycles: Fix types for print format 2022-09-08 12:17:45 -03:00
Documentation
examples/bpf
include
jvmti
pmu-events perf vendor events arm64: Fix incorrect Hisi hip08 L3 metrics 2022-11-04 00:00:32 +09:00
python
scripts
tests perf test: Fix skipping branch stack sampling test 2022-11-16 10:03:59 +01:00
trace
ui
util perf off_cpu: Fix a typo in BTF tracepoint name, it should be 'btf_trace_sched_switch' 2022-12-31 13:26:31 +01:00
.gitignore perf tools: Add the include/perf/ directory to .gitignore 2022-11-16 10:03:59 +01:00
Build
builtin-annotate.c
builtin-bench.c
builtin-buildid-cache.c
builtin-buildid-list.c
builtin-c2c.c perf c2c: Prevent potential memory leak in c2c_he_zalloc() 2022-09-06 09:45:23 -03:00
builtin-config.c
builtin-daemon.c
builtin-data.c
builtin-diff.c
builtin-evlist.c
builtin-ftrace.c
builtin-help.c
builtin-inject.c
builtin-kallsyms.c
builtin-kmem.c
builtin-kvm.c
builtin-kwork.c
builtin-list.c
builtin-lock.c perf lock: Remove redundant word 'contention' in help message 2022-09-08 15:23:42 -03:00
builtin-mem.c
builtin-probe.c
builtin-record.c perf record: Fix cpu mask bit setting for mixed mmaps 2022-09-21 16:08:00 -03:00
builtin-report.c
builtin-sched.c
builtin-script.c perf script: Fix Cannot print 'iregs' field for hybrid systems 2022-09-08 15:27:39 -03:00
builtin-stat.c perf stat: Do not delay the workload with --delay 2022-12-31 13:26:31 +01:00
builtin-timechart.c
builtin-top.c
builtin-trace.c perf trace: Handle failure when trace point folder is missed 2022-12-31 13:26:30 +01:00
builtin-version.c
builtin.h
check-headers.sh
command-list.txt
CREDITS
design.txt
Makefile
Makefile.config
Makefile.perf perf tools: Don't install data files with x permissions 2022-09-08 15:55:56 -03:00
MANIFEST
perf-archive.sh
perf-completion.sh
perf-iostat.sh
perf-read-vdso.c
perf-sys.h
perf.c
perf.h