Skip to content

Commit 1ff4a47

Browse files
Kan LiangKAGA-KOKO
authored andcommitted
perf/x86/intel/uncore: Support multi-die/package
Uncore becomes die-scope on Xeon Cascade Lake-AP. Uncore driver needs to support die-scope uncore units. Use topology_logical_die_id() to replace topology_logical_package_id(). For previous platforms which doesn't have multi-die, topology_logical_die_id() is identical as topology_logical_package_id(). In pci_probe()/remove(), the group id reads from PCI BUS is logical die id for multi-die systems. 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. 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/a25bba4a5b480aa4e9f8190005d7f5f53e29c8da.1557769318.git.len.brown@intel.com
1 parent 2e4c54d commit 1ff4a47

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

arch/x86/events/intel/uncore.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ ssize_t uncore_event_show(struct kobject *kobj,
100100

101101
struct intel_uncore_box *uncore_pmu_to_box(struct intel_uncore_pmu *pmu, int cpu)
102102
{
103-
unsigned int pkgid = topology_logical_package_id(cpu);
103+
unsigned int pkgid = topology_logical_die_id(cpu);
104104

105105
/*
106106
* The unsigned check also catches the '-1' return value for non
@@ -942,7 +942,8 @@ static int uncore_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id
942942
if (phys_id < 0)
943943
return -ENODEV;
944944

945-
pkg = topology_phys_to_logical_pkg(phys_id);
945+
pkg = (topology_max_die_per_package() > 1) ? phys_id :
946+
topology_phys_to_logical_pkg(phys_id);
946947
if (pkg < 0)
947948
return -EINVAL;
948949

@@ -1033,7 +1034,8 @@ static void uncore_pci_remove(struct pci_dev *pdev)
10331034

10341035
box = pci_get_drvdata(pdev);
10351036
if (!box) {
1036-
pkg = topology_phys_to_logical_pkg(phys_id);
1037+
pkg = (topology_max_die_per_package() > 1) ? phys_id :
1038+
topology_phys_to_logical_pkg(phys_id);
10371039
for (i = 0; i < UNCORE_EXTRA_PCI_DEV_MAX; i++) {
10381040
if (uncore_extra_pci_dev[pkg].dev[i] == pdev) {
10391041
uncore_extra_pci_dev[pkg].dev[i] = NULL;
@@ -1110,7 +1112,7 @@ static void uncore_change_type_ctx(struct intel_uncore_type *type, int old_cpu,
11101112
struct intel_uncore_box *box;
11111113
int i, pkg;
11121114

1113-
pkg = topology_logical_package_id(old_cpu < 0 ? new_cpu : old_cpu);
1115+
pkg = topology_logical_die_id(old_cpu < 0 ? new_cpu : old_cpu);
11141116
for (i = 0; i < type->num_boxes; i++, pmu++) {
11151117
box = pmu->boxes[pkg];
11161118
if (!box)
@@ -1151,7 +1153,7 @@ static int uncore_event_cpu_offline(unsigned int cpu)
11511153
if (!cpumask_test_and_clear_cpu(cpu, &uncore_cpu_mask))
11521154
goto unref;
11531155
/* Find a new cpu to collect uncore events */
1154-
target = cpumask_any_but(topology_core_cpumask(cpu), cpu);
1156+
target = cpumask_any_but(topology_die_cpumask(cpu), cpu);
11551157

11561158
/* Migrate uncore events to the new target */
11571159
if (target < nr_cpu_ids)
@@ -1164,7 +1166,7 @@ static int uncore_event_cpu_offline(unsigned int cpu)
11641166

11651167
unref:
11661168
/* Clear the references */
1167-
pkg = topology_logical_package_id(cpu);
1169+
pkg = topology_logical_die_id(cpu);
11681170
for (; *types; types++) {
11691171
type = *types;
11701172
pmu = type->pmus;
@@ -1223,7 +1225,7 @@ static int uncore_event_cpu_online(unsigned int cpu)
12231225
struct intel_uncore_box *box;
12241226
int i, ret, pkg, target;
12251227

1226-
pkg = topology_logical_package_id(cpu);
1228+
pkg = topology_logical_die_id(cpu);
12271229
ret = allocate_boxes(types, pkg, cpu);
12281230
if (ret)
12291231
return ret;
@@ -1242,7 +1244,7 @@ static int uncore_event_cpu_online(unsigned int cpu)
12421244
* Check if there is an online cpu in the package
12431245
* which collects uncore events already.
12441246
*/
1245-
target = cpumask_any_and(&uncore_cpu_mask, topology_core_cpumask(cpu));
1247+
target = cpumask_any_and(&uncore_cpu_mask, topology_die_cpumask(cpu));
12461248
if (target < nr_cpu_ids)
12471249
return 0;
12481250

@@ -1417,7 +1419,7 @@ static int __init intel_uncore_init(void)
14171419
if (boot_cpu_has(X86_FEATURE_HYPERVISOR))
14181420
return -ENODEV;
14191421

1420-
max_packages = topology_max_packages();
1422+
max_packages = topology_max_packages() * topology_max_die_per_package();
14211423

14221424
uncore_init = (struct intel_uncore_init_fun *)id->driver_data;
14231425
if (uncore_init->pci_init) {

0 commit comments

Comments
 (0)