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 stat: Add no-affinity flag

Add flag that disables affinity behavior.

Using sched_setaffinity() to place a perf thread on a CPU can avoid
certain interprocessor interrupts but may introduce a delay due to the
scheduling, particularly on loaded machines.

Add a command line option to disable the behavior.

This behavior is less present in other tools like `perf record`, as it
uses a ring buffer and doesn't make repeated system calls.

Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Andres Freund <andres@anarazel.de>
Cc: Dapeng Mi <dapeng1.mi@linux.intel.com>
Cc: Dr. David Alan Gilbert <linux@treblig.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Falcon <thomas.falcon@intel.com>
Cc: Thomas Richter <tmricht@linux.ibm.com>
Cc: Yang Li <yang.lee@linux.alibaba.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
5d1ab659 d4843615

+13 -5
+5
tools/perf/Documentation/perf-stat.txt
··· 382 382 Don't print output, warnings or messages. This is useful with perf stat 383 383 record below to only write data to the perf.data file. 384 384 385 + --no-affinity:: 386 + Don't change scheduler CPU affinities when iterating over 387 + CPUs. Disables an optimization aimed at minimizing interprocessor 388 + interrupts. 389 + 385 390 STAT RECORD 386 391 ----------- 387 392 Stores stat data into perf data file.
+6
tools/perf/builtin-stat.c
··· 2426 2426 int cmd_stat(int argc, const char **argv) 2427 2427 { 2428 2428 struct opt_aggr_mode opt_mode = {}; 2429 + bool affinity = true, affinity_set = false; 2429 2430 struct option stat_options[] = { 2430 2431 OPT_BOOLEAN('T', "transaction", &transaction_run, 2431 2432 "hardware transaction statistics"), ··· 2555 2554 "don't print 'summary' for CSV summary output"), 2556 2555 OPT_BOOLEAN(0, "quiet", &quiet, 2557 2556 "don't print any output, messages or warnings (useful with record)"), 2557 + OPT_BOOLEAN_SET(0, "affinity", &affinity, &affinity_set, 2558 + "enable (default) or disable affinity optimizations to reduce IPIs"), 2558 2559 OPT_CALLBACK(0, "cputype", &evsel_list, "hybrid cpu type", 2559 2560 "Only enable events on applying cpu with this type " 2560 2561 "for hybrid platform (e.g. core or atom)", ··· 2613 2610 stat_config.csv_sep = "\t"; 2614 2611 } else 2615 2612 stat_config.csv_sep = DEFAULT_SEPARATOR; 2613 + 2614 + if (affinity_set) 2615 + evsel_list->no_affinity = !affinity; 2616 2616 2617 2617 if (argc && strlen(argv[0]) > 2 && strstarts("record", argv[0])) { 2618 2618 argc = __cmd_record(stat_options, &opt_mode, argc, argv);
+1 -5
tools/perf/util/evlist.c
··· 369 369 struct perf_cpu_map *used_cpus = NULL; 370 370 bool ret = false; 371 371 372 - /* 373 - * With perf record core.user_requested_cpus is usually NULL. 374 - * Use the old method to handle this for now. 375 - */ 376 - if (!evlist->core.user_requested_cpus || 372 + if (evlist->no_affinity || !evlist->core.user_requested_cpus || 377 373 cpu_map__is_dummy(evlist->core.user_requested_cpus)) 378 374 return false; 379 375
+1
tools/perf/util/evlist.h
··· 59 59 struct evlist { 60 60 struct perf_evlist core; 61 61 bool enabled; 62 + bool no_affinity; 62 63 int id_pos; 63 64 int is_pos; 64 65 int nr_br_cntr;