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

Configure Feed

Select the types of activity you want to include in your feed.

perf intel-pt: Do not default to recording all switch events

On systems with many CPUs, recording extra context switch events can be
excessive and unnecessary. Add perf config intel-pt.all-switch-events=false
to control the behaviour.

Example:

# perf config intel-pt.all-switch-events=false
# perf record -eintel_pt//u uname
Linux
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.082 MB perf.data ]
# perf script -D | grep PERF_RECORD_SWITCH | awk '{print $5}' | uniq -c
5 PERF_RECORD_SWITCH
# perf config intel-pt.all-switch-events=true
# perf record -eintel_pt//u uname
Linux
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.102 MB perf.data ]
# perf script -D | grep PERF_RECORD_SWITCH | awk '{print $5}' | uniq -c
180 PERF_RECORD_SWITCH_CPU_WIDE

Committer testing:

While doing a make -j28 allmodconfig:

root@five:~# grep "model name" -m1 /proc/cpuinfo
model name : Intel(R) Core(TM) i7-14700K
root@five:~#
root@five:~# perf config intel-pt.all-switch-events=false
root@five:~# perf record -e intel_pt//u uname
Linux
[ perf record: Woken up 2 times to write data ]
[ perf record: Captured and wrote 0.019 MB perf.data ]
root@five:~# perf report --stats | grep SWITCH_CPU_WIDE
root@five:~#
root@five:~# perf config intel-pt.all-switch-events=true
root@five:~# perf record -e intel_pt//u uname
Linux
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.047 MB perf.data ]
root@five:~# perf report --stats | grep SWITCH_CPU_WIDE
SWITCH_CPU_WIDE events: 542 (96.4%)
root@five:~#

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20250512093932.79854-3-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Adrian Hunter and committed by
Arnaldo Carvalho de Melo
352b0881 e00eac6b

+19 -1
+4
tools/perf/Documentation/perf-config.txt
··· 708 708 the maximum is exceeded there will be a "Never-ending loop" 709 709 error. The default is 100000. 710 710 711 + intel-pt.all-switch-events:: 712 + If the user has permission to do so, always record all context 713 + switch events on all CPUs. 714 + 711 715 auxtrace.*:: 712 716 713 717 auxtrace.dumpdir::
+15 -1
tools/perf/arch/x86/util/intel-pt.c
··· 19 19 #include "../../../util/evlist.h" 20 20 #include "../../../util/evsel.h" 21 21 #include "../../../util/evsel_config.h" 22 + #include "../../../util/config.h" 22 23 #include "../../../util/cpumap.h" 23 24 #include "../../../util/mmap.h" 24 25 #include <subcmd/parse-options.h> ··· 53 52 struct perf_pmu *intel_pt_pmu; 54 53 int have_sched_switch; 55 54 struct evlist *evlist; 55 + bool all_switch_events; 56 56 bool snapshot_mode; 57 57 bool snapshot_init_done; 58 58 size_t snapshot_size; ··· 796 794 bool cpu_wide = !target__none(&opts->target) && 797 795 !target__has_task(&opts->target); 798 796 799 - if (!cpu_wide && perf_can_record_cpu_wide()) { 797 + if (ptr->all_switch_events && !cpu_wide && perf_can_record_cpu_wide()) { 800 798 struct evsel *switch_evsel; 801 799 802 800 switch_evsel = evlist__add_dummy_on_all_cpus(evlist); ··· 1180 1178 return rdtsc(); 1181 1179 } 1182 1180 1181 + static int intel_pt_perf_config(const char *var, const char *value, void *data) 1182 + { 1183 + struct intel_pt_recording *ptr = data; 1184 + 1185 + if (!strcmp(var, "intel-pt.all-switch-events")) 1186 + ptr->all_switch_events = perf_config_bool(var, value); 1187 + 1188 + return 0; 1189 + } 1190 + 1183 1191 struct auxtrace_record *intel_pt_recording_init(int *err) 1184 1192 { 1185 1193 struct perf_pmu *intel_pt_pmu = perf_pmus__find(INTEL_PT_PMU_NAME); ··· 1208 1196 *err = -ENOMEM; 1209 1197 return NULL; 1210 1198 } 1199 + 1200 + perf_config(intel_pt_perf_config, ptr); 1211 1201 1212 1202 ptr->intel_pt_pmu = intel_pt_pmu; 1213 1203 ptr->itr.recording_options = intel_pt_recording_options;