mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00

The -C option allows the CPUs for a list of events to be specified but its not possible to set the CPU for a single event. Add a term to allow this. The term isn't a general CPU list due to ',' already being a special character in event parsing instead multiple cpu= terms may be provided and they will be merged/unioned together. An example of mixing different types of events counted on different CPUs: ``` $ perf stat -A -C 0,4-5,8 -e "instructions/cpu=0/,l1d-misses/cpu=4,cpu=5/,inst_retired.any/cpu=8/,cycles" -a sleep 0.1 Performance counter stats for 'system wide': CPU0 6,979,225 instructions/cpu=0/ # 0.89 insn per cycle CPU4 75,138 cpu/l1d-misses/ CPU5 1,418,939 cpu/l1d-misses/ CPU8 797,553 cpu/inst_retired.any,cpu=8/ CPU0 7,845,302 cycles CPU4 6,546,859 cycles CPU5 185,915,438 cycles CPU8 2,065,668 cycles 0.112449242 seconds time elapsed ``` Committer testing: root@number:~# grep -m1 "model name" /proc/cpuinfo model name : AMD Ryzen 9 9950X3D 16-Core Processor root@number:~# perf stat -A -e "instructions/cpu=0/,instructions,l1d-misses/cpu=4,cpu=5/,cycles" -a sleep 0.1 Performance counter stats for 'system wide': CPU0 2,398,351 instructions/cpu=0/ # 0.44 insn per cycle CPU0 2,398,152 instructions # 0.44 insn per cycle CPU1 1,265,634 instructions # 0.49 insn per cycle CPU2 606,087 instructions # 0.50 insn per cycle CPU3 4,025,752 instructions # 0.52 insn per cycle CPU4 4,236,810 instructions # 0.53 insn per cycle CPU5 3,984,832 instructions # 0.66 insn per cycle CPU6 434,132 instructions # 0.44 insn per cycle CPU7 65,752 instructions # 0.41 insn per cycle CPU8 459,083 instructions # 0.48 insn per cycle CPU9 6,464,161 instructions # 1.31 insn per cycle <SNIP> root@number:~# perf stat -e "instructions/cpu=0/,instructions,l1d-misses/cpu=4,cpu=5/,cycles" -a sleep 0. Performance counter stats for 'system wide': 144,822 instructions/cpu=0/ # 0.03 insn per cycle 4,666,114 instructions # 0.93 insn per cycle 2,583 l1d-misses 4,993,633 cycles 0.000868512 seconds time elapsed root@number:~# Signed-off-by: Ian Rogers <irogers@google.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Tested-by: Kan Liang <kan.liang@linux.intel.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Dominique Martinet <asmadeus@codewreck.org> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: James Clark <james.clark@linaro.org> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Leo Yan <leo.yan@arm.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Weilin Wang <weilin.wang@intel.com> Cc: Yicong Yang <yangyicong@hisilicon.com> Link: https://lore.kernel.org/r/20250403194337.40202-5-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
63 lines
1.5 KiB
C
63 lines
1.5 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
#ifndef __PERF_EVSEL_CONFIG_H
|
|
#define __PERF_EVSEL_CONFIG_H 1
|
|
|
|
#include <linux/types.h>
|
|
#include <stdbool.h>
|
|
|
|
/*
|
|
* The 'struct evsel_config_term' is used to pass event
|
|
* specific configuration data to evsel__config routine.
|
|
* It is allocated within event parsing and attached to
|
|
* evsel::config_terms list head.
|
|
*/
|
|
enum evsel_term_type {
|
|
EVSEL__CONFIG_TERM_PERIOD,
|
|
EVSEL__CONFIG_TERM_FREQ,
|
|
EVSEL__CONFIG_TERM_TIME,
|
|
EVSEL__CONFIG_TERM_CALLGRAPH,
|
|
EVSEL__CONFIG_TERM_STACK_USER,
|
|
EVSEL__CONFIG_TERM_INHERIT,
|
|
EVSEL__CONFIG_TERM_MAX_STACK,
|
|
EVSEL__CONFIG_TERM_MAX_EVENTS,
|
|
EVSEL__CONFIG_TERM_OVERWRITE,
|
|
EVSEL__CONFIG_TERM_DRV_CFG,
|
|
EVSEL__CONFIG_TERM_BRANCH,
|
|
EVSEL__CONFIG_TERM_PERCORE,
|
|
EVSEL__CONFIG_TERM_AUX_OUTPUT,
|
|
EVSEL__CONFIG_TERM_AUX_ACTION,
|
|
EVSEL__CONFIG_TERM_AUX_SAMPLE_SIZE,
|
|
EVSEL__CONFIG_TERM_CFG_CHG,
|
|
};
|
|
|
|
struct evsel_config_term {
|
|
struct list_head list;
|
|
enum evsel_term_type type;
|
|
bool free_str;
|
|
union {
|
|
u64 period;
|
|
u64 freq;
|
|
bool time;
|
|
u64 stack_user;
|
|
int max_stack;
|
|
bool inherit;
|
|
bool overwrite;
|
|
unsigned long max_events;
|
|
bool percore;
|
|
bool aux_output;
|
|
u32 aux_sample_size;
|
|
u64 cfg_chg;
|
|
char *str;
|
|
int cpu;
|
|
} val;
|
|
bool weak;
|
|
};
|
|
|
|
struct evsel;
|
|
|
|
struct evsel_config_term *__evsel__get_config_term(struct evsel *evsel, enum evsel_term_type type);
|
|
|
|
#define evsel__get_config_term(evsel, type) \
|
|
__evsel__get_config_term(evsel, EVSEL__CONFIG_TERM_ ## type)
|
|
|
|
#endif // __PERF_EVSEL_CONFIG_H
|