All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/amd: Fix L1i and L2 cache sharing information for AMD family 15h processors
@ 2012-02-08 19:52 Andreas Herrmann
  2012-02-09 12:41 ` [tip:x86/urgent] " tip-bot for Andreas Herrmann
  0 siblings, 1 reply; 5+ messages in thread
From: Andreas Herrmann @ 2012-02-08 19:52 UTC (permalink / raw)
  To: Ingo Molnar, Thomas Gleixner, H. Peter Anvin
  Cc: linux-kernel, Petkov, Borislav


For L1 instruction cache and L2 cache the shared CPU information
is wrong. On current AMD family 15h CPUs those caches are shared
between both cores of a compute unit.

This fixes https://bugzilla.kernel.org/show_bug.cgi?id=42607

Signed-off-by: Andreas Herrmann <andreas.herrmann3@amd.com>
---
 arch/x86/kernel/cpu/intel_cacheinfo.c |   45 +++++++++++++++++++++++++++-----
 1 files changed, 38 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
index 6b45e5e..8e58fdb 100644
--- a/arch/x86/kernel/cpu/intel_cacheinfo.c
+++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
@@ -725,14 +725,16 @@ static DEFINE_PER_CPU(struct _cpuid4_info *, ici_cpuid4_info);
 #define CPUID4_INFO_IDX(x, y)	(&((per_cpu(ici_cpuid4_info, x))[y]))
 
 #ifdef CONFIG_SMP
-static void __cpuinit cache_shared_cpu_map_setup(unsigned int cpu, int index)
+
+static int __cpuinit cache_shared_amd_cpu_map_setup(unsigned int cpu, int index)
 {
-	struct _cpuid4_info	*this_leaf, *sibling_leaf;
-	unsigned long num_threads_sharing;
-	int index_msb, i, sibling;
+	struct _cpuid4_info *this_leaf;
+	int ret, i, sibling;
 	struct cpuinfo_x86 *c = &cpu_data(cpu);
 
-	if ((index == 3) && (c->x86_vendor == X86_VENDOR_AMD)) {
+	ret = 0;
+	if (index == 3) {
+		ret = 1;
 		for_each_cpu(i, cpu_llc_shared_mask(cpu)) {
 			if (!per_cpu(ici_cpuid4_info, i))
 				continue;
@@ -740,11 +742,40 @@ static void __cpuinit cache_shared_cpu_map_setup(unsigned int cpu, int index)
 			for_each_cpu(sibling, cpu_llc_shared_mask(cpu)) {
 				if (!cpu_online(sibling))
 					continue;
-				set_bit(sibling, this_leaf->shared_cpu_map);
+				set_bit(sibling,
+					this_leaf->shared_cpu_map);
+			}
+		}
+	} else if ((c->x86 == 0x15) && ((index == 1) || (index == 2))) {
+		ret = 1;
+		for_each_cpu(i, cpu_sibling_mask(cpu)) {
+			if (!per_cpu(ici_cpuid4_info, i))
+				continue;
+			this_leaf = CPUID4_INFO_IDX(i, index);
+			for_each_cpu(sibling, cpu_sibling_mask(cpu)) {
+				if (!cpu_online(sibling))
+					continue;
+				set_bit(sibling,
+					this_leaf->shared_cpu_map);
 			}
 		}
-		return;
 	}
+
+	return ret;
+}
+
+static void __cpuinit cache_shared_cpu_map_setup(unsigned int cpu, int index)
+{
+	struct _cpuid4_info	*this_leaf, *sibling_leaf;
+	unsigned long num_threads_sharing;
+	int index_msb, i;
+	struct cpuinfo_x86 *c = &cpu_data(cpu);
+
+	if (c->x86_vendor == X86_VENDOR_AMD) {
+		if (cache_shared_amd_cpu_map_setup(cpu, index))
+		    return;
+	}
+
 	this_leaf = CPUID4_INFO_IDX(cpu, index);
 	num_threads_sharing = 1 + this_leaf->base.eax.split.num_threads_sharing;
 
-- 
1.7.8.3




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

* [tip:x86/urgent] x86/amd: Fix L1i and L2 cache sharing information for AMD family 15h processors
  2012-02-08 19:52 [PATCH] x86/amd: Fix L1i and L2 cache sharing information for AMD family 15h processors Andreas Herrmann
@ 2012-02-09 12:41 ` tip-bot for Andreas Herrmann
  2012-02-09 13:37   ` Ingo Molnar
  0 siblings, 1 reply; 5+ messages in thread
From: tip-bot for Andreas Herrmann @ 2012-02-09 12:41 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, andreas.herrmann3, davej,
	Borislav.Petkov, stable, tglx, mingo

Commit-ID:  32c3233885eb10ac9cb9410f2f8cd64b8df2b2a1
Gitweb:     http://git.kernel.org/tip/32c3233885eb10ac9cb9410f2f8cd64b8df2b2a1
Author:     Andreas Herrmann <andreas.herrmann3@amd.com>
AuthorDate: Wed, 8 Feb 2012 20:52:29 +0100
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Thu, 9 Feb 2012 09:38:15 +0100

x86/amd: Fix L1i and L2 cache sharing information for AMD family 15h processors

For L1 instruction cache and L2 cache the shared CPU information
is wrong. On current AMD family 15h CPUs those caches are shared
between both cores of a compute unit.

This fixes https://bugzilla.kernel.org/show_bug.cgi?id=42607

Signed-off-by: Andreas Herrmann <andreas.herrmann3@amd.com>
Cc: Petkov Borislav <Borislav.Petkov@amd.com>
Cc: Dave Jones <davej@redhat.com>
Cc: <stable@kernel.org>
Link: http://lkml.kernel.org/r/20120208195229.GA17523@alberich.amd.com
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 arch/x86/kernel/cpu/intel_cacheinfo.c |   44 +++++++++++++++++++++++++++------
 1 files changed, 36 insertions(+), 8 deletions(-)

diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
index 6b45e5e..73d08ed 100644
--- a/arch/x86/kernel/cpu/intel_cacheinfo.c
+++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
@@ -326,8 +326,7 @@ static void __cpuinit amd_calc_l3_indices(struct amd_northbridge *nb)
 	l3->indices = (max(max3(sc0, sc1, sc2), sc3) << 10) - 1;
 }
 
-static void __cpuinit amd_init_l3_cache(struct _cpuid4_info_regs *this_leaf,
-					int index)
+static void __cpuinit amd_init_l3_cache(struct _cpuid4_info_regs *this_leaf, int index)
 {
 	int node;
 
@@ -725,14 +724,16 @@ static DEFINE_PER_CPU(struct _cpuid4_info *, ici_cpuid4_info);
 #define CPUID4_INFO_IDX(x, y)	(&((per_cpu(ici_cpuid4_info, x))[y]))
 
 #ifdef CONFIG_SMP
-static void __cpuinit cache_shared_cpu_map_setup(unsigned int cpu, int index)
+
+static int __cpuinit cache_shared_amd_cpu_map_setup(unsigned int cpu, int index)
 {
-	struct _cpuid4_info	*this_leaf, *sibling_leaf;
-	unsigned long num_threads_sharing;
-	int index_msb, i, sibling;
+	struct _cpuid4_info *this_leaf;
+	int ret, i, sibling;
 	struct cpuinfo_x86 *c = &cpu_data(cpu);
 
-	if ((index == 3) && (c->x86_vendor == X86_VENDOR_AMD)) {
+	ret = 0;
+	if (index == 3) {
+		ret = 1;
 		for_each_cpu(i, cpu_llc_shared_mask(cpu)) {
 			if (!per_cpu(ici_cpuid4_info, i))
 				continue;
@@ -743,8 +744,35 @@ static void __cpuinit cache_shared_cpu_map_setup(unsigned int cpu, int index)
 				set_bit(sibling, this_leaf->shared_cpu_map);
 			}
 		}
-		return;
+	} else if ((c->x86 == 0x15) && ((index == 1) || (index == 2))) {
+		ret = 1;
+		for_each_cpu(i, cpu_sibling_mask(cpu)) {
+			if (!per_cpu(ici_cpuid4_info, i))
+				continue;
+			this_leaf = CPUID4_INFO_IDX(i, index);
+			for_each_cpu(sibling, cpu_sibling_mask(cpu)) {
+				if (!cpu_online(sibling))
+					continue;
+				set_bit(sibling, this_leaf->shared_cpu_map);
+			}
+		}
 	}
+
+	return ret;
+}
+
+static void __cpuinit cache_shared_cpu_map_setup(unsigned int cpu, int index)
+{
+	struct _cpuid4_info *this_leaf, *sibling_leaf;
+	unsigned long num_threads_sharing;
+	int index_msb, i;
+	struct cpuinfo_x86 *c = &cpu_data(cpu);
+
+	if (c->x86_vendor == X86_VENDOR_AMD) {
+		if (cache_shared_amd_cpu_map_setup(cpu, index))
+			return;
+	}
+
 	this_leaf = CPUID4_INFO_IDX(cpu, index);
 	num_threads_sharing = 1 + this_leaf->base.eax.split.num_threads_sharing;
 

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

* Re: [tip:x86/urgent] x86/amd: Fix L1i and L2 cache sharing information for AMD family 15h processors
  2012-02-09 12:41 ` [tip:x86/urgent] " tip-bot for Andreas Herrmann
@ 2012-02-09 13:37   ` Ingo Molnar
  2012-02-09 15:35     ` Andreas Herrmann
  0 siblings, 1 reply; 5+ messages in thread
From: Ingo Molnar @ 2012-02-09 13:37 UTC (permalink / raw)
  To: tip-bot for Andreas Herrmann
  Cc: linux-tip-commits, linux-kernel, hpa, mingo, davej,
	Borislav.Petkov, stable, tglx


This commit seems to cause a boot hang on an old Athlon64 CPU:

CPU: Physical Processor ID: 0
CPU: Processor Core ID: 0
numa_add_cpu cpu 0 node 0: mask now 0
ExtINT not setup in hardware but reported by MP table
..TIMER: vector=0x30 apic1=0 pin1=2 apic2=0 pin2=0
..MP-BIOS bug: 8254 timer not connected to IO-APIC
...trying to set up timer (IRQ0) through the 8259A ...
..... (found apic 0 pin 0) ...
....... works.
CPU0: AMD Athlon(tm) 64 X2 Dual Core Processor 3800+ stepping 02

Thanks,

	Ingo

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

* Re: [tip:x86/urgent] x86/amd: Fix L1i and L2 cache sharing information for AMD family 15h processors
  2012-02-09 13:37   ` Ingo Molnar
@ 2012-02-09 15:35     ` Andreas Herrmann
  2012-02-10  6:17       ` Ingo Molnar
  0 siblings, 1 reply; 5+ messages in thread
From: Andreas Herrmann @ 2012-02-09 15:35 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-tip-commits, linux-kernel, hpa, mingo, davej,
	Borislav.Petkov, stable, tglx

On Thu, Feb 09, 2012 at 02:37:54PM +0100, Ingo Molnar wrote:
> 
> This commit seems to cause a boot hang on an old Athlon64 CPU:

Are you sure that it's this commit, or is it possible that some other
patch in tip might trigger the trouble? (Systems boots fine with this
patch reverted?)

> CPU: Physical Processor ID: 0
> CPU: Processor Core ID: 0
> numa_add_cpu cpu 0 node 0: mask now 0
> ExtINT not setup in hardware but reported by MP table
> ..TIMER: vector=0x30 apic1=0 pin1=2 apic2=0 pin2=0
> ..MP-BIOS bug: 8254 timer not connected to IO-APIC
> ...trying to set up timer (IRQ0) through the 8259A ...
> ..... (found apic 0 pin 0) ...
> ....... works.
> CPU0: AMD Athlon(tm) 64 X2 Dual Core Processor 3800+ stepping 02

Can't reproduce this here (tried it on a couple of further
systems). Can you please provide dmesg or at least /proc/cpuinfo
output? (Also at the moment, it's not obvious to me how this timer
interrupt trouble is related to this patch.)


Thanks,

Andreas



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

* Re: [tip:x86/urgent] x86/amd: Fix L1i and L2 cache sharing information for AMD family 15h processors
  2012-02-09 15:35     ` Andreas Herrmann
@ 2012-02-10  6:17       ` Ingo Molnar
  0 siblings, 0 replies; 5+ messages in thread
From: Ingo Molnar @ 2012-02-10  6:17 UTC (permalink / raw)
  To: Andreas Herrmann
  Cc: linux-tip-commits, linux-kernel, hpa, mingo, davej,
	Borislav.Petkov, stable, tglx


* Andreas Herrmann <andreas.herrmann3@amd.com> wrote:

> On Thu, Feb 09, 2012 at 02:37:54PM +0100, Ingo Molnar wrote:
> > 
> > This commit seems to cause a boot hang on an old Athlon64 CPU:
> 
> Are you sure that it's this commit, or is it possible that 
> some other patch in tip might trigger the trouble? (Systems 
> boots fine with this patch reverted?)

You are right, it's not this commit after all, but probably some 
other recent commit. I'll bisect it.

Thanks,

	Ingo

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

end of thread, other threads:[~2012-02-10  6:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-08 19:52 [PATCH] x86/amd: Fix L1i and L2 cache sharing information for AMD family 15h processors Andreas Herrmann
2012-02-09 12:41 ` [tip:x86/urgent] " tip-bot for Andreas Herrmann
2012-02-09 13:37   ` Ingo Molnar
2012-02-09 15:35     ` Andreas Herrmann
2012-02-10  6:17       ` Ingo Molnar

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.