linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86: use dmi check in apic_is_clustered with 64bit
@ 2009-04-27  6:39 Yinghai Lu
  2009-04-27 17:00 ` [tip:x86/apic] x86: Use dmi check in apic_is_clustered() on 64-bit to mark the TSC unstable tip-bot for Yinghai Lu
  2009-04-27 23:30 ` [PATCH] x86: use dmi check in apic_is_clustered with 64bit Ravikiran G Thirumalai
  0 siblings, 2 replies; 3+ messages in thread
From: Yinghai Lu @ 2009-04-27  6:39 UTC (permalink / raw)
  To: Ingo Molnar, Thomas Gleixner, H. Peter Anvin; +Cc: linux-kernel


will have system with 2 and more sockets 8cores/2thread.
do treat them as multi chassis.

use dmi check instead.

[ Impact: do not make unstable TSC on wrongly ]

Signed-off-by: Yinghai Lu <yinghai@kernel.org>

---
 arch/x86/kernel/apic/apic.c |   86 ++++++++++++++++++++++++++++++--------------
 1 file changed, 59 insertions(+), 27 deletions(-)

Index: linux-2.6/arch/x86/kernel/apic/apic.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/apic/apic.c
+++ linux-2.6/arch/x86/kernel/apic/apic.c
@@ -2142,31 +2142,14 @@ static void apic_pm_activate(void) { }
 #endif	/* CONFIG_PM */
 
 #ifdef CONFIG_X86_64
-/*
- * apic_is_clustered_box() -- Check if we can expect good TSC
- *
- * Thus far, the major user of this is IBM's Summit2 series:
- *
- * Clustered boxes may have unsynced TSC problems if they are
- * multi-chassis. Use available data to take a good guess.
- * If in doubt, go HPET.
- */
-__cpuinit int apic_is_clustered_box(void)
+
+static int __cpuinit apic_cluster_num(void)
 {
 	int i, clusters, zeros;
 	unsigned id;
 	u16 *bios_cpu_apicid;
 	DECLARE_BITMAP(clustermap, NUM_APIC_CLUSTERS);
 
-	/*
-	 * there is not this kind of box with AMD CPU yet.
-	 * Some AMD box with quadcore cpu and 8 sockets apicid
-	 * will be [4, 0x23] or [8, 0x27] could be thought to
-	 * vsmp box still need checking...
-	 */
-	if ((boot_cpu_data.x86_vendor == X86_VENDOR_AMD) && !is_vsmp_box())
-		return 0;
-
 	bios_cpu_apicid = early_per_cpu_ptr(x86_bios_cpu_apicid);
 	bitmap_zero(clustermap, NUM_APIC_CLUSTERS);
 
@@ -2202,18 +2185,67 @@ __cpuinit int apic_is_clustered_box(void
 			++zeros;
 	}
 
-	/* ScaleMP vSMPowered boxes have one cluster per board and TSCs are
-	 * not guaranteed to be synced between boards
-	 */
-	if (is_vsmp_box() && clusters > 1)
+	return clusters;
+}
+
+static int __cpuinitdata multi_checked;
+static int __cpuinitdata multi;
+
+static int __cpuinit set_multi(const struct dmi_system_id *d)
+{
+	if (multi)
+		return 0;
+	printk(KERN_INFO "APIC: %s detected, Multi Chassis\n", d->ident);
+	multi = 1;
+	return 0;
+}
+
+static const __cpuinitconst struct dmi_system_id multi_dmi_table[] = {
+	{
+		.callback = set_multi,
+		.ident = "IBM System Summit2",
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "Summit2"),
+		},
+	},
+	{}
+};
+
+static void __cpuinit dmi_check_multi(void)
+{
+	if (multi_checked)
+		return;
+
+	dmi_check_system(multi_dmi_table);
+	multi_checked = 1;
+}
+
+/*
+ * apic_is_clustered_box() -- Check if we can expect good TSC
+ *
+ * Thus far, the major user of this is IBM's Summit2 series:
+ * Clustered boxes may have unsynced TSC problems if they are
+ * multi-chassis.
+ * Use DMI to check them
+ */
+__cpuinit int apic_is_clustered_box(void)
+{
+	dmi_check_multi();
+	if (multi)
 		return 1;
 
+	if (!is_vsmp_box())
+		return 0;
+
 	/*
-	 * If clusters > 2, then should be multi-chassis.
-	 * May have to revisit this when multi-core + hyperthreaded CPUs come
-	 * out, but AFAIK this will work even for them.
+	 * ScaleMP vSMPowered boxes have one cluster per board and TSCs are
+	 * not guaranteed to be synced between boards
 	 */
-	return (clusters > 2);
+	if (apic_cluster_num() > 1)
+		return 1;
+
+	return 0;
 }
 #endif
 

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

* [tip:x86/apic] x86: Use dmi check in apic_is_clustered() on 64-bit to mark the TSC unstable
  2009-04-27  6:39 [PATCH] x86: use dmi check in apic_is_clustered with 64bit Yinghai Lu
@ 2009-04-27 17:00 ` tip-bot for Yinghai Lu
  2009-04-27 23:30 ` [PATCH] x86: use dmi check in apic_is_clustered with 64bit Ravikiran G Thirumalai
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Yinghai Lu @ 2009-04-27 17:00 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, kiran, yinghai, tglx, mingo

Commit-ID:  e0e42142bab96404de535cceb85d6533d5ad7942
Gitweb:     http://git.kernel.org/tip/e0e42142bab96404de535cceb85d6533d5ad7942
Author:     Yinghai Lu <yinghai@kernel.org>
AuthorDate: Sun, 26 Apr 2009 23:39:38 -0700
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Mon, 27 Apr 2009 09:23:52 +0200

x86: Use dmi check in apic_is_clustered() on 64-bit to mark the TSC unstable

We will have systems with 2 and more sockets 8cores/2thread,
but we treat them as multi chassis - while they could have
a stable TSC domain.

Use DMI check instead.

[ Impact: do not turn possibly stable TSCs off incorrectly ]

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Ravikiran Thirumalai <kiran@scalex86.org>
LKML-Reference: <49F5532A.5000802@kernel.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>


---
 arch/x86/kernel/apic/apic.c |   86 +++++++++++++++++++++++++++++-------------
 1 files changed, 59 insertions(+), 27 deletions(-)

diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 1386dbe..28f747d 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -2138,31 +2138,14 @@ static void apic_pm_activate(void) { }
 #endif	/* CONFIG_PM */
 
 #ifdef CONFIG_X86_64
-/*
- * apic_is_clustered_box() -- Check if we can expect good TSC
- *
- * Thus far, the major user of this is IBM's Summit2 series:
- *
- * Clustered boxes may have unsynced TSC problems if they are
- * multi-chassis. Use available data to take a good guess.
- * If in doubt, go HPET.
- */
-__cpuinit int apic_is_clustered_box(void)
+
+static int __cpuinit apic_cluster_num(void)
 {
 	int i, clusters, zeros;
 	unsigned id;
 	u16 *bios_cpu_apicid;
 	DECLARE_BITMAP(clustermap, NUM_APIC_CLUSTERS);
 
-	/*
-	 * there is not this kind of box with AMD CPU yet.
-	 * Some AMD box with quadcore cpu and 8 sockets apicid
-	 * will be [4, 0x23] or [8, 0x27] could be thought to
-	 * vsmp box still need checking...
-	 */
-	if ((boot_cpu_data.x86_vendor == X86_VENDOR_AMD) && !is_vsmp_box())
-		return 0;
-
 	bios_cpu_apicid = early_per_cpu_ptr(x86_bios_cpu_apicid);
 	bitmap_zero(clustermap, NUM_APIC_CLUSTERS);
 
@@ -2198,18 +2181,67 @@ __cpuinit int apic_is_clustered_box(void)
 			++zeros;
 	}
 
-	/* ScaleMP vSMPowered boxes have one cluster per board and TSCs are
-	 * not guaranteed to be synced between boards
-	 */
-	if (is_vsmp_box() && clusters > 1)
+	return clusters;
+}
+
+static int __cpuinitdata multi_checked;
+static int __cpuinitdata multi;
+
+static int __cpuinit set_multi(const struct dmi_system_id *d)
+{
+	if (multi)
+		return 0;
+	printk(KERN_INFO "APIC: %s detected, Multi Chassis\n", d->ident);
+	multi = 1;
+	return 0;
+}
+
+static const __cpuinitconst struct dmi_system_id multi_dmi_table[] = {
+	{
+		.callback = set_multi,
+		.ident = "IBM System Summit2",
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "Summit2"),
+		},
+	},
+	{}
+};
+
+static void __cpuinit dmi_check_multi(void)
+{
+	if (multi_checked)
+		return;
+
+	dmi_check_system(multi_dmi_table);
+	multi_checked = 1;
+}
+
+/*
+ * apic_is_clustered_box() -- Check if we can expect good TSC
+ *
+ * Thus far, the major user of this is IBM's Summit2 series:
+ * Clustered boxes may have unsynced TSC problems if they are
+ * multi-chassis.
+ * Use DMI to check them
+ */
+__cpuinit int apic_is_clustered_box(void)
+{
+	dmi_check_multi();
+	if (multi)
 		return 1;
 
+	if (!is_vsmp_box())
+		return 0;
+
 	/*
-	 * If clusters > 2, then should be multi-chassis.
-	 * May have to revisit this when multi-core + hyperthreaded CPUs come
-	 * out, but AFAIK this will work even for them.
+	 * ScaleMP vSMPowered boxes have one cluster per board and TSCs are
+	 * not guaranteed to be synced between boards
 	 */
-	return (clusters > 2);
+	if (apic_cluster_num() > 1)
+		return 1;
+
+	return 0;
 }
 #endif
 

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

* Re: [PATCH] x86: use dmi check in apic_is_clustered with 64bit
  2009-04-27  6:39 [PATCH] x86: use dmi check in apic_is_clustered with 64bit Yinghai Lu
  2009-04-27 17:00 ` [tip:x86/apic] x86: Use dmi check in apic_is_clustered() on 64-bit to mark the TSC unstable tip-bot for Yinghai Lu
@ 2009-04-27 23:30 ` Ravikiran G Thirumalai
  1 sibling, 0 replies; 3+ messages in thread
From: Ravikiran G Thirumalai @ 2009-04-27 23:30 UTC (permalink / raw)
  To: Yinghai Lu; +Cc: Ingo Molnar, Thomas Gleixner, H. Peter Anvin, linux-kernel

On Sun, Apr 26, 2009 at 11:39:38PM -0700, Yinghai Lu wrote:
>
>will have system with 2 and more sockets 8cores/2thread.
>do treat them as multi chassis.
>
>use dmi check instead.
>
>[ Impact: do not make unstable TSC on wrongly ]
>
>Signed-off-by: Yinghai Lu <yinghai@kernel.org>
>

The patch looks good.
Just one minor observation -- apic_is_clustered_box()
is used only to check if tscs are synced.  It is not used elsewhere. Since
the routine is not actually checking if the box uses clustered apic --
rather the routine is used to determine if tsc's are synced are not, the name
could be changed appropriately I guess?

...
>+}
>+
>+/*
>+ * apic_is_clustered_box() -- Check if we can expect good TSC
>+ *
>+ * Thus far, the major user of this is IBM's Summit2 series:
>+ * Clustered boxes may have un-synced TSC problems if they are
>+ * multi-chassis.
>+ * Use DMI to check them
>+ */
>+__cpuinit int apic_is_clustered_box(void)
>+{
>+	dmi_check_multi();
>+	if (multi)
> 		return 1;
> 
>+	if (!is_vsmp_box())
>+		return 0;
>+
> 	/*
>-	 * If clusters > 2, then should be multi-chassis.
>-	 * May have to revisit this when multi-core + hyperthreaded CPUs come
>-	 * out, but AFAIK this will work even for them.
>+	 * ScaleMP vSMPowered boxes have one cluster per board and TSCs are
>+	 * not guaranteed to be synced between boards
> 	 */
>-	return (clusters > 2);
>+	if (apic_cluster_num() > 1)
>+		return 1;
>+
>+	return 0;
> }

...

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

end of thread, other threads:[~2009-04-27 23:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-27  6:39 [PATCH] x86: use dmi check in apic_is_clustered with 64bit Yinghai Lu
2009-04-27 17:00 ` [tip:x86/apic] x86: Use dmi check in apic_is_clustered() on 64-bit to mark the TSC unstable tip-bot for Yinghai Lu
2009-04-27 23:30 ` [PATCH] x86: use dmi check in apic_is_clustered with 64bit Ravikiran G Thirumalai

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).