All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf/x86/intel/uncore: Add Node ID mask
@ 2019-01-27 14:53 kan.liang
  2019-01-29  7:10 ` Song Liu
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: kan.liang @ 2019-01-27 14:53 UTC (permalink / raw)
  To: tglx, peterz, mingo, linux-kernel; +Cc: ak, songliubraving, Kan Liang, stable

From: Kan Liang <kan.liang@linux.intel.com>

Some PCI uncore PMUs cannot be registered on a 8-socket system (HPE
Superdome Flex).

To understand which Socket the PCI uncore PMUs belong to, perf retrieves
the local Node ID of the uncore device from CPUNODEID(0xC0) of the PCI
configuration space, and the mapping between Socket ID and Node ID from
GIDNIDMAP(0xD4). The Socket ID can be calculated accordingly.
The local Node ID is only available at bit 2:0, but current code doesn't
mask it. If a BIOS doesn't clear the rest of the bits, a wrong Node ID
will be fetched.

Filter the Node ID by adding a mask.

Fixes: 7c94ee2e0917 ("perf/x86: Add Intel Nehalem and Sandy Bridge-EP uncore support")
Reported-by: Song Liu <songliubraving@fb.com>
Tested-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Cc: stable@vger.kernel.org
---
 arch/x86/events/intel/uncore_snbep.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c
index c07bee3..b10e043 100644
--- a/arch/x86/events/intel/uncore_snbep.c
+++ b/arch/x86/events/intel/uncore_snbep.c
@@ -1222,6 +1222,8 @@ static struct pci_driver snbep_uncore_pci_driver = {
 	.id_table	= snbep_uncore_pci_ids,
 };
 
+#define NODE_ID_MASK	0x7
+
 /*
  * build pci bus to socket mapping
  */
@@ -1243,7 +1245,7 @@ static int snbep_pci2phy_map_init(int devid, int nodeid_loc, int idmap_loc, bool
 		err = pci_read_config_dword(ubox_dev, nodeid_loc, &config);
 		if (err)
 			break;
-		nodeid = config;
+		nodeid = config & NODE_ID_MASK;
 		/* get the Node ID mapping */
 		err = pci_read_config_dword(ubox_dev, idmap_loc, &config);
 		if (err)
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] perf/x86/intel/uncore: Add Node ID mask
  2019-01-27 14:53 [PATCH] perf/x86/intel/uncore: Add Node ID mask kan.liang
@ 2019-01-29  7:10 ` Song Liu
       [not found] ` <20190129003519.ECAE32177E@mail.kernel.org>
  2019-02-04  8:48 ` [tip:perf/core] " tip-bot for Kan Liang
  2 siblings, 0 replies; 5+ messages in thread
From: Song Liu @ 2019-01-29  7:10 UTC (permalink / raw)
  To: kan.liang; +Cc: Thomas Gleixner, peterz, mingo, linux-kernel, ak, stable



> On Jan 27, 2019, at 6:53 AM, kan.liang@linux.intel.com wrote:
> 
> From: Kan Liang <kan.liang@linux.intel.com>
> 
> Some PCI uncore PMUs cannot be registered on a 8-socket system (HPE
> Superdome Flex).
> 
> To understand which Socket the PCI uncore PMUs belong to, perf retrieves
> the local Node ID of the uncore device from CPUNODEID(0xC0) of the PCI
> configuration space, and the mapping between Socket ID and Node ID from
> GIDNIDMAP(0xD4). The Socket ID can be calculated accordingly.
> The local Node ID is only available at bit 2:0, but current code doesn't
> mask it. If a BIOS doesn't clear the rest of the bits, a wrong Node ID
> will be fetched.
> 
> Filter the Node ID by adding a mask.
> 
> Fixes: 7c94ee2e0917 ("perf/x86: Add Intel Nehalem and Sandy Bridge-EP uncore support")
> Reported-by: Song Liu <songliubraving@fb.com>
> Tested-by: Song Liu <songliubraving@fb.com>
> Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
> Cc: stable@vger.kernel.org

Thanks Kan!

Acked-by: Song Liu <songliubraving@fb.com>


> ---
> arch/x86/events/intel/uncore_snbep.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c
> index c07bee3..b10e043 100644
> --- a/arch/x86/events/intel/uncore_snbep.c
> +++ b/arch/x86/events/intel/uncore_snbep.c
> @@ -1222,6 +1222,8 @@ static struct pci_driver snbep_uncore_pci_driver = {
> 	.id_table	= snbep_uncore_pci_ids,
> };
> 
> +#define NODE_ID_MASK	0x7
> +
> /*
>  * build pci bus to socket mapping
>  */
> @@ -1243,7 +1245,7 @@ static int snbep_pci2phy_map_init(int devid, int nodeid_loc, int idmap_loc, bool
> 		err = pci_read_config_dword(ubox_dev, nodeid_loc, &config);
> 		if (err)
> 			break;
> -		nodeid = config;
> +		nodeid = config & NODE_ID_MASK;
> 		/* get the Node ID mapping */
> 		err = pci_read_config_dword(ubox_dev, idmap_loc, &config);
> 		if (err)
> -- 
> 2.7.4
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] perf/x86/intel/uncore: Add Node ID mask
       [not found] ` <20190129003519.ECAE32177E@mail.kernel.org>
@ 2019-01-29 16:40   ` Liang, Kan
  2019-01-31 17:24     ` Song Liu
  0 siblings, 1 reply; 5+ messages in thread
From: Liang, Kan @ 2019-01-29 16:40 UTC (permalink / raw)
  To: Sasha Levin, tglx, peterz, mingo; +Cc: ak, songliubraving, stable



On 1/28/2019 7:35 PM, Sasha Levin wrote:
> Hi,
> 
> [This is an automated email]
> 
> This commit has been processed because it contains a "Fixes:" tag,
> fixing commit: 7c94ee2e0917 perf/x86: Add Intel Nehalem and Sandy Bridge-EP uncore support.
> 
> The bot has tested the following trees: v4.20.5, v4.19.18, v4.14.96, v4.9.153, v4.4.172, v3.18.133.
> 
> v4.20.5: Build OK!
> v4.19.18: Build OK!
> v4.14.96: Build OK!
> v4.9.153: Build OK!
> v4.4.172: Failed to apply! Possible dependencies:
>      Unable to calculate
> 
> v3.18.133: Failed to apply! Possible dependencies:
>      Unable to calculate
> 
> 
> How should we proceed with this patch?
>

Here is the backport patch for 4.4 and 3.18.

 From 21eb165d645a48fb31efed75902f892986449bb0 Mon Sep 17 00:00:00 2001
From: Kan Liang <kan.liang@linux.intel.com>
Date: Tue, 29 Jan 2019 08:35:03 -0800
Subject: [PATCH] perf/x86/intel/uncore: Add Node ID mask

Some PCI uncore PMUs cannot be registered on a 8-socket system (HPE
Superdome Flex).

To understand which Socket the PCI uncore PMUs belong to, perf retrieves
the local Node ID of the uncore device from CPUNODEID(0xC0) of the PCI
configuration space, and the mapping between Socket ID and Node ID from
GIDNIDMAP(0xD4). The Socket ID can be calculated accordingly.
The local Node ID is only available at bit 2:0, but current code doesn't
mask it. If a BIOS doesn't clear the rest of the bits, a wrong Node ID
will be fetched.

Filter the Node ID by adding a mask.

Fixes: 7c94ee2e0917 ("perf/x86: Add Intel Nehalem and Sandy Bridge-EP 
uncore support")
Reported-by: Song Liu <songliubraving@fb.com>
Tested-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Acked-by: Song Liu <songliubraving@fb.com>
Cc: stable@vger.kernel.org
---
  arch/x86/kernel/cpu/perf_event_intel_uncore_snbep.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore_snbep.c 
b/arch/x86/kernel/cpu/perf_event_intel_uncore_snbep.c
index f0f4fcb..9475794 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_uncore_snbep.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_uncore_snbep.c
@@ -1081,6 +1081,8 @@ static struct pci_driver snbep_uncore_pci_driver = {
  	.id_table	= snbep_uncore_pci_ids,
  };

+#define NODE_ID_MASK	0x7
+
  /*
   * build pci bus to socket mapping
   */
@@ -1102,7 +1104,7 @@ static int snbep_pci2phy_map_init(int devid)
  		err = pci_read_config_dword(ubox_dev, 0x40, &config);
  		if (err)
  			break;
-		nodeid = config;
+		nodeid = config & NODE_ID_MASK;
  		/* get the Node ID mapping */
  		err = pci_read_config_dword(ubox_dev, 0x54, &config);
  		if (err)
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] perf/x86/intel/uncore: Add Node ID mask
  2019-01-29 16:40   ` Liang, Kan
@ 2019-01-31 17:24     ` Song Liu
  0 siblings, 0 replies; 5+ messages in thread
From: Song Liu @ 2019-01-31 17:24 UTC (permalink / raw)
  To: Liang, Kan
  Cc: Sasha Levin, Thomas Gleixner, Peter Zijlstra, Ingo Molnar,
	Andi Kleen, stable


> On Jan 29, 2019, at 8:40 AM, Liang, Kan <kan.liang@linux.intel.com> wrote:
> 
> 
> 
> On 1/28/2019 7:35 PM, Sasha Levin wrote:
>> Hi,
>> [This is an automated email]
>> This commit has been processed because it contains a "Fixes:" tag,
>> fixing commit: 7c94ee2e0917 perf/x86: Add Intel Nehalem and Sandy Bridge-EP uncore support.
>> The bot has tested the following trees: v4.20.5, v4.19.18, v4.14.96, v4.9.153, v4.4.172, v3.18.133.
>> v4.20.5: Build OK!
>> v4.19.18: Build OK!
>> v4.14.96: Build OK!
>> v4.9.153: Build OK!
>> v4.4.172: Failed to apply! Possible dependencies:
>>     Unable to calculate
>> v3.18.133: Failed to apply! Possible dependencies:
>>     Unable to calculate
>> How should we proceed with this patch?
>> 
> 
> Here is the backport patch for 4.4 and 3.18.
> 
> From 21eb165d645a48fb31efed75902f892986449bb0 Mon Sep 17 00:00:00 2001
> From: Kan Liang <kan.liang@linux.intel.com>
> Date: Tue, 29 Jan 2019 08:35:03 -0800
> Subject: [PATCH] perf/x86/intel/uncore: Add Node ID mask
> 
> Some PCI uncore PMUs cannot be registered on a 8-socket system (HPE
> Superdome Flex).
> 
> To understand which Socket the PCI uncore PMUs belong to, perf retrieves
> the local Node ID of the uncore device from CPUNODEID(0xC0) of the PCI
> configuration space, and the mapping between Socket ID and Node ID from
> GIDNIDMAP(0xD4). The Socket ID can be calculated accordingly.
> The local Node ID is only available at bit 2:0, but current code doesn't
> mask it. If a BIOS doesn't clear the rest of the bits, a wrong Node ID
> will be fetched.
> 
> Filter the Node ID by adding a mask.
> 
> Fixes: 7c94ee2e0917 ("perf/x86: Add Intel Nehalem and Sandy Bridge-EP uncore support")
> Reported-by: Song Liu <songliubraving@fb.com>
> Tested-by: Song Liu <songliubraving@fb.com>
> Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
> Acked-by: Song Liu <songliubraving@fb.com>
> Cc: stable@vger.kernel.org
> ---
> arch/x86/kernel/cpu/perf_event_intel_uncore_snbep.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore_snbep.c b/arch/x86/kernel/cpu/perf_event_intel_uncore_snbep.c
> index f0f4fcb..9475794 100644
> --- a/arch/x86/kernel/cpu/perf_event_intel_uncore_snbep.c
> +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore_snbep.c
> @@ -1081,6 +1081,8 @@ static struct pci_driver snbep_uncore_pci_driver = {
> 	.id_table	= snbep_uncore_pci_ids,
> };
> 
> +#define NODE_ID_MASK	0x7
> +
> /*
>  * build pci bus to socket mapping
>  */
> @@ -1102,7 +1104,7 @@ static int snbep_pci2phy_map_init(int devid)
> 		err = pci_read_config_dword(ubox_dev, 0x40, &config);
> 		if (err)
> 			break;
> -		nodeid = config;
> +		nodeid = config & NODE_ID_MASK;
> 		/* get the Node ID mapping */
> 		err = pci_read_config_dword(ubox_dev, 0x54, &config);
> 		if (err)
> -- 
> 2.7.4

Is this patch applied to the tip tree? I would like to back port the
official commit to our internal tree. 

Thanks,
Song







^ permalink raw reply	[flat|nested] 5+ messages in thread

* [tip:perf/core] perf/x86/intel/uncore: Add Node ID mask
  2019-01-27 14:53 [PATCH] perf/x86/intel/uncore: Add Node ID mask kan.liang
  2019-01-29  7:10 ` Song Liu
       [not found] ` <20190129003519.ECAE32177E@mail.kernel.org>
@ 2019-02-04  8:48 ` tip-bot for Kan Liang
  2 siblings, 0 replies; 5+ messages in thread
From: tip-bot for Kan Liang @ 2019-02-04  8:48 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: peterz, torvalds, alexander.shishkin, mingo, jolsa,
	songliubraving, hpa, acme, tglx, kan.liang, linux-kernel

Commit-ID:  9e63a7894fd302082cf3627fe90844421a6cbe7f
Gitweb:     https://git.kernel.org/tip/9e63a7894fd302082cf3627fe90844421a6cbe7f
Author:     Kan Liang <kan.liang@linux.intel.com>
AuthorDate: Sun, 27 Jan 2019 06:53:14 -0800
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Mon, 4 Feb 2019 08:44:43 +0100

perf/x86/intel/uncore: Add Node ID mask

Some PCI uncore PMUs cannot be registered on an 8-socket system (HPE
Superdome Flex).

To understand which Socket the PCI uncore PMUs belongs to, perf retrieves
the local Node ID of the uncore device from CPUNODEID(0xC0) of the PCI
configuration space, and the mapping between Socket ID and Node ID from
GIDNIDMAP(0xD4). The Socket ID can be calculated accordingly.

The local Node ID is only available at bit 2:0, but current code doesn't
mask it. If a BIOS doesn't clear the rest of the bits, an incorrect Node ID
will be fetched.

Filter the Node ID by adding a mask.

Reported-by: Song Liu <songliubraving@fb.com>
Tested-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: <stable@vger.kernel.org> # v3.7+
Fixes: 7c94ee2e0917 ("perf/x86: Add Intel Nehalem and Sandy Bridge-EP uncore support")
Link: https://lkml.kernel.org/r/1548600794-33162-1-git-send-email-kan.liang@linux.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/events/intel/uncore_snbep.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c
index c07bee31abe8..b10e04387f38 100644
--- a/arch/x86/events/intel/uncore_snbep.c
+++ b/arch/x86/events/intel/uncore_snbep.c
@@ -1222,6 +1222,8 @@ static struct pci_driver snbep_uncore_pci_driver = {
 	.id_table	= snbep_uncore_pci_ids,
 };
 
+#define NODE_ID_MASK	0x7
+
 /*
  * build pci bus to socket mapping
  */
@@ -1243,7 +1245,7 @@ static int snbep_pci2phy_map_init(int devid, int nodeid_loc, int idmap_loc, bool
 		err = pci_read_config_dword(ubox_dev, nodeid_loc, &config);
 		if (err)
 			break;
-		nodeid = config;
+		nodeid = config & NODE_ID_MASK;
 		/* get the Node ID mapping */
 		err = pci_read_config_dword(ubox_dev, idmap_loc, &config);
 		if (err)

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-02-04  8:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-27 14:53 [PATCH] perf/x86/intel/uncore: Add Node ID mask kan.liang
2019-01-29  7:10 ` Song Liu
     [not found] ` <20190129003519.ECAE32177E@mail.kernel.org>
2019-01-29 16:40   ` Liang, Kan
2019-01-31 17:24     ` Song Liu
2019-02-04  8:48 ` [tip:perf/core] " tip-bot for Kan Liang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.