linux_dsm_epyc7002/tools/perf
Srikar Dronamraju b63fd11cce perf stat: Reset previous counts on repeat with interval
When using 'perf stat' with repeat and interval option, it shows wrong
values for events.

The wrong values will be shown for the first interval on the second and
subsequent repetitions.

Without the fix:

  # perf stat -r 3 -I 2000 -e faults -e sched:sched_switch -a sleep 5

     2.000282489                 53      faults
     2.000282489                513      sched:sched_switch
     4.005478208              3,721      faults
     4.005478208              2,666      sched:sched_switch
     5.025470933                395      faults
     5.025470933              1,307      sched:sched_switch
     2.009602825 1,84,46,74,40,73,70,95,47,520      faults 		<------
     2.009602825 1,84,46,74,40,73,70,95,49,568      sched:sched_switch  <------
     4.019612206              4,730      faults
     4.019612206              2,746      sched:sched_switch
     5.039615484              3,953      faults
     5.039615484              1,496      sched:sched_switch
     2.000274620 1,84,46,74,40,73,70,95,47,520      faults		<------
     2.000274620 1,84,46,74,40,73,70,95,47,520      sched:sched_switch	<------
     4.000480342              4,282      faults
     4.000480342              2,303      sched:sched_switch
     5.000916811              1,322      faults
     5.000916811              1,064      sched:sched_switch
  #

prev_raw_counts is allocated when using intervals. This is used when
calculating the difference in the counts of events when using interval.

The current counts are stored in prev_raw_counts to calculate the
differences in the next iteration.

On the first interval of the second and subsequent repetitions,
prev_raw_counts would be the values stored in the last interval of the
previous repetitions, while the current counts will only be for the
first interval of the current repetition.

Hence there is a possibility of events showing up as big number.

Fix this by resetting prev_raw_counts whenever perf stat repeats the
command.

With the fix:

  # perf stat -r 3 -I 2000 -e faults -e sched:sched_switch -a sleep 5

     2.019349347              2,597      faults
     2.019349347              2,753      sched:sched_switch
     4.019577372              3,098      faults
     4.019577372              2,532      sched:sched_switch
     5.019415481              1,879      faults
     5.019415481              1,356      sched:sched_switch
     2.000178813              8,468      faults
     2.000178813              2,254      sched:sched_switch
     4.000404621              7,440      faults
     4.000404621              1,266      sched:sched_switch
     5.040196079              2,458      faults
     5.040196079                556      sched:sched_switch
     2.000191939              6,870      faults
     2.000191939              1,170      sched:sched_switch
     4.000414103                541      faults
     4.000414103                902      sched:sched_switch
     5.000809863                450      faults
     5.000809863                364      sched:sched_switch
  #

Committer notes:

This was broken since the cset introducing the --interval feature, i.e.
--repeat + --interval wasn't tested at that point, add the Fixes tag so
that automatic scripts can pick this up.

Fixes: 13370a9b5b ("perf stat: Add interval printing")
Signed-off-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: stable@vger.kernel.org # v3.9+
Link: http://lore.kernel.org/lkml/20190904094738.9558-2-srikar@linux.vnet.ibm.com
[ Fixed up conflicts with libperf, i.e. some perf_{evsel,evlist} lost the 'perf' prefix ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2019-09-20 10:28:26 -03:00
..
arch perf tools: Move event synthesizing routines to separate header 2019-09-20 09:19:22 -03:00
bench perf env: Remove needless cpumap.h header 2019-09-20 09:19:21 -03:00
Documentation perf report: Add --switch-on/--switch-off events 2019-08-16 12:14:33 -03:00
examples/bpf perf augmented_raw_syscalls: Reduce perf_event_output() boilerplate 2019-08-26 11:58:29 -03:00
include/bpf perf include bpf: Add bpf_tail_call() prototype 2019-07-29 18:34:40 -03:00
jvmti perf jvmti: Link against tools/lib/string.o to have weak strlcpy() 2019-09-20 09:18:45 -03:00
lib libperf: Adopt perf_cpu_map__max() function 2019-09-10 14:33:32 +01:00
pmu-events perf tools: Add PMU event JSON files for ARM Cortex-A76 and, Neoverse N1. 2019-09-20 09:19:20 -03:00
python treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 407 2019-06-05 17:37:14 +02:00
scripts perf tools: Remove perf.h from source files not needing it 2019-08-29 17:38:32 -03:00
tests perf tools: Move event synthesizing routines to separate header 2019-09-20 09:19:22 -03:00
trace perf trace beauty ioctl: Fix off-by-one error in cmd->string table 2019-08-26 11:58:29 -03:00
ui perf tools: Move event synthesizing routines to separate header 2019-09-20 09:19:22 -03:00
util perf stat: Reset previous counts on repeat with interval 2019-09-20 10:28:26 -03:00
.gitignore perf: Update .gitignore file 2019-08-31 22:27:52 -03:00
Build perf tools: Rename build libperf to perf 2019-02-14 15:18:08 -03:00
builtin-annotate.c perf annotate: Add missing machine.h include directive 2019-09-20 09:19:22 -03:00
builtin-bench.c perf tools: Remove perf.h from source files not needing it 2019-08-29 17:38:32 -03:00
builtin-buildid-cache.c perf tools: Remove needless evlist.h include directives 2019-08-31 22:24:10 -03:00
builtin-buildid-list.c perf tools: Remove needless evlist.h include directives 2019-08-31 22:24:10 -03:00
builtin-c2c.c perf env: Remove needless cpumap.h header 2019-09-20 09:19:21 -03:00
builtin-config.c perf tools: Remove util.h from where it is not needed 2019-09-20 09:19:20 -03:00
builtin-data.c perf debug: Remove needless include directives from debug.h 2019-08-31 19:10:19 -03:00
builtin-diff.c perf debug: Remove needless include directives from debug.h 2019-08-31 19:10:19 -03:00
builtin-evlist.c perf tools: Remove util.h from where it is not needed 2019-09-20 09:19:20 -03:00
builtin-ftrace.c perf auxtrace: Uninline functions that touch perf_session 2019-08-31 22:24:10 -03:00
builtin-help.c perf debug: Remove needless include directives from debug.h 2019-08-31 19:10:19 -03:00
builtin-inject.c perf tools: Move event synthesizing routines to separate header 2019-09-20 09:19:22 -03:00
builtin-kallsyms.c perf dsos: Move the dsos struct and its methods to separate source files 2019-08-31 22:24:10 -03:00
builtin-kmem.c perf dsos: Move the dsos struct and its methods to separate source files 2019-08-31 22:24:10 -03:00
builtin-kvm.c perf tools: Move event synthesizing routines to separate header 2019-09-20 09:19:22 -03:00
builtin-list.c perf tools: Remove needless evlist.h include directives 2019-08-31 22:24:10 -03:00
builtin-lock.c perf tools: Remove needless evlist.h include directives 2019-08-31 22:24:10 -03:00
builtin-mem.c perf symbols: Move mem_info and branch_info out of symbol.h 2019-08-31 22:27:48 -03:00
builtin-probe.c perf probe: No need for symbol.h, symbol_conf is enough 2019-08-31 22:24:10 -03:00
builtin-record.c perf tools: Move event synthesizing routines to separate .c file 2019-09-20 10:28:21 -03:00
builtin-report.c perf tools: Remove util.h from where it is not needed 2019-09-20 09:19:20 -03:00
builtin-sched.c perf sched: Add missing event.h include directive 2019-09-20 09:19:22 -03:00
builtin-script.c perf tools: Remove needless evlist.h include directives 2019-08-31 22:24:10 -03:00
builtin-stat.c perf stat: Reset previous counts on repeat with interval 2019-09-20 10:28:26 -03:00
builtin-timechart.c perf tools: Remove needless evlist.h include directives 2019-08-31 22:24:10 -03:00
builtin-top.c perf tools: Move event synthesizing routines to separate header 2019-09-20 09:19:22 -03:00
builtin-trace.c perf tools: Move event synthesizing routines to separate header 2019-09-20 09:19:22 -03:00
builtin-version.c perf symbols: Move mem_info and branch_info out of symbol.h 2019-08-31 22:27:48 -03:00
builtin.h perf tools: Remove needless util.h include from builtin.h 2019-08-28 17:19:34 -03:00
check-headers.sh perf build: Ignore intentional differences for the x86 insn decoder 2019-08-31 22:27:52 -03:00
command-list.txt perf help: Add missing subcommand version 2018-09-19 14:53:36 -03:00
CREDITS
design.txt perf/doc: Update design.txt for exclude_{host|guest} flags 2019-01-21 11:01:18 +01:00
Makefile
Makefile.config perf tools: tools/include should come before tools/uapi/include 2019-08-20 12:07:22 -03:00
Makefile.perf perf python: Add missing python/perf.so dependency for libperf 2019-09-10 14:33:32 +01:00
MANIFEST tools lib: Adopt zalloc()/zfree() from tools/perf 2019-07-09 10:13:26 -03:00
perf-archive.sh
perf-completion.sh
perf-read-vdso.c perf tools: Make find_vdso_map() more modular 2019-01-08 13:28:13 -03:00
perf-sys.h perf tools: Move everything related to sys_perf_event_open() to perf-sys.h 2019-08-29 17:38:32 -03:00
perf-with-kcore.sh Merge branch 'x86/cpu' into perf/core, to pick up dependent changes 2019-06-17 12:29:16 +02:00
perf.c perf tools: Remove util.h from where it is not needed 2019-09-20 09:19:20 -03:00
perf.h perf time-utils: Adopt rdclock() from perf.h 2019-08-29 17:38:32 -03:00