mirror-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 perf arm-spe: Use SPE data source for neoverse cores 2022-08-11 19:12:01 -03:00
bpf_skel perf stat: Support old kernels for bperf cgroup counting 2022-10-14 10:29:05 -03:00
c++ perf clang: Fix header include for LLVM >= 14 2022-04-22 18:39:34 -03:00
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 perf unwind arm64: Use perf's copy of kernel headers 2022-05-26 12:36:58 -03:00
scripting-engines perf build: Fixup disabling of -Wdeprecated-declarations for the python scripting engine 2022-09-29 16:03:35 -03:00
Build perf build: Define YYNOMEM as YYNOABORT for bison < 3.81 2023-10-06 14:56:58 +02:00
PERF-VERSION-GEN perf tools: Fix empty version number when building outside of a git repo 2022-10-06 08:03:52 -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 perf script ibs: Support new IBS bits in raw trace dump 2022-06-24 13:18:55 -03:00
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 perf unwind: Don't show unwind error messages when augmenting frame pointer stack 2022-04-09 12:34:29 -03:00
arm64-frame-pointer-unwind-support.h perf arm64: Inject missing frames when using 'perf record --call-graph=fp' 2021-12-21 18:37:13 -03:00
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-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 perf bpf: 8 byte align bpil data 2022-06-28 12:05:25 -03:00
bpf-utils.h
bpf_counter.c perf build: Stop using __weak bpf_map_create() to handle older libbpf versions 2022-05-26 12:36:56 -03:00
bpf_counter.h perf build: Properly guard libbpf includes 2023-01-18 11:58:31 +01:00
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_ftrace.c perf evlist: Rename cpus to user_requested_cpus 2022-04-01 16:19:35 -03:00
bpf_kwork.c perf kwork: Add workqueue trace BPF support 2022-07-26 16:31:54 -03:00
bpf_lock_contention.c perf lock: Remove unused struct lock_contention_key 2022-10-06 08:03:52 -03:00
bpf_map.c perf: Stop using bpf_map__def() API 2022-01-12 17:01:38 -08:00
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
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-id.c perf dso: Hold lock when accessing nsinfo 2022-10-04 08:55:20 -03:00
build-id.h perf buildid-cache: Add guestmount'd files to the build ID cache 2022-07-20 11:07:53 -03:00
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 perf callchain: Enable dwarf_callchain_users on arm64 2021-12-21 18:35:44 -03:00
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.c
color.h
color_config.c
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 perf cpumap: Migrate to libperf cpumap api 2022-01-22 17:08:42 -03:00
counts.h perf counts: Switch name cpu to cpu_map_idx 2022-01-12 14:28:22 -03:00
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 perf data convert: Prefer sampled CPU when exporting JSON 2022-06-23 11:54:21 -03:00
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 perf data: Add missing unistd.h header needed for pid_t 2022-07-25 18:10:43 -03:00
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 perf dlfilter: Add machine_pid and vcpu 2022-07-20 11:08:13 -03:00
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 perf tools: Fix dso_id inode generation comparison 2022-07-19 16:19:00 -03:00
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 perf header: Record non-CPU PMU capabilities 2022-06-24 13:18:55 -03:00
env.h perf header: Record non-CPU PMU capabilities 2022-06-24 13:18:55 -03:00
event.c perf record: Add finished init event 2022-06-23 11:54:22 -03:00
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 perf evlist: Fix failed to use cpu list for uncore events 2022-02-18 09:59:26 -03:00
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.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
evsel_config.h
evsel_fprintf.c
evsel_fprintf.h
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 perf ftrace latency: Add -n/--use-nsec option 2022-03-22 17:43:46 -03:00
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
genelf_debug.c
generate-cmdlist.sh
get_current_dir_name.c
get_current_dir_name.h
hashmap.c perf tools: Update copy of libbpf's hashmap.c 2022-04-01 16:19:34 -03:00
hashmap.h
header.c perf tools: Handle old data in PERF_RECORD_ATTR 2023-09-19 12:28:07 +02:00
header.h Merge remote-tracking branch 'torvalds/master' into perf/core 2022-07-18 10:36:11 -03:00
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 perf kwork: Implement BPF trace 2022-07-26 16:31:54 -03:00
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 perf machine: Use realloc_array_as_needed() in machine__set_current_tid() 2022-07-20 11:08:37 -03:00
map.c perf dso: Hold lock when accessing nsinfo 2022-10-04 08:55:20 -03:00
map.h perf map: Make map__contains_symbol() args const 2022-02-14 16:59:55 -03:00
map_symbol.h perf tools: Apply correct label to user/kernel symbols in branch mode 2022-02-06 09:03:06 -03:00
maps.c perf maps: Move maps code to own C file 2022-02-14 16:56:32 -03:00
maps.h perf maps: Reduce scope of init and exit 2022-02-14 16:52:14 -03:00
mem-events.c perf mem: Print "LFB/MAB" for PERF_MEM_LVLNUM_LFB 2022-10-06 16:32:05 -03:00
mem-events.h perf mem: Add statistics for peer snooping 2022-08-11 19:12:12 -03:00
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 perf auxtrace: Remove auxtrace_mmap_params__set_idx() per_cpu parameter 2022-05-26 12:36:57 -03:00
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 perf namespaces: Add functions to access nsinfo 2022-02-11 14:31:22 -03:00
namespaces.h perf namespaces: Add functions to access nsinfo 2022-02-11 14:31:22 -03:00
off_cpu.h perf offcpu: Accept allowed sample types only 2022-06-28 11:45:45 -03:00
ordered-events.c perf report: Output data file name in raw trace dump 2022-02-10 16:27:34 -03:00
ordered-events.h perf ordered_events: Add ordered_events__last_flush_time() 2022-07-20 11:07:30 -03:00
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 perf stat: Add user_time and system_time events 2022-04-20 13:44:56 -03:00
parse-events.y perf parse-events: Support event alias in form foo-bar-baz 2022-01-22 17:20:12 -03:00
parse-regs-options.c
parse-regs-options.h
parse-sublevel-options.c
parse-sublevel-options.h
path.c perf test: Shell - Limit to only run executable scripts in tests 2022-04-11 16:39:49 -03:00
path.h perf test: Shell - Limit to only run executable scripts in tests 2022-04-11 16:39:49 -03:00
perf-hooks-list.h
perf-hooks.c
perf-hooks.h
perf_api_probe.c perf tools: Do not pass NULL to parse_events() 2022-08-10 14:30:09 -03:00
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 tools arm64: Add support for VG register 2022-05-27 13:21:33 -03:00
perf_regs.h perf tools: Refactor SMPL_REG macro in perf_regs.h 2021-12-21 18:35:44 -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-events.c perf parse-events: Remove "not supported" hybrid cache events 2022-09-26 10:16:26 -03:00
print-events.h perf parse-events: Break out tracepoint and printing 2022-08-02 16:32:26 -03:00
print_binary.c
print_binary.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 perf unwind: Use dynamic register set for DWARF unwind 2022-05-26 12:41:36 -03:00
python.c perf python: Add perf_env stubs that will be needed in evsel__open_strerror() 2022-03-26 10:55:57 -03:00
rb_resort.h
rblist.c
rblist.h
record.c perf tools: Do not pass NULL to parse_events() 2022-08-10 14:30:09 -03:00
record.h perf record: Add new option to sample identifier 2022-06-23 11:54:22 -03:00
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 perf tools: Export perf_event__process_finished_round() 2022-07-20 11:07:37 -03:00
setns.c
setup.py perf python: Ignore unused command line arguments when building with clang 2022-07-20 15:14:39 -03:00
sideband_evlist.c perf evlist: Rename cpus to user_requested_cpus 2022-04-01 16:19:35 -03:00
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 perf cpumap: Migrate to libperf cpumap api 2022-01-22 17:08:42 -03:00
svghelper.h
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 perf symbol: Remove arch__symbols__fixup_end() 2022-04-28 10:51:40 -03:00
symbol_conf.h perf tools: Add guest_code support 2022-05-23 10:18:38 -03:00
symbol_fprintf.c
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-stack.c
thread-stack.h
thread.c perf tools: Add guest_cpu to hypervisor threads 2022-07-20 11:08:04 -03:00
thread.h perf tools: Add guest_cpu to hypervisor threads 2022-07-20 11:08:04 -03:00
thread_map.c
thread_map.h
time-utils.c
time-utils.h
tool.h perf record: Add finished init event 2022-06-23 11:54:22 -03:00
top.c perf evlist: Rename cpus to user_requested_cpus 2022-04-01 16:19:35 -03:00
top.h perf top: Update use of pthread mutex 2022-10-04 08:55:20 -03:00
topdown.c perf stat: Add topdown metrics in the default perf stat on the hybrid machine 2022-07-29 13:43:34 -03:00
topdown.h perf stat: Add topdown metrics in the default perf stat on the hybrid machine 2022-07-29 13:43:34 -03:00
trace-event-info.c perf parse-events: Break out tracepoint and printing 2022-08-02 16:32:26 -03:00
trace-event-parse.c perf tools: Use ARRAY_SIZE() instead of ad hoc equivalent, spotted by array_size.cocci 2022-03-07 14:54:54 -03:00
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 perf parse-events: Break out tracepoint and printing 2022-08-02 16:32:26 -03:00
trigger.h
tsc.c
tsc.h perf tsc: Add arch TSC frequency information 2022-07-25 12:28:00 -03:00
units.c
units.h
unwind-libdw.c perf unwind: Don't show unwind error messages when augmenting frame pointer stack 2022-04-09 12:34:29 -03:00
unwind-libdw.h perf unwind: Don't show unwind error messages when augmenting frame pointer stack 2022-04-09 12:34:29 -03:00
unwind-libunwind-local.c perf unwind: Fix unitialized 'offset' variable on aarch64 2022-07-02 09:16:52 -03:00
unwind-libunwind.c perf unwind: Don't show unwind error messages when augmenting frame pointer stack 2022-04-09 12:34:29 -03:00
unwind.h perf unwind: Don't show unwind error messages when augmenting frame pointer stack 2022-04-09 12:34:29 -03:00
usage.c
util.c perf tools: Add reallocarray_as_needed() 2022-07-20 11:08:37 -03:00
util.h perf tools: Add reallocarray_as_needed() 2022-07-20 11:08:37 -03:00
values.c
values.h
vdso.c
vdso.h
zlib.c
zstd.c