linux/tools/perf/util
Ian Rogers e833591265 perf evlist: Avoid frequency mode for the dummy event
[ Upstream commit f9cdeb58a9 ]

Dummy events are created with an attribute where the period and freq
are zero. evsel__config will then see the uninitialized values and
initialize them in evsel__default_freq_period. As fequency mode is
used by default the dummy event would be set to use frequency
mode. However, this has no effect on the dummy event but does cause
unnecessary timers/interrupts. Avoid this overhead by setting the
period to 1 for dummy events.

evlist__add_aux_dummy calls evlist__add_dummy then sets freq=0 and
period=1. This isn't necessary after this change and so the setting is
removed.

From Stephane:

The dummy event is not counting anything. It is used to collect mmap
records and avoid a race condition during the synthesize mmap phase of
perf record. As such, it should not cause any overhead during active
profiling. Yet, it did. Because of a bug the dummy event was
programmed as a sampling event in frequency mode. Events in that mode
incur more kernel overheads because on timer tick, the kernel has to
look at the number of samples for each event and potentially adjust
the sampling period to achieve the desired frequency. The dummy event
was therefore adding a frequency event to task and ctx contexts we may
otherwise not have any, e.g.,

  perf record -a -e cpu/event=0x3c,period=10000000/.

On each timer tick the perf_adjust_freq_unthr_context() is invoked and
if ctx->nr_freq is non-zero, then the kernel will loop over ALL the
events of the context looking for frequency mode ones. In doing, so it
locks the context, and enable/disable the PMU of each hw event. If all
the events of the context are in period mode, the kernel will have to
traverse the list for nothing incurring overhead. The overhead is
multiplied by a very large factor when this happens in a guest kernel.
There is no need for the dummy event to be in frequency mode, it does
not count anything and therefore should not cause extra overhead for
no reason.

Fixes: 5bae025023 ("perf evlist: Introduce perf_evlist__new_dummy constructor")
Reported-by: Stephane Eranian <eranian@google.com>
Signed-off-by: Ian Rogers <irogers@google.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Yang Jihong <yangjihong1@huawei.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Link: https://lore.kernel.org/r/20230916035640.1074422-1-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-08 14:11:02 +01:00
..
arm-spe-decoder
bpf_skel perf stat: Support old kernels for bperf cgroup counting 2022-10-14 10:29:05 -03:00
c++
cs-etm-decoder
hisi-ptt-decoder perf auxtrace arm64: Add support for parsing HiSilicon PCIe Trace packet 2022-10-15 10:13:16 -03:00
include tools headers: Update the copy of x86's memcpy_64.S used in 'perf bench' 2022-10-25 17:40:48 -03:00
intel-pt-decoder perf intel-pt: Fix CYC timestamps after standalone CBR 2023-05-11 23:03:42 +09:00
libunwind
scripting-engines perf build: Fixup disabling of -Wdeprecated-declarations for the python scripting engine 2022-09-29 16:03:35 -03:00
affinity.c perf affinity: Fix out of bound access to "sched_cpus" mask 2022-09-06 09:45:23 -03:00
affinity.h
amd-sample-raw.c
annotate.c perf annotate bpf: Don't enclose non-debug code with an assert() 2023-09-19 12:27:59 +02:00
annotate.h perf annotate: Toggle full address <-> offset display 2022-10-04 08:55:22 -03:00
archinsn.h
arm-spe.c perf arm-spe: augment the data source type with neoverse_spe list 2022-09-28 11:26:33 -03:00
arm-spe.h
arm64-frame-pointer-unwind-support.c
arm64-frame-pointer-unwind-support.h
auxtrace.c perf auxtrace: Fix address filter entire kernel size 2023-05-11 23:03:42 +09:00
auxtrace.h perf auxtrace arm64: Add support for HiSilicon PCIe Tune and Trace device driver 2022-10-15 10:13:16 -03:00
block-info.c
block-info.h
block-range.c
block-range.h
bpf_counter_cgroup.c perf stat: Fix handling of unsupported cgroup events when using BPF counters 2023-01-12 12:02:30 +01:00
bpf_counter.c
bpf_counter.h perf build: Properly guard libbpf includes 2023-01-18 11:58:31 +01:00
bpf_ftrace.c
bpf_kwork.c
bpf_lock_contention.c perf lock: Remove unused struct lock_contention_key 2022-10-06 08:03:52 -03:00
bpf_map.c
bpf_map.h
bpf_off_cpu.c perf off_cpu: Fix a typo in BTF tracepoint name, it should be 'btf_trace_sched_switch' 2022-12-31 13:32:45 +01:00
bpf-event.c perf bpf: Fix build with libbpf 0.7.0 by adding prototype for bpf_load_program() 2022-10-25 17:40:48 -03:00
bpf-event.h perf bpf: Remove unused pthread.h include 2022-10-04 08:55:19 -03:00
bpf-loader.c perf bpf: Fix build with libbpf 0.7.0 by checking if bpf_program__set_insns() is available 2022-10-25 17:40:48 -03:00
bpf-loader.h
bpf-prologue.c
bpf-prologue.h
bpf-utils.c
bpf-utils.h
branch.c perf branch: Add PERF_BR_NEW_ARCH_[N] map for BRBE on arm64 platform 2022-10-04 08:55:20 -03:00
branch.h perf branch: Fix interpretation of branch records 2022-12-31 13:32:45 +01:00
Build perf build: Define YYNOMEM as YYNOABORT for bison < 3.81 2023-10-06 14:56:58 +02:00
build-id.c perf dso: Hold lock when accessing nsinfo 2022-10-04 08:55:20 -03:00
build-id.h
cache.h
cacheline.c
cacheline.h
call-path.c
call-path.h
callchain.c perf callchain: Remove unneeded 'result' variable 2022-10-04 08:55:21 -03:00
callchain.h
cap.c
cap.h
cgroup.c perf stat: Fix handling of --for-each-cgroup with --bpf-counters to match non BPF mode 2023-01-12 12:02:31 +01:00
cgroup.h
clockid.c
clockid.h
cloexec.c
cloexec.h
color_config.c
color.c
color.h
comm.c
comm.h
compress.h
config.c perf tools: Add perf_config_scan() 2022-10-04 08:55:21 -03:00
config.h perf tools: Add perf_config_scan() 2022-10-04 08:55:21 -03:00
copyfile.c
copyfile.h
counts.c
counts.h
cpu-set-sched.h
cpumap.c perf stat: Rename to aggr_cpu_id.thread_idx 2022-10-06 08:03:53 -03:00
cpumap.h perf stat: Rename to aggr_cpu_id.thread_idx 2022-10-06 08:03:53 -03:00
cputopo.c perf topology: Add core_wide 2022-10-04 08:55:22 -03:00
cputopo.h perf topology: Add core_wide 2022-10-04 08:55:22 -03:00
cs-etm.c perf cs-etm: Fix timeless decode mode detection 2023-05-17 11:53:40 +02:00
cs-etm.h
data-convert-bt.c
data-convert-json.c
data-convert.h
data.c perf tools: Fix resources leak in perf_data__open_dir() 2023-01-12 12:02:27 +01:00
data.h
db-export.c
db-export.h
debug.c perf debug: Set debug_peo_args and redirect_to_stderr variable to correct values in perf_quiet_option() 2022-12-31 13:33:07 +01:00
debug.h
demangle-java.c
demangle-java.h
demangle-ocaml.c
demangle-ocaml.h
demangle-rust.c
demangle-rust.h
dlfilter.c
dlfilter.h
dso.c perf dso: Hold lock when accessing nsinfo 2022-10-04 08:55:20 -03:00
dso.h perf dso: Update use of pthread mutex 2022-10-04 08:55:20 -03:00
dsos.c
dsos.h
dump-insn.c
dump-insn.h
dwarf-aux.c perf dwarf-aux: Fix off-by-one in die_get_varname() 2023-07-19 16:21:38 +02:00
dwarf-aux.h
dwarf-regs.c
env.c
env.h
event.c
event.h perf tools: Support reading PERF_FORMAT_LOST 2022-08-19 15:56:56 -03:00
events_stats.h perf hist: Add nr_lost_samples to hist_stats 2022-10-04 08:55:20 -03:00
evlist-hybrid.c
evlist-hybrid.h
evlist.c perf evlist: Avoid frequency mode for the dummy event 2023-11-08 14:11:02 +01:00
evlist.h perf tools: Add evlist__add_sched_switch() 2022-10-06 08:03:53 -03:00
evsel_config.h
evsel_fprintf.c
evsel_fprintf.h
evsel.c perf tools: Remove special handling of system-wide evsel 2022-10-06 08:03:53 -03:00
evsel.h perf stat: Separate bperf from bpf_profiler 2023-05-17 11:53:41 +02:00
evswitch.c
evswitch.h
expr.c perf expr: Remove jevents case workaround 2022-10-06 08:03:52 -03:00
expr.h perf metrics: Wire up core_wide 2022-10-04 08:55:22 -03:00
expr.l perf metrics: Wire up core_wide 2022-10-04 08:55:22 -03:00
expr.y perf expr: Allow a double if expression 2022-10-06 08:03:52 -03:00
find-map.c
fncache.c
fncache.h
ftrace.h
genelf_debug.c
genelf.c perf genelf: Fix error code in jit_write_elf() 2022-10-04 08:55:22 -03:00
genelf.h perf inject: Fix GEN_ELF_TEXT_OFFSET for jit 2022-10-15 10:13:16 -03:00
generate-cmdlist.sh
get_current_dir_name.c
get_current_dir_name.h
hashmap.c
hashmap.h
header.c perf tools: Handle old data in PERF_RECORD_ATTR 2023-09-19 12:28:07 +02:00
header.h
help-unknown-cmd.c
help-unknown-cmd.h
hisi-ptt.c perf auxtrace arm64: Add support for parsing HiSilicon PCIe Trace packet 2022-10-15 10:13:16 -03:00
hisi-ptt.h perf auxtrace arm64: Add support for parsing HiSilicon PCIe Trace packet 2022-10-15 10:13:16 -03:00
hist.c perf tools: Add 'addr' sort key 2022-10-04 08:55:22 -03:00
hist.h perf tools: Add 'addr' sort key 2022-10-04 08:55:22 -03:00
intel-bts.c
intel-bts.h
intel-pt.c perf intel-pt: Do not try to queue auxtrace data on pipe 2023-03-10 09:33:26 +01:00
intel-pt.h
intlist.c
intlist.h
iostat.c
iostat.h
jit.h
jitdump.c perf jit: Remove unused struct debug_line_info 2022-10-06 08:03:51 -03:00
jitdump.h
kvm-stat.h
kwork.h
levenshtein.c
levenshtein.h
llvm-utils.c perf llvm: Fix inadvertent file creation 2023-03-10 09:33:25 +01:00
llvm-utils.h
lock-contention.h perf lock contention: Fix a build error on 32-bit 2022-10-06 08:03:51 -03:00
lzma.c
machine.c perf machine: Remove unused struct process_args 2022-10-06 08:03:51 -03:00
machine.h
map_symbol.h
map.c perf dso: Hold lock when accessing nsinfo 2022-10-04 08:55:20 -03:00
map.h
maps.c
maps.h
mem-events.c perf mem: Print "LFB/MAB" for PERF_MEM_LVLNUM_LFB 2022-10-06 16:32:05 -03:00
mem-events.h
mem2node.c
mem2node.h
memswap.c
memswap.h
metricgroup.c perf metric: Remove unused struct metric_ref_node 2022-10-06 08:03:51 -03:00
metricgroup.h perf metrics: Wire up core_wide 2022-10-04 08:55:22 -03:00
mmap.c
mmap.h perf mmap: Remove unnecessary pthread.h include 2022-10-04 08:55:20 -03:00
mutex.c perf mutex: Add thread safety annotations 2022-10-04 08:55:20 -03:00
mutex.h perf mutex: Add thread safety annotations 2022-10-04 08:55:20 -03:00
namespaces.c
namespaces.h
off_cpu.h
ordered-events.c
ordered-events.h
parse-branch-options.c perf test: Fix skipping branch stack sampling test 2022-11-08 17:59:14 -03:00
parse-branch-options.h
parse-events-hybrid.c perf parse-events: Remove "not supported" hybrid cache events 2022-09-26 10:16:26 -03:00
parse-events-hybrid.h
parse-events.c perf: Skip and warn on unknown format 'configN' attrs 2022-10-14 12:23:09 -03:00
parse-events.h perf parse-events: Remove "not supported" hybrid cache events 2022-09-26 10:16:26 -03:00
parse-events.l
parse-events.y
parse-regs-options.c
parse-regs-options.h
parse-sublevel-options.c
parse-sublevel-options.h
path.c
path.h
perf_api_probe.c
perf_api_probe.h
perf_event_attr_fprintf.c perf tools: Print LOST read format in the verbose mode 2022-10-04 08:55:20 -03:00
perf_regs.c
perf_regs.h
perf-hooks-list.h
perf-hooks.c
perf-hooks.h
PERF-VERSION-GEN perf tools: Fix empty version number when building outside of a git repo 2022-10-06 08:03:52 -03:00
pfm.c
pfm.h
pmu-hybrid.c
pmu-hybrid.h
pmu.c perf pmu: zfree() expects a pointer to a pointer to zero it after freeing its contents 2023-05-17 11:53:39 +02:00
pmu.h perf: Skip and warn on unknown format 'configN' attrs 2022-10-14 12:23:09 -03:00
pmu.l perf: Skip and warn on unknown format 'configN' attrs 2022-10-14 12:23:09 -03:00
pmu.y perf: Skip and warn on unknown format 'configN' attrs 2022-10-14 12:23:09 -03:00
print_binary.c
print_binary.h
print-events.c perf parse-events: Remove "not supported" hybrid cache events 2022-09-26 10:16:26 -03:00
print-events.h
probe-event.c perf dso: Hold lock when accessing nsinfo 2022-10-04 08:55:20 -03:00
probe-event.h
probe-file.c
probe-file.h
probe-finder.c
probe-finder.h
pstack.c
pstack.h
python-ext-sources
python.c
rb_resort.h
rblist.c
rblist.h
record.c
record.h
rlimit.c
rlimit.h
rwsem.c
rwsem.h
s390-cpumcf-kernel.h
s390-cpumsf-kernel.h
s390-cpumsf.c
s390-cpumsf.h
s390-sample-raw.c perf pmu-events: Hide the pmu_events 2022-08-13 15:02:08 -03:00
sample-raw.c
sample-raw.h
session.c perf cpumap: Add range data encoding 2022-10-04 08:55:21 -03:00
session.h
setns.c
setup.py
sideband_evlist.c
smt.c perf topology: Add core_wide 2022-10-04 08:55:22 -03:00
smt.h perf topology: Add core_wide 2022-10-04 08:55:22 -03:00
sort.c perf map: Delete two variable initialisations before null pointer checks in sort__sym_from_cmp() 2023-05-17 11:53:40 +02:00
sort.h perf tools: Add 'addr' sort key 2022-10-04 08:55:22 -03:00
spark.c
spark.h
srccode.c
srccode.h
srcline.c
srcline.h
stat-display.c perf stat: Move common code in print_metric_headers() 2022-12-31 13:32:44 +01:00
stat-shadow.c perf stat: Don't compare runtime stat for shadow stats 2022-10-06 08:03:53 -03:00
stat.c perf stat: Fix counting when initial delay configured 2023-03-17 08:50:24 +01:00
stat.h perf stat: Fix counting when initial delay configured 2023-03-17 08:50:24 +01:00
strbuf.c
strbuf.h
stream.c
stream.h
strfilter.c
strfilter.h
string.c perf string: Remove unused macro K() 2022-10-04 08:55:23 -03:00
string2.h
strlist.c
strlist.h
svghelper.c
svghelper.h
symbol_conf.h
symbol_fprintf.c
symbol-elf.c perf symbols: Fix return incorrect build_id size in elf_read_build_id() 2023-05-17 11:53:40 +02:00
symbol-minimal.c
symbol.c perf symbols: Symbol lookup with kcore can fail if multiple segments match stext 2023-07-05 18:27:37 +01:00
symbol.h
symsrc.h
synthetic-events.c perf record: Save DSO build-ID for synthesizing 2022-10-06 11:12:14 -03:00
synthetic-events.h perf cpumap: Synthetic events and const/static 2022-08-19 12:26:58 -03:00
syscalltbl.c
syscalltbl.h
target.c
target.h perf stat: Fix counting when initial delay configured 2023-03-17 08:50:24 +01:00
term.c
term.h
thread_map.c
thread_map.h
thread-stack.c
thread-stack.h
thread.c
thread.h
time-utils.c
time-utils.h
tool.h
top.c
top.h perf top: Update use of pthread mutex 2022-10-04 08:55:20 -03:00
topdown.c
topdown.h
trace-event-info.c
trace-event-parse.c
trace-event-read.c
trace-event-scripting.c
trace-event.c
trace-event.h
tracepoint.c perf tracepoint: Fix memory leak in is_valid_tracepoint() 2023-05-17 11:53:41 +02:00
tracepoint.h
trigger.h
tsc.c
tsc.h
units.c
units.h
unwind-libdw.c
unwind-libdw.h
unwind-libunwind-local.c
unwind-libunwind.c
unwind.h
usage.c
util.c
util.h
values.c
values.h
vdso.c
vdso.h
zlib.c
zstd.c