Skip to contentSkip to conversation

x86/mm/numa: Open code function early_get_boot_cpu_id

PATCH New Baoquan He 2 participants 4 messages Aug 12, 2016 – Aug 15, 2016

Subsystems (3)
lore
Share & tools
lore

Baoquan He

author
#0 lore raw

PATCH v4 1/2 x86/mm/numa: Open code function early_get_boot_cpu_id

Previously early_acpi_boot_init is called in early_get_boot_cpu_id() to get value for boot_cpu_physical_apicid. Now early_acpi_boot_init() has been taken out and moved to setup_arch(), the name of early_get_boot_cpu_id doesn't match its implementation. And only the getting boot-time SMP configuration code is left. So in this patch open code it.

And move the smp_found_config check into default_get_smp_config to simplify code. Because both early_get_smp_config and get_smp_config call x86_init.mpparse.get_smp_config(). While x86_init.mpparse.get_smp_config is set as default_get_smp_config when they really try to get boot-time SMP config, otherwise it's set as x86_init_uint_noop to do nothing.

And there are different version of early_get_smp_config based on CONFIG_X86_MPPARSE check, so remove the redundent CONFIG_X86_MPPARSE #ifdef check when call early_get_smp_config.

---
v1->v3:
-No change.
v3->v4:
1)Move smp_found_config check into default_get_smp_config.
2)Remove the redundent #ifdef check of CONFIG_X86_MPPARSE when call early_get_smp_config. -These are suggested by Ingo.

 arch/x86/kernel/mpparse.c |  3 +++
 arch/x86/kernel/setup.c   |  3 +--
 arch/x86/mm/amdtopology.c | 22 +++++-----------------
 3 files changed, 9 insertions(+), 19 deletions(-)
arch/x86/kernel/mpparse.c +3 -0
index 068c4a9..0f8d204 100644
@@ -499,6 +499,9 @@ void __init default_get_smp_config(unsigned int early)
 {
 	struct mpf_intel *mpf = mpf_found;
 
+	if (!smp_found_config)
+		return;
+
 	if (!mpf)
 		return;
 
arch/x86/kernel/setup.c +1 -2
index 991b779..a0db003 100644
@@ -1214,8 +1214,7 @@ void __init setup_arch(char **cmdline_p)
 	/*
 	 * get boot-time SMP configuration:
 	 */
-	if (smp_found_config)
-		get_smp_config();
+	get_smp_config();
 
 	prefill_possible_map();
 
arch/x86/mm/amdtopology.c +5 -17
index ba47524..d1c7de0 100644
@@ -52,21 +52,6 @@ static __init int find_northbridge(void)
 	return -ENOENT;
 }
 
-static __init void early_get_boot_cpu_id(void)
-{
-	/*
-	 * need to get the APIC ID of the BSP so can use that to
-	 * create apicid_to_node in amd_scan_nodes()
-	 */
-#ifdef CONFIG_X86_MPPARSE
-	/*
-	 * get boot-time SMP configuration:
-	 */
-	if (smp_found_config)
-		early_get_smp_config();
-#endif
-}
-
 int __init amd_numa_init(void)
 {
 	u64 start = PFN_PHYS(0);
@@ -180,8 +165,11 @@ int __init amd_numa_init(void)
 	cores = 1 << bits;
 	apicid_base = 0;
 
-	/* get the APIC ID of the BSP early for systems with apicid lifting */
-	early_get_boot_cpu_id();
+	/*
+	 * get boot-time SMP configuration:
+	 */
+	early_get_smp_config();
+
 	if (boot_cpu_physical_apicid > 0) {
 		pr_info("BSP APIC ID: %02x\n", boot_cpu_physical_apicid);
 		apicid_base = boot_cpu_physical_apicid;
Signature · 1 line
2.5.5
author
#1 lore raw

PATCH v4 2/2 x86/acpi: Remove the repeated lapic address override entry parsing

ACPI MADT has a 32-bit field providing lapic address at which each processor can access its lapic information. MADT also contains an optional entry to provide a 64-bit address to override the 32-bit one. However the current code does the lapic address override entry parsing twice. One is in early_acpi_boot_init() because AMD NUMA need get boot_cpu_id earlier. The other is in acpi_boot_init() which parses all MADT entries.

So in this patch remove the repeated code in the 2nd part.

Meanwhile print lapic override entry information like other MADT entry, this will be added to boot log.

This patch is not supposed to change any runtime behavior, other than improving kernel messages.

---
v1->v2:
-Remove the incorrect code comment above early_acpi_boot_init()
as Rafael suggested.

v2->v4:
-Spell out that this patch is not supposed to change any runtime
behavior, other than improving kernel messages.

 arch/x86/kernel/acpi/boot.c | 17 ++---------------
 arch/x86/kernel/apic/apic.c |  2 +-
 2 files changed, 3 insertions(+), 16 deletions(-)
arch/x86/kernel/acpi/boot.c +2 -15
index 90d84c3..2087bea 100644
@@ -282,6 +282,8 @@ acpi_parse_lapic_addr_ovr(struct acpi_subtable_header * header,
 	if (BAD_MADT_ENTRY(lapic_addr_ovr, end))
 		return -EINVAL;
 
+	acpi_table_print_madt_entry(header);
+
 	acpi_lapic_addr = lapic_addr_ovr->address;
 
 	return 0;
@@ -998,21 +1000,6 @@ static int __init acpi_parse_madt_lapic_entries(void)
 	if (!boot_cpu_has(X86_FEATURE_APIC))
 		return -ENODEV;
 
-	/*
-	 * Note that the LAPIC address is obtained from the MADT (32-bit value)
-	 * and (optionally) overridden by a LAPIC_ADDR_OVR entry (64-bit value).
-	 */
-
-	count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE,
-				      acpi_parse_lapic_addr_ovr, 0);
-	if (count < 0) {
-		printk(KERN_ERR PREFIX
-		       "Error parsing LAPIC address override entry\n");
-		return count;
-	}
-
-	register_lapic_address(acpi_lapic_addr);
-
 	count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_SAPIC,
 				      acpi_parse_sapic, MAX_LOCAL_APIC);
 
arch/x86/kernel/apic/apic.c +1 -1
index 20abd91..cb87da2 100644
@@ -1801,7 +1801,7 @@ void __init register_lapic_address(unsigned long address)
 	if (!x2apic_mode) {
 		set_fixmap_nocache(FIX_APIC_BASE, address);
 		apic_printk(APIC_VERBOSE, "mapped APIC to %16lx (%16lx)\n",
-			    APIC_BASE, mp_lapic_addr);
+			    APIC_BASE, address);
 	}
 	if (boot_cpu_physical_apicid == -1U) {
 		boot_cpu_physical_apicid  = read_apic_id();
Signature · 1 line
2.5.5
#2 lore raw

[tip:x86/apic] x86/apic, ACPI: Remove the repeated lapic address override entry parsing

x86/apic, ACPI: Remove the repeated lapic address override entry parsing
Commit-ID:  6de421198c75d95088331e6a480e952292b0e121
Gitweb:     http://git.kernel.org/tip/6de421198c75d95088331e6a480e952292b0e121
Author:     Baoquan He <[email protected]>
AuthorDate: Fri, 12 Aug 2016 14:57:13 +0800
Committer:  Ingo Molnar <[email protected]>
CommitDate: Mon, 15 Aug 2016 08:53:37 +0200

x86/apic, ACPI: Remove the repeated lapic address override entry parsing

The ACPI MADT has a 32-bit field providing lapic address at which each processor can access its lapic information. MADT also contains an optional entry to provide a 64-bit address to override the 32-bit one. However the current code does the lapic address override entry parsing twice. One is in early_acpi_boot_init() because AMD NUMA need get boot_cpu_id earlier. The other is in acpi_boot_init() which parses all MADT entries.

So in this patch we remove the repeated code in the 2nd part.

Meanwhile print lapic override entry information like other MADT entry, this will be added to boot log.

This patch is not supposed to change any runtime behavior, other than improving kernel messages.

Cc Andy Lutomirski <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Brian Gerst <[email protected]>
Cc Denys Vlasenko <[email protected]>
Cc H. Peter Anvin <[email protected]>
Cc Josh Poimboeuf <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Thomas Gleixner <[email protected]>
---
 arch/x86/kernel/acpi/boot.c | 17 ++---------------
 arch/x86/kernel/apic/apic.c |  2 +-
 2 files changed, 3 insertions(+), 16 deletions(-)
arch/x86/kernel/acpi/boot.c +2 -15
index 90d84c3..2087bea 100644
@@ -282,6 +282,8 @@ acpi_parse_lapic_addr_ovr(struct acpi_subtable_header * header,
 	if (BAD_MADT_ENTRY(lapic_addr_ovr, end))
 		return -EINVAL;
 
+	acpi_table_print_madt_entry(header);
+
 	acpi_lapic_addr = lapic_addr_ovr->address;
 
 	return 0;
@@ -998,21 +1000,6 @@ static int __init acpi_parse_madt_lapic_entries(void)
 	if (!boot_cpu_has(X86_FEATURE_APIC))
 		return -ENODEV;
 
-	/*
-	 * Note that the LAPIC address is obtained from the MADT (32-bit value)
-	 * and (optionally) overridden by a LAPIC_ADDR_OVR entry (64-bit value).
-	 */
-
-	count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE,
-				      acpi_parse_lapic_addr_ovr, 0);
-	if (count < 0) {
-		printk(KERN_ERR PREFIX
-		       "Error parsing LAPIC address override entry\n");
-		return count;
-	}
-
-	register_lapic_address(acpi_lapic_addr);
-
 	count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_SAPIC,
 				      acpi_parse_sapic, MAX_LOCAL_APIC);
 
arch/x86/kernel/apic/apic.c +1 -1
index cea4fc1..63b7484 100644
@@ -1825,7 +1825,7 @@ void __init register_lapic_address(unsigned long address)
 	if (!x2apic_mode) {
 		set_fixmap_nocache(FIX_APIC_BASE, address);
 		apic_printk(APIC_VERBOSE, "mapped APIC to %16lx (%16lx)\n",
-			    APIC_BASE, mp_lapic_addr);
+			    APIC_BASE, address);
 	}
 	if (boot_cpu_physical_apicid == -1U) {
 		boot_cpu_physical_apicid  = read_apic_id();
#3 lore raw

[tip:x86/apic] x86/mm/numa: Open code function early_get_boot_cpu_id()

In reply to Baoquan He
x86/mm/numa: Open code function early_get_boot_cpu_id()
Commit-ID:  a91bf718dbc993ea582cd53c0cb711a0839b4603
Gitweb:     http://git.kernel.org/tip/a91bf718dbc993ea582cd53c0cb711a0839b4603
Author:     Baoquan He <[email protected]>
AuthorDate: Fri, 12 Aug 2016 14:57:12 +0800
Committer:  Ingo Molnar <[email protected]>
CommitDate: Mon, 15 Aug 2016 08:51:54 +0200

x86/mm/numa: Open code function early_get_boot_cpu_id()

Previously early_acpi_boot_init() was called in early_get_boot_cpu_id() to get the value for boot_cpu_physical_apicid. Now early_acpi_boot_init() has been taken out and moved to setup_arch(), the name of early_get_boot_cpu_id() doesn't match its implementation anymore, and only the getting boot-time SMP configuration code was left.

So in this patch we open code it.

Also move the smp_found_config check into default_get_smp_config to simplify code, because both early_get_smp_config() and get_smp_config() call x86_init.mpparse.get_smp_config().

Also remove the redundent CONFIG_X86_MPPARSE #ifdef check when we call early_get_smp_config().

Cc Andy Lutomirski <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Brian Gerst <[email protected]>
Cc Denys Vlasenko <[email protected]>
Cc H. Peter Anvin <[email protected]>
Cc Josh Poimboeuf <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Thomas Gleixner <[email protected]>
---
 arch/x86/kernel/mpparse.c |  3 +++
 arch/x86/kernel/setup.c   |  3 +--
 arch/x86/mm/amdtopology.c | 22 +++++-----------------
 3 files changed, 9 insertions(+), 19 deletions(-)
arch/x86/kernel/mpparse.c +3 -0
index 068c4a9..0f8d204 100644
@@ -499,6 +499,9 @@ void __init default_get_smp_config(unsigned int early)
 {
 	struct mpf_intel *mpf = mpf_found;
 
+	if (!smp_found_config)
+		return;
+
 	if (!mpf)
 		return;
 
arch/x86/kernel/setup.c +1 -2
index 0fa60f5..cbf5634 100644
@@ -1221,8 +1221,7 @@ void __init setup_arch(char **cmdline_p)
 	/*
 	 * get boot-time SMP configuration:
 	 */
-	if (smp_found_config)
-		get_smp_config();
+	get_smp_config();
 
 	prefill_possible_map();
 
arch/x86/mm/amdtopology.c +5 -17
index ba47524..d1c7de0 100644
@@ -52,21 +52,6 @@ static __init int find_northbridge(void)
 	return -ENOENT;
 }
 
-static __init void early_get_boot_cpu_id(void)
-{
-	/*
-	 * need to get the APIC ID of the BSP so can use that to
-	 * create apicid_to_node in amd_scan_nodes()
-	 */
-#ifdef CONFIG_X86_MPPARSE
-	/*
-	 * get boot-time SMP configuration:
-	 */
-	if (smp_found_config)
-		early_get_smp_config();
-#endif
-}
-
 int __init amd_numa_init(void)
 {
 	u64 start = PFN_PHYS(0);
@@ -180,8 +165,11 @@ int __init amd_numa_init(void)
 	cores = 1 << bits;
 	apicid_base = 0;
 
-	/* get the APIC ID of the BSP early for systems with apicid lifting */
-	early_get_boot_cpu_id();
+	/*
+	 * get boot-time SMP configuration:
+	 */
+	early_get_smp_config();
+
 	if (boot_cpu_physical_apicid > 0) {
 		pr_info("BSP APIC ID: %02x\n", boot_cpu_physical_apicid);
 		apicid_base = boot_cpu_physical_apicid;