* [PATCH] perf/x86/intel/uncore: Fix a kernel WARNING triggered by maxcpus=1
@ 2021-05-26 13:58 kan.liang
2021-05-27 11:14 ` Peter Zijlstra
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: kan.liang @ 2021-05-26 13:58 UTC (permalink / raw)
To: peterz, mingo, linux-kernel
Cc: steve.wahl, john.p.donnelly, brian.maly, jack.vogel, ak, Kan Liang
From: Kan Liang <kan.liang@linux.intel.com>
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 ba9506be4e40, 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 ba9506be4e40,
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: ba9506be4e40 ("perf/x86/intel/uncore: Store the logical die id
instead of the physical die id.")
Reported-by: John Donnelly <john.p.donnelly@oracle.com>
Tested-by: John Donnelly <john.p.donnelly@oracle.com>
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
---
arch/x86/events/intel/uncore_snbep.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c
index f57d9cb..035787c 100644
--- a/arch/x86/events/intel/uncore_snbep.c
+++ b/arch/x86/events/intel/uncore_snbep.c
@@ -1413,6 +1413,8 @@ static int snbep_pci2phy_map_init(int devid, int nodeid_loc, int idmap_loc, bool
die_id = i;
else
die_id = topology_phys_to_logical_pkg(i);
+ if (die_id < 0)
+ die_id = -ENODEV;
map->pbus_to_dieid[bus] = die_id;
break;
}
@@ -1459,14 +1461,14 @@ static int snbep_pci2phy_map_init(int devid, int nodeid_loc, int idmap_loc, bool
i = -1;
if (reverse) {
for (bus = 255; bus >= 0; bus--) {
- if (map->pbus_to_dieid[bus] >= 0)
+ if (map->pbus_to_dieid[bus] != -1)
i = map->pbus_to_dieid[bus];
else
map->pbus_to_dieid[bus] = i;
}
} else {
for (bus = 0; bus <= 255; bus++) {
- if (map->pbus_to_dieid[bus] >= 0)
+ if (map->pbus_to_dieid[bus] != -1)
i = map->pbus_to_dieid[bus];
else
map->pbus_to_dieid[bus] = i;
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] perf/x86/intel/uncore: Fix a kernel WARNING triggered by maxcpus=1
2021-05-26 13:58 [PATCH] perf/x86/intel/uncore: Fix a kernel WARNING triggered by maxcpus=1 kan.liang
@ 2021-05-27 11:14 ` Peter Zijlstra
2021-05-27 20:13 ` John Donnelly
2021-05-31 10:40 ` [tip: perf/urgent] " tip-bot2 for Kan Liang
2 siblings, 0 replies; 4+ messages in thread
From: Peter Zijlstra @ 2021-05-27 11:14 UTC (permalink / raw)
To: kan.liang
Cc: mingo, linux-kernel, steve.wahl, john.p.donnelly, brian.maly,
jack.vogel, ak
On Wed, May 26, 2021 at 06:58:47AM -0700, kan.liang@linux.intel.com wrote:
> From: Kan Liang <kan.liang@linux.intel.com>
>
> 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 ba9506be4e40, 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 ba9506be4e40,
> 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: ba9506be4e40 ("perf/x86/intel/uncore: Store the logical die id
> instead of the physical die id.")
(please don't wrap like that)
> Reported-by: John Donnelly <john.p.donnelly@oracle.com>
> Tested-by: John Donnelly <john.p.donnelly@oracle.com>
> Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] perf/x86/intel/uncore: Fix a kernel WARNING triggered by maxcpus=1
2021-05-26 13:58 [PATCH] perf/x86/intel/uncore: Fix a kernel WARNING triggered by maxcpus=1 kan.liang
2021-05-27 11:14 ` Peter Zijlstra
@ 2021-05-27 20:13 ` John Donnelly
2021-05-31 10:40 ` [tip: perf/urgent] " tip-bot2 for Kan Liang
2 siblings, 0 replies; 4+ messages in thread
From: John Donnelly @ 2021-05-27 20:13 UTC (permalink / raw)
To: kan.liang, peterz, mingo, linux-kernel; +Cc: steve.wahl, ak
On 5/26/21 8:58 AM, kan.liang@linux.intel.com wrote:
> From: Kan Liang <kan.liang@linux.intel.com>
>
> 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 ba9506be4e40, 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 ba9506be4e40,
> 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: ba9506be4e40 ("perf/x86/intel/uncore: Store the logical die id
> instead of the physical die id.")
> Reported-by: John Donnelly <john.p.donnelly@oracle.com>
> Tested-by: John Donnelly <john.p.donnelly@oracle.com>
> Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Acked-by: John Donnelly <john.p.donnelly@oracle.com>
> ---
> arch/x86/events/intel/uncore_snbep.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c
> index f57d9cb..035787c 100644
> --- a/arch/x86/events/intel/uncore_snbep.c
> +++ b/arch/x86/events/intel/uncore_snbep.c
> @@ -1413,6 +1413,8 @@ static int snbep_pci2phy_map_init(int devid, int nodeid_loc, int idmap_loc, bool
> die_id = i;
> else
> die_id = topology_phys_to_logical_pkg(i);
> + if (die_id < 0)
> + die_id = -ENODEV;
> map->pbus_to_dieid[bus] = die_id;
> break;
> }
> @@ -1459,14 +1461,14 @@ static int snbep_pci2phy_map_init(int devid, int nodeid_loc, int idmap_loc, bool
> i = -1;
> if (reverse) {
> for (bus = 255; bus >= 0; bus--) {
> - if (map->pbus_to_dieid[bus] >= 0)
> + if (map->pbus_to_dieid[bus] != -1)
> i = map->pbus_to_dieid[bus];
> else
> map->pbus_to_dieid[bus] = i;
> }
> } else {
> for (bus = 0; bus <= 255; bus++) {
> - if (map->pbus_to_dieid[bus] >= 0)
> + if (map->pbus_to_dieid[bus] != -1)
> i = map->pbus_to_dieid[bus];
> else
> map->pbus_to_dieid[bus] = i;
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [tip: perf/urgent] perf/x86/intel/uncore: Fix a kernel WARNING triggered by maxcpus=1
2021-05-26 13:58 [PATCH] perf/x86/intel/uncore: Fix a kernel WARNING triggered by maxcpus=1 kan.liang
2021-05-27 11:14 ` Peter Zijlstra
2021-05-27 20:13 ` John Donnelly
@ 2021-05-31 10:40 ` tip-bot2 for Kan Liang
2 siblings, 0 replies; 4+ messages in thread
From: tip-bot2 for Kan Liang @ 2021-05-31 10:40 UTC (permalink / raw)
To: linux-tip-commits
Cc: John Donnelly, Kan Liang, Peter Zijlstra (Intel), x86, linux-kernel
The following commit has been merged into the perf/urgent branch of tip:
Commit-ID: 4a0e3ff30980b7601b13dd3b7ee275212b852843
Gitweb: https://git.kernel.org/tip/4a0e3ff30980b7601b13dd3b7ee275212b852843
Author: Kan Liang <kan.liang@linux.intel.com>
AuthorDate: Wed, 26 May 2021 06:58:47 -07:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Mon, 31 May 2021 10:14:51 +02:00
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 ba9506be4e40, 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 ba9506be4e40,
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: ba9506be4e40 ("perf/x86/intel/uncore: Store the logical die id instead of the physical die id.")
Reported-by: John Donnelly <john.p.donnelly@oracle.com>
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: John Donnelly <john.p.donnelly@oracle.com>
Tested-by: John Donnelly <john.p.donnelly@oracle.com>
Link: https://lkml.kernel.org/r/1622037527-156028-1-git-send-email-kan.liang@linux.intel.com
---
arch/x86/events/intel/uncore_snbep.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c
index 63f0972..1587d32 100644
--- a/arch/x86/events/intel/uncore_snbep.c
+++ b/arch/x86/events/intel/uncore_snbep.c
@@ -1406,6 +1406,8 @@ static int snbep_pci2phy_map_init(int devid, int nodeid_loc, int idmap_loc, bool
die_id = i;
else
die_id = topology_phys_to_logical_pkg(i);
+ if (die_id < 0)
+ die_id = -ENODEV;
map->pbus_to_dieid[bus] = die_id;
break;
}
@@ -1452,14 +1454,14 @@ static int snbep_pci2phy_map_init(int devid, int nodeid_loc, int idmap_loc, bool
i = -1;
if (reverse) {
for (bus = 255; bus >= 0; bus--) {
- if (map->pbus_to_dieid[bus] >= 0)
+ if (map->pbus_to_dieid[bus] != -1)
i = map->pbus_to_dieid[bus];
else
map->pbus_to_dieid[bus] = i;
}
} else {
for (bus = 0; bus <= 255; bus++) {
- if (map->pbus_to_dieid[bus] >= 0)
+ if (map->pbus_to_dieid[bus] != -1)
i = map->pbus_to_dieid[bus];
else
map->pbus_to_dieid[bus] = i;
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-05-31 10:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-26 13:58 [PATCH] perf/x86/intel/uncore: Fix a kernel WARNING triggered by maxcpus=1 kan.liang
2021-05-27 11:14 ` Peter Zijlstra
2021-05-27 20:13 ` John Donnelly
2021-05-31 10:40 ` [tip: perf/urgent] " tip-bot2 for Kan Liang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).