Skip to content

Commit 4a0e3ff

Browse files
Kan LiangPeter Zijlstra
authored andcommitted
perf/x86/intel/uncore: Fix a kernel WARNING triggered by maxcpus=1
A kernel WARNING may be triggered when setting maxcpus=1. The uncore counters are Die-scope. When probing a PCI device, only the BUS information can be retrieved. The uncore driver has to maintain a mapping table used to calculate the logical Die ID from a given BUS#. Before the patch ba9506b, the mapping table stores the mapping information from the BUS# -> a Physical Socket ID. To calculate the logical die ID, perf does, - In snbep_pci2phy_map_init(), retrieve the BUS# -> a Physical Socket ID from the UBOX PCI configure space. - Calculate the mapping information (a BUS# -> a Physical Socket ID) for the other PCI BUS. - In the uncore_pci_probe(), get the physical Socket ID from a given BUS and the mapping table. - Calculate the logical Die ID Since only the logical Die ID is required, with the patch ba9506b, the mapping table stores the mapping information from the BUS# -> a logical Die ID. Now perf does, - In snbep_pci2phy_map_init(), retrieve the BUS# -> a Physical Socket ID from the UBOX PCI configure space. - Calculate the logical Die ID - Calculate the mapping information (a BUS# -> a logical Die ID) for the other PCI BUS. - In the uncore_pci_probe(), get the logical die ID from a given BUS and the mapping table. When calculating the logical Die ID, -1 may be returned, especially when maxcpus=1. Here, -1 means the logical Die ID is not found. But when calculating the mapping information for the other PCI BUS, -1 indicates that it's the other PCI BUS that requires the calculation of the mapping. The driver will mistakenly do the calculation. Uses the -ENODEV to indicate the case which the logical Die ID is not found. The driver will not mess up the mapping table anymore. Fixes: ba9506b ("perf/x86/intel/uncore: Store the logical die id instead of the physical die id.") Reported-by: John Donnelly <[email protected]> Signed-off-by: Kan Liang <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Acked-by: John Donnelly <[email protected]> Tested-by: John Donnelly <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 6c605f8 commit 4a0e3ff

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

arch/x86/events/intel/uncore_snbep.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,6 +1406,8 @@ static int snbep_pci2phy_map_init(int devid, int nodeid_loc, int idmap_loc, bool
14061406
die_id = i;
14071407
else
14081408
die_id = topology_phys_to_logical_pkg(i);
1409+
if (die_id < 0)
1410+
die_id = -ENODEV;
14091411
map->pbus_to_dieid[bus] = die_id;
14101412
break;
14111413
}
@@ -1452,14 +1454,14 @@ static int snbep_pci2phy_map_init(int devid, int nodeid_loc, int idmap_loc, bool
14521454
i = -1;
14531455
if (reverse) {
14541456
for (bus = 255; bus >= 0; bus--) {
1455-
if (map->pbus_to_dieid[bus] >= 0)
1457+
if (map->pbus_to_dieid[bus] != -1)
14561458
i = map->pbus_to_dieid[bus];
14571459
else
14581460
map->pbus_to_dieid[bus] = i;
14591461
}
14601462
} else {
14611463
for (bus = 0; bus <= 255; bus++) {
1462-
if (map->pbus_to_dieid[bus] >= 0)
1464+
if (map->pbus_to_dieid[bus] != -1)
14631465
i = map->pbus_to_dieid[bus];
14641466
else
14651467
map->pbus_to_dieid[bus] = i;

0 commit comments

Comments
 (0)