Skip to content

Commit cb63ba0

Browse files
Kan LiangKAGA-KOKO
authored andcommitted
perf/x86/intel/cstate: Support multi-die/package
Some cstate counters become die-scoped on Xeon Cascade Lake-AP. Perf cstate driver needs to support die-scope cstate counters. Use topology_die_cpumask() to replace topology_core_cpumask(). For previous platforms which doesn't have multi-die, topology_die_cpumask() is identical as topology_core_cpumask(). There is no functional change for previous platforms. Name the die-scope PMU "cstate_die". Signed-off-by: Kan Liang <[email protected]> Signed-off-by: Len Brown <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Ingo Molnar <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lkml.kernel.org/r/acb5e483287280eeb2b6daabe04a600b85e72a78.1557769318.git.len.brown@intel.com
1 parent b10b3ef commit cb63ba0

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

arch/x86/events/intel/cstate.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ static int cstate_pmu_event_init(struct perf_event *event)
302302
return -EINVAL;
303303
event->hw.event_base = pkg_msr[cfg].msr;
304304
cpu = cpumask_any_and(&cstate_pkg_cpu_mask,
305-
topology_core_cpumask(event->cpu));
305+
topology_die_cpumask(event->cpu));
306306
} else {
307307
return -ENOENT;
308308
}
@@ -385,7 +385,7 @@ static int cstate_cpu_exit(unsigned int cpu)
385385
if (has_cstate_pkg &&
386386
cpumask_test_and_clear_cpu(cpu, &cstate_pkg_cpu_mask)) {
387387

388-
target = cpumask_any_but(topology_core_cpumask(cpu), cpu);
388+
target = cpumask_any_but(topology_die_cpumask(cpu), cpu);
389389
/* Migrate events if there is a valid target */
390390
if (target < nr_cpu_ids) {
391391
cpumask_set_cpu(target, &cstate_pkg_cpu_mask);
@@ -414,7 +414,7 @@ static int cstate_cpu_init(unsigned int cpu)
414414
* in the package cpu mask as the designated reader.
415415
*/
416416
target = cpumask_any_and(&cstate_pkg_cpu_mask,
417-
topology_core_cpumask(cpu));
417+
topology_die_cpumask(cpu));
418418
if (has_cstate_pkg && target >= nr_cpu_ids)
419419
cpumask_set_cpu(cpu, &cstate_pkg_cpu_mask);
420420

@@ -663,7 +663,13 @@ static int __init cstate_init(void)
663663
}
664664

665665
if (has_cstate_pkg) {
666-
err = perf_pmu_register(&cstate_pkg_pmu, cstate_pkg_pmu.name, -1);
666+
if (topology_max_die_per_package() > 1) {
667+
err = perf_pmu_register(&cstate_pkg_pmu,
668+
"cstate_die", -1);
669+
} else {
670+
err = perf_pmu_register(&cstate_pkg_pmu,
671+
cstate_pkg_pmu.name, -1);
672+
}
667673
if (err) {
668674
has_cstate_pkg = false;
669675
pr_info("Failed to register cstate pkg pmu\n");

0 commit comments

Comments
 (0)