2024-10-01 20:20:07 -07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
#ifndef __TOOL_PMU_H
|
|
|
|
#define __TOOL_PMU_H
|
|
|
|
|
|
|
|
#include "pmu.h"
|
|
|
|
|
|
|
|
struct evsel;
|
|
|
|
struct perf_thread_map;
|
|
|
|
struct print_callbacks;
|
|
|
|
|
2024-10-01 20:20:08 -07:00
|
|
|
enum tool_pmu_event {
|
|
|
|
TOOL_PMU__EVENT_NONE = 0,
|
perf tool_pmu: Move expr literals to tool_pmu
Add the expr literals like "#smt_on" as tool events, this allows stat
events to give the values. On my laptop with hyperthreading enabled:
```
$ perf stat -e "has_pmem,num_cores,num_cpus,num_cpus_online,num_dies,num_packages,smt_on,system_tsc_freq" true
Performance counter stats for 'true':
0 has_pmem
8 num_cores
16 num_cpus
16 num_cpus_online
1 num_dies
1 num_packages
1 smt_on
2,496,000,000 system_tsc_freq
0.001113637 seconds time elapsed
0.001218000 seconds user
0.000000000 seconds sys
```
And with hyperthreading disabled:
```
$ perf stat -e "has_pmem,num_cores,num_cpus,num_cpus_online,num_dies,num_packages,smt_on,system_tsc_freq" true
Performance counter stats for 'true':
0 has_pmem
8 num_cores
16 num_cpus
8 num_cpus_online
1 num_dies
1 num_packages
0 smt_on
2,496,000,000 system_tsc_freq
0.000802115 seconds time elapsed
0.000000000 seconds user
0.000806000 seconds sys
```
As zero matters for these values, in stat-display
should_skip_zero_counter only skip the zero value if it is not the
first aggregation index.
The tool event implementations are used in expr but not evaluated as
events for simplicity. Also core_wide isn't made a tool event as it
requires command line parameters.
Signed-off-by: Ian Rogers <irogers@google.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20241002032016.333748-8-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
2024-10-01 20:20:10 -07:00
|
|
|
TOOL_PMU__EVENT_DURATION_TIME,
|
|
|
|
TOOL_PMU__EVENT_USER_TIME,
|
|
|
|
TOOL_PMU__EVENT_SYSTEM_TIME,
|
|
|
|
TOOL_PMU__EVENT_HAS_PMEM,
|
|
|
|
TOOL_PMU__EVENT_NUM_CORES,
|
|
|
|
TOOL_PMU__EVENT_NUM_CPUS,
|
|
|
|
TOOL_PMU__EVENT_NUM_CPUS_ONLINE,
|
|
|
|
TOOL_PMU__EVENT_NUM_DIES,
|
|
|
|
TOOL_PMU__EVENT_NUM_PACKAGES,
|
|
|
|
TOOL_PMU__EVENT_SLOTS,
|
|
|
|
TOOL_PMU__EVENT_SMT_ON,
|
|
|
|
TOOL_PMU__EVENT_SYSTEM_TSC_FREQ,
|
2024-10-01 20:20:07 -07:00
|
|
|
|
2024-10-01 20:20:08 -07:00
|
|
|
TOOL_PMU__EVENT_MAX,
|
2024-10-01 20:20:07 -07:00
|
|
|
};
|
|
|
|
|
2024-10-01 20:20:09 -07:00
|
|
|
#define tool_pmu__for_each_event(ev) \
|
2024-10-01 20:20:08 -07:00
|
|
|
for ((ev) = TOOL_PMU__EVENT_DURATION_TIME; (ev) < TOOL_PMU__EVENT_MAX; ev++)
|
2024-10-01 20:20:07 -07:00
|
|
|
|
2024-10-01 20:20:09 -07:00
|
|
|
const char *tool_pmu__event_to_str(enum tool_pmu_event ev);
|
|
|
|
enum tool_pmu_event tool_pmu__str_to_event(const char *str);
|
2024-10-01 20:20:12 -07:00
|
|
|
bool tool_pmu__skip_event(const char *name);
|
|
|
|
int tool_pmu__num_skip_events(void);
|
|
|
|
|
perf tool_pmu: Allow num_cpus(_online) to be specific to a cpumask
For hybrid metrics it is useful to know the number of p-core or e-core
CPUs. If a cpumask is specified for the num_cpus or num_cpus_online
tool events, compute the value relative to the given mask rather than
for the full system.
```
$ sudo /tmp/perf/perf stat -e 'tool/num_cpus/,tool/num_cpus,cpu=cpu_core/,
tool/num_cpus,cpu=cpu_atom/,tool/num_cpus_online/,tool/num_cpus_online,
cpu=cpu_core/,tool/num_cpus_online,cpu=cpu_atom/' true
Performance counter stats for 'true':
28 tool/num_cpus/
16 tool/num_cpus,cpu=cpu_core/
12 tool/num_cpus,cpu=cpu_atom/
28 tool/num_cpus_online/
16 tool/num_cpus_online,cpu=cpu_core/
12 tool/num_cpus_online,cpu=cpu_atom/
0.000767205 seconds time elapsed
0.000938000 seconds user
0.000000000 seconds sys
```
Reviewed-by: Thomas Falcon <thomas.falcon@intel.com>
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: James Clark <james.clark@linaro.org>
Link: https://lore.kernel.org/r/20250719030517.1990983-6-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
2025-07-18 20:05:07 -07:00
|
|
|
bool tool_pmu__read_event(enum tool_pmu_event ev, struct evsel *evsel, u64 *result);
|
2024-10-01 20:20:07 -07:00
|
|
|
|
perf tool_pmu: Move expr literals to tool_pmu
Add the expr literals like "#smt_on" as tool events, this allows stat
events to give the values. On my laptop with hyperthreading enabled:
```
$ perf stat -e "has_pmem,num_cores,num_cpus,num_cpus_online,num_dies,num_packages,smt_on,system_tsc_freq" true
Performance counter stats for 'true':
0 has_pmem
8 num_cores
16 num_cpus
16 num_cpus_online
1 num_dies
1 num_packages
1 smt_on
2,496,000,000 system_tsc_freq
0.001113637 seconds time elapsed
0.001218000 seconds user
0.000000000 seconds sys
```
And with hyperthreading disabled:
```
$ perf stat -e "has_pmem,num_cores,num_cpus,num_cpus_online,num_dies,num_packages,smt_on,system_tsc_freq" true
Performance counter stats for 'true':
0 has_pmem
8 num_cores
16 num_cpus
8 num_cpus_online
1 num_dies
1 num_packages
0 smt_on
2,496,000,000 system_tsc_freq
0.000802115 seconds time elapsed
0.000000000 seconds user
0.000806000 seconds sys
```
As zero matters for these values, in stat-display
should_skip_zero_counter only skip the zero value if it is not the
first aggregation index.
The tool event implementations are used in expr but not evaluated as
events for simplicity. Also core_wide isn't made a tool event as it
requires command line parameters.
Signed-off-by: Ian Rogers <irogers@google.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20241002032016.333748-8-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
2024-10-01 20:20:10 -07:00
|
|
|
u64 tool_pmu__cpu_slots_per_cycle(void);
|
2024-10-01 20:20:07 -07:00
|
|
|
|
perf tool_pmu: Move expr literals to tool_pmu
Add the expr literals like "#smt_on" as tool events, this allows stat
events to give the values. On my laptop with hyperthreading enabled:
```
$ perf stat -e "has_pmem,num_cores,num_cpus,num_cpus_online,num_dies,num_packages,smt_on,system_tsc_freq" true
Performance counter stats for 'true':
0 has_pmem
8 num_cores
16 num_cpus
16 num_cpus_online
1 num_dies
1 num_packages
1 smt_on
2,496,000,000 system_tsc_freq
0.001113637 seconds time elapsed
0.001218000 seconds user
0.000000000 seconds sys
```
And with hyperthreading disabled:
```
$ perf stat -e "has_pmem,num_cores,num_cpus,num_cpus_online,num_dies,num_packages,smt_on,system_tsc_freq" true
Performance counter stats for 'true':
0 has_pmem
8 num_cores
16 num_cpus
8 num_cpus_online
1 num_dies
1 num_packages
0 smt_on
2,496,000,000 system_tsc_freq
0.000802115 seconds time elapsed
0.000000000 seconds user
0.000806000 seconds sys
```
As zero matters for these values, in stat-display
should_skip_zero_counter only skip the zero value if it is not the
first aggregation index.
The tool event implementations are used in expr but not evaluated as
events for simplicity. Also core_wide isn't made a tool event as it
requires command line parameters.
Signed-off-by: Ian Rogers <irogers@google.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20241002032016.333748-8-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
2024-10-01 20:20:10 -07:00
|
|
|
bool perf_pmu__is_tool(const struct perf_pmu *pmu);
|
2024-10-01 20:20:07 -07:00
|
|
|
|
|
|
|
bool evsel__is_tool(const struct evsel *evsel);
|
2024-10-01 20:20:08 -07:00
|
|
|
enum tool_pmu_event evsel__tool_event(const struct evsel *evsel);
|
2024-10-01 20:20:07 -07:00
|
|
|
const char *evsel__tool_pmu_event_name(const struct evsel *evsel);
|
|
|
|
int evsel__tool_pmu_prepare_open(struct evsel *evsel,
|
|
|
|
struct perf_cpu_map *cpus,
|
|
|
|
int nthreads);
|
|
|
|
int evsel__tool_pmu_open(struct evsel *evsel,
|
|
|
|
struct perf_thread_map *threads,
|
|
|
|
int start_cpu_map_idx, int end_cpu_map_idx);
|
2024-10-01 20:20:09 -07:00
|
|
|
int evsel__tool_pmu_read(struct evsel *evsel, int cpu_map_idx, int thread);
|
2024-10-01 20:20:07 -07:00
|
|
|
|
2025-02-26 10:41:00 +00:00
|
|
|
struct perf_pmu *tool_pmu__new(void);
|
2024-10-01 20:20:07 -07:00
|
|
|
|
|
|
|
#endif /* __TOOL_PMU_H */
|