Skip to contentSkip to conversation

x86, apic: use logical flat on intel with <= 8 logical cpus

PATCH In review Suresh Siddha 2 participants 5 messages Sep 19, 2009 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86, apic: use logical flat on intel with <= 8 logical cpus

On Intel platforms, we can use logical flat mode if there are <= 8 logical cpu's (irrespective of physical apic id values). This will enable simplified and efficient IPI and device interrupt routing on such platforms.

Fix the relevant comments while we are at it.

We can clean up default_setup_apic_routing() by using apic->probe() but that is a different item.

---

arch/x86/kernel/apic/apic.c +7 -17
index a34601f..0bde0a5 100644
@@ -62,7 +62,7 @@ unsigned int boot_cpu_physical_apicid = -1U;
 /*
  * The highest APIC ID seen during enumeration.
  *
- * This determines the messaging protocol we can use: if all APIC IDs
+ * On AMD, this determines the messaging protocol we can use: if all APIC IDs
  * are in the 0 ... 7 range, then we can use logical addressing which
  * has some performance advantages (better broadcasting).
  *
@@ -1917,24 +1917,14 @@ void __cpuinit generic_processor_info(int apicid, int version)
 		max_physical_apicid = apicid;
 
 #ifdef CONFIG_X86_32
-	/*
-	 * Would be preferable to switch to bigsmp when CONFIG_HOTPLUG_CPU=y
-	 * but we need to work other dependencies like SMP_SUSPEND etc
-	 * before this can be done without some confusion.
-	 * if (CPU_HOTPLUG_ENABLED || num_processors > 8)
-	 *       - Ashok Raj <[email protected]>
-	 */
-	if (max_physical_apicid >= 8) {
-		switch (boot_cpu_data.x86_vendor) {
+	switch (boot_cpu_data.x86_vendor) {
 		case X86_VENDOR_INTEL:
-			if (!APIC_XAPIC(version)) {
-				def_to_bigsmp = 0;
-				break;
-			}
-			/* If P4 and above fall through */
+			if (num_processors > 8)
+				def_to_bigsmp = 1;
+			break;
 		case X86_VENDOR_AMD:
-			def_to_bigsmp = 1;
-		}
+			if (max_physical_apicid >= 8)
+				def_to_bigsmp = 1;
 	}
 #endif
 
arch/x86/kernel/apic/probe_64.c +11 -4
index 65edc18..2e562a3 100644
@@ -64,16 +64,23 @@ void __init default_setup_apic_routing(void)
 			apic = &apic_x2apic_phys;
 		else
 			apic = &apic_x2apic_cluster;
-		printk(KERN_INFO "Setting APIC routing to %s\n", apic->name);
 	}
 #endif
 
 	if (apic == &apic_flat) {
-		if (max_physical_apicid >= 8)
-			apic = &apic_physflat;
-		printk(KERN_INFO "Setting APIC routing to %s\n", apic->name);
+		switch (boot_cpu_data.x86_vendor) {
+			case X86_VENDOR_INTEL:
+				if (num_processors > 8)
+					apic = &apic_physflat;
+				break;
+			case X86_VENDOR_AMD:
+		 		if (max_physical_apicid >= 8)
+					apic = &apic_physflat;
+		}
 	}
 
+	printk(KERN_INFO "Setting APIC routing to %s\n", apic->name);
+
 	if (is_vsmp_box()) {
 		/* need to update phys_pkg_id */
 		apic->phys_pkg_id = apicid_phys_pkg_id;
#1 lore raw

arch/x86/kernel/apic/probe_64.c void __init default_setup_apic_routing(void) · line 79

Quoted 9 lines · Suresh Siddha
arch/x86/kernel/apic/probe_64.c +9 -0
+               switch (boot_cpu_data.x86_vendor) {
+                       case X86_VENDOR_INTEL:
+                               if (num_processors > 8)
+                                       apic = &apic_physflat;
+                               break;
+                       case X86_VENDOR_AMD:
+                               if (max_physical_apicid >= 8)
+                                       apic = &apic_physflat;
+               }

There are a couple of checkpatch issues in this patch .. Could you run it through and fix the errors that show up.. One is that you need 1 less tab for the code inside the switch statement .. You have another switch statement in apic.c that needs similar attention .

Daniel

#2 lore raw
Quoted 4 lines · Daniel Walker

There are a couple of checkpatch issues in this patch .. Could you run it through and fix the errors that show up.. One is that you need 1 less tab for the code inside the switch statement .. You have another switch statement in apic.c that needs similar attention .

Oops. Here it is. Thanks!

---

From: Suresh Siddha <[email protected]>
Subject: x86, apic: use logical flat on intel with <= 8 logical cpus

On Intel platforms, we can use logical flat mode if there are <= 8 logical cpu's (irrespective of physical apic id values). This will enable simplified and efficient IPI and device interrupt routing on such platforms.

Fix the relevant comments while we are at it.

We can clean up default_setup_apic_routing() by using apic->probe() but that is a different item.

---

arch/x86/kernel/apic/apic.c +8 -18
index a34601f..e3654ec 100644
@@ -62,7 +62,7 @@ unsigned int boot_cpu_physical_apicid = -1U;
 /*
  * The highest APIC ID seen during enumeration.
  *
- * This determines the messaging protocol we can use: if all APIC IDs
+ * On AMD, this determines the messaging protocol we can use: if all APIC IDs
  * are in the 0 ... 7 range, then we can use logical addressing which
  * has some performance advantages (better broadcasting).
  *
@@ -1917,24 +1917,14 @@ void __cpuinit generic_processor_info(int apicid, int version)
 		max_physical_apicid = apicid;
 
 #ifdef CONFIG_X86_32
-	/*
-	 * Would be preferable to switch to bigsmp when CONFIG_HOTPLUG_CPU=y
-	 * but we need to work other dependencies like SMP_SUSPEND etc
-	 * before this can be done without some confusion.
-	 * if (CPU_HOTPLUG_ENABLED || num_processors > 8)
-	 *       - Ashok Raj <[email protected]>
-	 */
-	if (max_physical_apicid >= 8) {
-		switch (boot_cpu_data.x86_vendor) {
-		case X86_VENDOR_INTEL:
-			if (!APIC_XAPIC(version)) {
-				def_to_bigsmp = 0;
-				break;
-			}
-			/* If P4 and above fall through */
-		case X86_VENDOR_AMD:
+	switch (boot_cpu_data.x86_vendor) {
+	case X86_VENDOR_INTEL:
+		if (num_processors > 8)
+			def_to_bigsmp = 1;
+		break;
+	case X86_VENDOR_AMD:
+		if (max_physical_apicid >= 8)
 			def_to_bigsmp = 1;
-		}
 	}
 #endif
 
arch/x86/kernel/apic/probe_64.c +11 -4
index 65edc18..41e8509 100644
@@ -64,16 +64,23 @@ void __init default_setup_apic_routing(void)
 			apic = &apic_x2apic_phys;
 		else
 			apic = &apic_x2apic_cluster;
-		printk(KERN_INFO "Setting APIC routing to %s\n", apic->name);
 	}
 #endif
 
 	if (apic == &apic_flat) {
-		if (max_physical_apicid >= 8)
-			apic = &apic_physflat;
-		printk(KERN_INFO "Setting APIC routing to %s\n", apic->name);
+		switch (boot_cpu_data.x86_vendor) {
+		case X86_VENDOR_INTEL:
+			if (num_processors > 8)
+				apic = &apic_physflat;
+			break;
+		case X86_VENDOR_AMD:
+			if (max_physical_apicid >= 8)
+				apic = &apic_physflat;
+		}
 	}
 
+	printk(KERN_INFO "Setting APIC routing to %s\n", apic->name);
+
 	if (is_vsmp_box()) {
 		/* need to update phys_pkg_id */
 		apic->phys_pkg_id = apicid_phys_pkg_id;
#3 lore raw
Quoted 8 lines · Suresh Siddha
Quoted 4 lines · Daniel Walker

There are a couple of checkpatch issues in this patch .. Could you run it through and fix the errors that show up.. One is that you need 1 less tab for the code inside the switch statement .. You have another switch statement in apic.c that needs similar attention .

Oops. Here it is. Thanks!

Much better thanks..

Daniel

#4 lore raw

[tip:x86/urgent] x86, apic: Use logical flat on intel with <= 8 logical cpus

In reply to Suresh Siddha
Commit-ID:  2fbd07a5f5d1295fa9b0c0564ec27da7c276a75a
Gitweb:     http://git.kernel.org/tip/2fbd07a5f5d1295fa9b0c0564ec27da7c276a75a
Author:     Suresh Siddha <[email protected]>
AuthorDate: Fri, 18 Sep 2009 19:29:59 -0700
Committer:  Ingo Molnar <[email protected]>
CommitDate: Sat, 19 Sep 2009 09:20:05 +0200

x86, apic: Use logical flat on intel with <= 8 logical cpus

On Intel platforms, we can use logical flat mode if there are <= 8 logical cpu's (irrespective of physical apic id values). This will enable simplified and efficient IPI and device interrupt routing on such platforms.

Fix the relevant comments while we are at it.

We can clean up default_setup_apic_routing() by using apic->probe() but that is a different item.

LKML-Reference: <[email protected]>

---
 arch/x86/kernel/apic/apic.c     |   26 ++++++++------------------
 arch/x86/kernel/apic/probe_64.c |   15 +++++++++++----
 2 files changed, 19 insertions(+), 22 deletions(-)
arch/x86/kernel/apic/apic.c +8 -18
index 79e5b92..072aea6 100644
@@ -61,7 +61,7 @@ unsigned int boot_cpu_physical_apicid = -1U;
 /*
  * The highest APIC ID seen during enumeration.
  *
- * This determines the messaging protocol we can use: if all APIC IDs
+ * On AMD, this determines the messaging protocol we can use: if all APIC IDs
  * are in the 0 ... 7 range, then we can use logical addressing which
  * has some performance advantages (better broadcasting).
  *
@@ -1915,24 +1915,14 @@ void __cpuinit generic_processor_info(int apicid, int version)
 		max_physical_apicid = apicid;
 
 #ifdef CONFIG_X86_32
-	/*
-	 * Would be preferable to switch to bigsmp when CONFIG_HOTPLUG_CPU=y
-	 * but we need to work other dependencies like SMP_SUSPEND etc
-	 * before this can be done without some confusion.
-	 * if (CPU_HOTPLUG_ENABLED || num_processors > 8)
-	 *       - Ashok Raj <[email protected]>
-	 */
-	if (max_physical_apicid >= 8) {
-		switch (boot_cpu_data.x86_vendor) {
-		case X86_VENDOR_INTEL:
-			if (!APIC_XAPIC(version)) {
-				def_to_bigsmp = 0;
-				break;
-			}
-			/* If P4 and above fall through */
-		case X86_VENDOR_AMD:
+	switch (boot_cpu_data.x86_vendor) {
+	case X86_VENDOR_INTEL:
+		if (num_processors > 8)
+			def_to_bigsmp = 1;
+		break;
+	case X86_VENDOR_AMD:
+		if (max_physical_apicid >= 8)
 			def_to_bigsmp = 1;
-		}
 	}
 #endif
 
arch/x86/kernel/apic/probe_64.c +11 -4
index 65edc18..c4cbd30 100644
@@ -64,16 +64,23 @@ void __init default_setup_apic_routing(void)
 			apic = &apic_x2apic_phys;
 		else
 			apic = &apic_x2apic_cluster;
-		printk(KERN_INFO "Setting APIC routing to %s\n", apic->name);
 	}
 #endif
 
 	if (apic == &apic_flat) {
-		if (max_physical_apicid >= 8)
-			apic = &apic_physflat;
-		printk(KERN_INFO "Setting APIC routing to %s\n", apic->name);
+		switch (boot_cpu_data.x86_vendor) {
+		case X86_VENDOR_INTEL:
+			if (num_processors > 8)
+				apic = &apic_physflat;
+			break;
+		case X86_VENDOR_AMD:
+			if (max_physical_apicid >= 8)
+				apic = &apic_physflat;
+		}
 	}
 
+	printk(KERN_INFO "Setting APIC routing to %s\n", apic->name);
+
 	if (is_vsmp_box()) {
 		/* need to update phys_pkg_id */
 		apic->phys_pkg_id = apicid_phys_pkg_id;