Skip to content

Commit e11c1a7

Browse files
Kan LiangPeter Zijlstra
authored andcommitted
perf/x86: Factor out x86_pmu_show_pmu_cap
The PMU capabilities are different among hybrid PMUs. Perf should dump the PMU capabilities information for each hybrid PMU. Factor out x86_pmu_show_pmu_cap() which shows the PMU capabilities information. The function will be reused later when registering a dedicated hybrid PMU. Signed-off-by: Kan Liang <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Andi Kleen <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent b985672 commit e11c1a7

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

arch/x86/events/core.c

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1976,6 +1976,20 @@ static void _x86_pmu_read(struct perf_event *event)
19761976
x86_perf_event_update(event);
19771977
}
19781978

1979+
void x86_pmu_show_pmu_cap(int num_counters, int num_counters_fixed,
1980+
u64 intel_ctrl)
1981+
{
1982+
pr_info("... version: %d\n", x86_pmu.version);
1983+
pr_info("... bit width: %d\n", x86_pmu.cntval_bits);
1984+
pr_info("... generic registers: %d\n", num_counters);
1985+
pr_info("... value mask: %016Lx\n", x86_pmu.cntval_mask);
1986+
pr_info("... max period: %016Lx\n", x86_pmu.max_period);
1987+
pr_info("... fixed-purpose events: %lu\n",
1988+
hweight64((((1ULL << num_counters_fixed) - 1)
1989+
<< INTEL_PMC_IDX_FIXED) & intel_ctrl));
1990+
pr_info("... event mask: %016Lx\n", intel_ctrl);
1991+
}
1992+
19791993
static int __init init_hw_perf_events(void)
19801994
{
19811995
struct x86_pmu_quirk *quirk;
@@ -2036,15 +2050,8 @@ static int __init init_hw_perf_events(void)
20362050

20372051
pmu.attr_update = x86_pmu.attr_update;
20382052

2039-
pr_info("... version: %d\n", x86_pmu.version);
2040-
pr_info("... bit width: %d\n", x86_pmu.cntval_bits);
2041-
pr_info("... generic registers: %d\n", x86_pmu.num_counters);
2042-
pr_info("... value mask: %016Lx\n", x86_pmu.cntval_mask);
2043-
pr_info("... max period: %016Lx\n", x86_pmu.max_period);
2044-
pr_info("... fixed-purpose events: %lu\n",
2045-
hweight64((((1ULL << x86_pmu.num_counters_fixed) - 1)
2046-
<< INTEL_PMC_IDX_FIXED) & x86_pmu.intel_ctrl));
2047-
pr_info("... event mask: %016Lx\n", x86_pmu.intel_ctrl);
2053+
x86_pmu_show_pmu_cap(x86_pmu.num_counters, x86_pmu.num_counters_fixed,
2054+
x86_pmu.intel_ctrl);
20482055

20492056
if (!x86_pmu.read)
20502057
x86_pmu.read = _x86_pmu_read;

arch/x86/events/perf_event.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,6 +1092,9 @@ void x86_pmu_enable_event(struct perf_event *event);
10921092

10931093
int x86_pmu_handle_irq(struct pt_regs *regs);
10941094

1095+
void x86_pmu_show_pmu_cap(int num_counters, int num_counters_fixed,
1096+
u64 intel_ctrl);
1097+
10951098
extern struct event_constraint emptyconstraint;
10961099

10971100
extern struct event_constraint unconstrained;

0 commit comments

Comments
 (0)