LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH v3 0/2] x86/CPU/AMD: Add support for Extended Topology Enumeration
@ 2018-04-27 21:47 Suravee Suthikulpanit
2018-04-27 21:48 ` [PATCH v3 1/2] x86/CPU: Modify detect_extended_topology() to return result Suravee Suthikulpanit
2018-04-27 21:48 ` [PATCH v3 2/2] x86/CPU/AMD: Derive CPU topology from CPUID Fn0xB when available Suravee Suthikulpanit
0 siblings, 2 replies; 5+ messages in thread
From: Suravee Suthikulpanit @ 2018-04-27 21:47 UTC (permalink / raw)
To: linux-kernel, x86; +Cc: tglx, mingo, hpa, bp, rientjes, Suravee Suthikulpanit
Linux currently provides function detect_extended_topology()
for parsing CPUID Fn0xB and derive CPU topology information.
Therefore, also call this function in AMD code path.
Please note that this series depend on the previously submitted
series:
[PATCH v2 0/4] x86/CPU: Update AMD Last-Level-Cache Information
(https://lkml.org/lkml/2018/4/27/1112)
Thanks,
Suravee
Changes from v2 (https://lkml.org/lkml/2018/4/4/55)
* 2/2: Fix typo in comment.
Suravee Suthikulpanit (2):
x86/CPU: Modify detect_extended_topology() to return result
x86/CPU/AMD: Derive CPU topology from CPUID Fn0xB when available
arch/x86/include/asm/processor.h | 2 +-
arch/x86/kernel/cpu/amd.c | 11 ++++++++++-
arch/x86/kernel/cpu/topology.c | 8 ++++----
3 files changed, 15 insertions(+), 6 deletions(-)
--
2.7.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v3 1/2] x86/CPU: Modify detect_extended_topology() to return result
2018-04-27 21:47 [PATCH v3 0/2] x86/CPU/AMD: Add support for Extended Topology Enumeration Suravee Suthikulpanit
@ 2018-04-27 21:48 ` Suravee Suthikulpanit
2018-05-12 21:11 ` [tip:x86/cpu] " tip-bot for Suravee Suthikulpanit
2018-04-27 21:48 ` [PATCH v3 2/2] x86/CPU/AMD: Derive CPU topology from CPUID Fn0xB when available Suravee Suthikulpanit
1 sibling, 1 reply; 5+ messages in thread
From: Suravee Suthikulpanit @ 2018-04-27 21:48 UTC (permalink / raw)
To: linux-kernel, x86; +Cc: tglx, mingo, hpa, bp, rientjes, Suravee Suthikulpanit
Current implementation does not communicate whether it can successfully
detect CPUID Fn0x0000000B information. Therefore, modify the function
to return success or error codes. This will be used by subsequent patches.
Reviewed-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
---
arch/x86/include/asm/processor.h | 2 +-
arch/x86/kernel/cpu/topology.c | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index b0ccd48..2a5d5ed 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -193,7 +193,7 @@ extern u32 get_scattered_cpuid_leaf(unsigned int level,
extern unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c);
extern void init_amd_cacheinfo(struct cpuinfo_x86 *c);
-extern void detect_extended_topology(struct cpuinfo_x86 *c);
+extern int detect_extended_topology(struct cpuinfo_x86 *c);
extern void detect_ht(struct cpuinfo_x86 *c);
#ifdef CONFIG_X86_32
diff --git a/arch/x86/kernel/cpu/topology.c b/arch/x86/kernel/cpu/topology.c
index b099024..81c0afb 100644
--- a/arch/x86/kernel/cpu/topology.c
+++ b/arch/x86/kernel/cpu/topology.c
@@ -27,7 +27,7 @@
* exists, use it for populating initial_apicid and cpu topology
* detection.
*/
-void detect_extended_topology(struct cpuinfo_x86 *c)
+int detect_extended_topology(struct cpuinfo_x86 *c)
{
#ifdef CONFIG_SMP
unsigned int eax, ebx, ecx, edx, sub_index;
@@ -36,7 +36,7 @@ void detect_extended_topology(struct cpuinfo_x86 *c)
static bool printed;
if (c->cpuid_level < 0xb)
- return;
+ return -1;
cpuid_count(0xb, SMT_LEVEL, &eax, &ebx, &ecx, &edx);
@@ -44,7 +44,7 @@ void detect_extended_topology(struct cpuinfo_x86 *c)
* check if the cpuid leaf 0xb is actually implemented.
*/
if (ebx == 0 || (LEAFB_SUBTYPE(ecx) != SMT_TYPE))
- return;
+ return -1;
set_cpu_cap(c, X86_FEATURE_XTOPOLOGY);
@@ -95,6 +95,6 @@ void detect_extended_topology(struct cpuinfo_x86 *c)
c->cpu_core_id);
printed = 1;
}
- return;
#endif
+ return 0;
}
--
2.7.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v3 2/2] x86/CPU/AMD: Derive CPU topology from CPUID Fn0xB when available
2018-04-27 21:47 [PATCH v3 0/2] x86/CPU/AMD: Add support for Extended Topology Enumeration Suravee Suthikulpanit
2018-04-27 21:48 ` [PATCH v3 1/2] x86/CPU: Modify detect_extended_topology() to return result Suravee Suthikulpanit
@ 2018-04-27 21:48 ` Suravee Suthikulpanit
2018-05-12 21:12 ` [tip:x86/cpu] x86/CPU/AMD: Derive CPU topology from CPUID function 0xB " tip-bot for Suravee Suthikulpanit
1 sibling, 1 reply; 5+ messages in thread
From: Suravee Suthikulpanit @ 2018-04-27 21:48 UTC (permalink / raw)
To: linux-kernel, x86; +Cc: tglx, mingo, hpa, bp, rientjes, Suravee Suthikulpanit
Derive topology information from Extended Topology Enumeration
(CPUID Fn0x0000000B) when the information is available.
Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
---
arch/x86/kernel/cpu/amd.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index 2c1a9f2..a3e099d 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -327,6 +327,7 @@ static void amd_get_topology(struct cpuinfo_x86 *c)
/* get information required for multi-node processors */
if (boot_cpu_has(X86_FEATURE_TOPOEXT)) {
+ int err;
u32 eax, ebx, ecx, edx;
cpuid(0x8000001e, &eax, &ebx, &ecx, &edx);
@@ -344,6 +345,14 @@ static void amd_get_topology(struct cpuinfo_x86 *c)
c->x86_max_cores /= smp_num_siblings;
}
+ /*
+ * In case leaf B is available, use leaf B to derive
+ * topology information instead.
+ */
+ err = detect_extended_topology(c);
+ if (!err)
+ c->x86_coreid_bits = get_count_order(c->x86_max_cores);
+
cacheinfo_amd_init_llc_id(c, cpu, node_id);
} else if (cpu_has(c, X86_FEATURE_NODEID_MSR)) {
@@ -378,7 +387,6 @@ static void amd_detect_cmp(struct cpuinfo_x86 *c)
c->phys_proc_id = c->initial_apicid >> bits;
/* use socket ID also for last level cache */
per_cpu(cpu_llc_id, cpu) = c->phys_proc_id;
- amd_get_topology(c);
}
u16 amd_get_nb_id(int cpu)
@@ -823,6 +831,7 @@ static void init_amd(struct cpuinfo_x86 *c)
/* Multi core CPU? */
if (c->extended_cpuid_level >= 0x80000008) {
amd_detect_cmp(c);
+ amd_get_topology(c);
srat_detect_node(c);
}
--
2.7.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* [tip:x86/cpu] x86/CPU: Modify detect_extended_topology() to return result
2018-04-27 21:48 ` [PATCH v3 1/2] x86/CPU: Modify detect_extended_topology() to return result Suravee Suthikulpanit
@ 2018-05-12 21:11 ` tip-bot for Suravee Suthikulpanit
0 siblings, 0 replies; 5+ messages in thread
From: tip-bot for Suravee Suthikulpanit @ 2018-05-12 21:11 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, hpa, suravee.suthikulpanit, mingo, tglx, bp
Commit-ID: 6c4f5abaf3566dbf5b26e7b14f4392be400f12e3
Gitweb: https://git.kernel.org/tip/6c4f5abaf3566dbf5b26e7b14f4392be400f12e3
Author: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
AuthorDate: Fri, 27 Apr 2018 16:48:00 -0500
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Sun, 6 May 2018 12:49:16 +0200
x86/CPU: Modify detect_extended_topology() to return result
Current implementation does not communicate whether it can successfully
detect CPUID function 0xB information. Therefore, modify the function to
return success or error codes. This will be used by subsequent patches.
Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Borislav Petkov <bp@suse.de>
Link: http://lkml.kernel.org/r/1524865681-112110-2-git-send-email-suravee.suthikulpanit@amd.com
---
arch/x86/include/asm/processor.h | 2 +-
arch/x86/kernel/cpu/topology.c | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index 4fa4206029e3..7aa2caa82b2d 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -193,7 +193,7 @@ extern u32 get_scattered_cpuid_leaf(unsigned int level,
extern unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c);
extern void init_amd_cacheinfo(struct cpuinfo_x86 *c);
-extern void detect_extended_topology(struct cpuinfo_x86 *c);
+extern int detect_extended_topology(struct cpuinfo_x86 *c);
extern void detect_ht(struct cpuinfo_x86 *c);
#ifdef CONFIG_X86_32
diff --git a/arch/x86/kernel/cpu/topology.c b/arch/x86/kernel/cpu/topology.c
index b099024d339c..81c0afb39d0a 100644
--- a/arch/x86/kernel/cpu/topology.c
+++ b/arch/x86/kernel/cpu/topology.c
@@ -27,7 +27,7 @@
* exists, use it for populating initial_apicid and cpu topology
* detection.
*/
-void detect_extended_topology(struct cpuinfo_x86 *c)
+int detect_extended_topology(struct cpuinfo_x86 *c)
{
#ifdef CONFIG_SMP
unsigned int eax, ebx, ecx, edx, sub_index;
@@ -36,7 +36,7 @@ void detect_extended_topology(struct cpuinfo_x86 *c)
static bool printed;
if (c->cpuid_level < 0xb)
- return;
+ return -1;
cpuid_count(0xb, SMT_LEVEL, &eax, &ebx, &ecx, &edx);
@@ -44,7 +44,7 @@ void detect_extended_topology(struct cpuinfo_x86 *c)
* check if the cpuid leaf 0xb is actually implemented.
*/
if (ebx == 0 || (LEAFB_SUBTYPE(ecx) != SMT_TYPE))
- return;
+ return -1;
set_cpu_cap(c, X86_FEATURE_XTOPOLOGY);
@@ -95,6 +95,6 @@ void detect_extended_topology(struct cpuinfo_x86 *c)
c->cpu_core_id);
printed = 1;
}
- return;
#endif
+ return 0;
}
^ permalink raw reply [flat|nested] 5+ messages in thread
* [tip:x86/cpu] x86/CPU/AMD: Derive CPU topology from CPUID function 0xB when available
2018-04-27 21:48 ` [PATCH v3 2/2] x86/CPU/AMD: Derive CPU topology from CPUID Fn0xB when available Suravee Suthikulpanit
@ 2018-05-12 21:12 ` tip-bot for Suravee Suthikulpanit
0 siblings, 0 replies; 5+ messages in thread
From: tip-bot for Suravee Suthikulpanit @ 2018-05-12 21:12 UTC (permalink / raw)
To: linux-tip-commits
Cc: suravee.suthikulpanit, hpa, tglx, bp, linux-kernel, mingo
Commit-ID: 3986a0a805e668a63fac0ca2cdfa8db951f87c4b
Gitweb: https://git.kernel.org/tip/3986a0a805e668a63fac0ca2cdfa8db951f87c4b
Author: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
AuthorDate: Fri, 27 Apr 2018 16:48:01 -0500
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Sun, 6 May 2018 12:49:16 +0200
x86/CPU/AMD: Derive CPU topology from CPUID function 0xB when available
Derive topology information from Extended Topology Enumeration (CPUID
function 0xB) when the information is available.
Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1524865681-112110-3-git-send-email-suravee.suthikulpanit@amd.com
---
arch/x86/kernel/cpu/amd.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index bf27246bb7bd..55361ee04cc5 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -327,6 +327,7 @@ static void amd_get_topology(struct cpuinfo_x86 *c)
/* get information required for multi-node processors */
if (boot_cpu_has(X86_FEATURE_TOPOEXT)) {
+ int err;
u32 eax, ebx, ecx, edx;
cpuid(0x8000001e, &eax, &ebx, &ecx, &edx);
@@ -344,6 +345,14 @@ static void amd_get_topology(struct cpuinfo_x86 *c)
c->x86_max_cores /= smp_num_siblings;
}
+ /*
+ * In case leaf B is available, use it to derive
+ * topology information.
+ */
+ err = detect_extended_topology(c);
+ if (!err)
+ c->x86_coreid_bits = get_count_order(c->x86_max_cores);
+
cacheinfo_amd_init_llc_id(c, cpu, node_id);
} else if (cpu_has(c, X86_FEATURE_NODEID_MSR)) {
@@ -378,7 +387,6 @@ static void amd_detect_cmp(struct cpuinfo_x86 *c)
c->phys_proc_id = c->initial_apicid >> bits;
/* use socket ID also for last level cache */
per_cpu(cpu_llc_id, cpu) = c->phys_proc_id;
- amd_get_topology(c);
}
u16 amd_get_nb_id(int cpu)
@@ -821,6 +829,7 @@ static void init_amd(struct cpuinfo_x86 *c)
/* Multi core CPU? */
if (c->extended_cpuid_level >= 0x80000008) {
amd_detect_cmp(c);
+ amd_get_topology(c);
srat_detect_node(c);
}
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-05-12 21:12 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-27 21:47 [PATCH v3 0/2] x86/CPU/AMD: Add support for Extended Topology Enumeration Suravee Suthikulpanit
2018-04-27 21:48 ` [PATCH v3 1/2] x86/CPU: Modify detect_extended_topology() to return result Suravee Suthikulpanit
2018-05-12 21:11 ` [tip:x86/cpu] " tip-bot for Suravee Suthikulpanit
2018-04-27 21:48 ` [PATCH v3 2/2] x86/CPU/AMD: Derive CPU topology from CPUID Fn0xB when available Suravee Suthikulpanit
2018-05-12 21:12 ` [tip:x86/cpu] x86/CPU/AMD: Derive CPU topology from CPUID function 0xB " tip-bot for Suravee Suthikulpanit
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).