mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-08-09 06:14:34 +02:00
Tool PMU events (duration_time, user_time, system_time) currently
count from when the event is opened to when it is read. This causes
issues with features like the delay option (-D) or control fd, where
events are opened but should not start counting immediately.
Make these events behave more like regular counters by implementing
proper enable and disable support. Add accumulated_time to struct
evsel to track time while enabled, and implement enable/disable CPU
callbacks to start/stop counting.
Also generalize userspace PMU mixed group handling. Userspace synthetic
PMUs (type > PERF_PMU_TYPE_PE_END) do not have kernel implementations and
cannot be grouped in the kernel (opened with group_fd = -1), and are
skipped by kernel enable/disable calls. Iterate over group members in
userspace and manually enable/disable any members if the leader or the
member is a non-perf-event open PMU, and synchronize their disabled flags.
Closes: https://lore.kernel.org/linux-perf-users/20260517093650.2540920-1-nigro.fra@gmail.com/
Fixes: b71f46a6a7 ("perf stat: Remove hard coded shadow metrics")
Reported-by: Francesco Nigro <nigro.fra@gmail.com>
Assisted-by: Antigravity:gemini-3-flash
Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ian Rogers <irogers@google.com>
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 Richter <tmricht@linux.ibm.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
68 lines
2.0 KiB
C
68 lines
2.0 KiB
C
/* 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;
|
|
|
|
enum tool_pmu_event {
|
|
TOOL_PMU__EVENT_NONE = 0,
|
|
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,
|
|
TOOL_PMU__EVENT_CORE_WIDE,
|
|
TOOL_PMU__EVENT_TARGET_CPU,
|
|
|
|
TOOL_PMU__EVENT_MAX,
|
|
};
|
|
|
|
#define tool_pmu__for_each_event(ev) \
|
|
for ((ev) = TOOL_PMU__EVENT_DURATION_TIME; (ev) < TOOL_PMU__EVENT_MAX; ev++)
|
|
|
|
const char *tool_pmu__event_to_str(enum tool_pmu_event ev);
|
|
enum tool_pmu_event tool_pmu__str_to_event(const char *str);
|
|
bool tool_pmu__skip_event(const char *name);
|
|
int tool_pmu__num_skip_events(void);
|
|
|
|
bool tool_pmu__read_event(enum tool_pmu_event ev,
|
|
struct evsel *evsel,
|
|
bool system_wide,
|
|
const char *user_requested_cpu_list,
|
|
u64 *result);
|
|
|
|
|
|
u64 tool_pmu__cpu_slots_per_cycle(void);
|
|
|
|
bool perf_pmu__is_tool(const struct perf_pmu *pmu);
|
|
|
|
bool evsel__is_tool(const struct evsel *evsel);
|
|
enum tool_pmu_event evsel__tool_event(const struct evsel *evsel);
|
|
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);
|
|
int evsel__tool_pmu_enable_cpu(struct evsel *evsel, int cpu_map_idx);
|
|
int evsel__tool_pmu_enable(struct evsel *evsel);
|
|
int evsel__tool_pmu_disable_cpu(struct evsel *evsel, int cpu_map_idx);
|
|
int evsel__tool_pmu_disable(struct evsel *evsel);
|
|
int evsel__tool_pmu_read(struct evsel *evsel, int cpu_map_idx, int thread);
|
|
|
|
struct perf_pmu *tool_pmu__new(void);
|
|
|
|
#endif /* __TOOL_PMU_H */
|