public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/acpi/boot: Do not register processors that cannot be onlined for x2apic
@ 2022-12-28 11:45 Kishon Vijay Abraham I
  2022-12-30 13:23 ` Zhang, Rui
  0 siblings, 1 reply; 4+ messages in thread
From: Kishon Vijay Abraham I @ 2022-12-28 11:45 UTC (permalink / raw)
  To: Rafael J. Wysocki, Len Brown, Pavel Machek, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Dave Hansen
  Cc: x86, H. Peter Anvin, linux-pm, linux-kernel, Santosh Shukla,
	Suravee Suthikulpanit, Borislav Petkov, Kishon Vijay Abraham I

Section 5.2.12.12 Processor Local x2APIC Structure in the ACPI v6.3
spec mandates that both "enabled" and "online capable" Local APIC Flags
should be used to determine if the processor is usable or not.

However, Linux doesn't use the "online capable" flag for x2APIC to
determine if the processor is usable. As a result, cpu_possible_mask has
incorrect value and results in more memory getting allocated for per_cpu
variables than it is going to be used.

Make sure Linux parses both "enabled" and "online capable" flags for
x2APIC to correctly determine if the processor is usable.

Fixes: 7237d3de78ff ("x86, ACPI: add support for x2apic ACPI extensions")
Reviewed-by: Borislav Petkov (AMD) <bp@alien8.de>
Signed-off-by: Kishon Vijay Abraham I <kvijayab@amd.com>
---
 arch/x86/kernel/acpi/boot.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index 907cc98b1938..518bda50068c 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -188,6 +188,17 @@ static int acpi_register_lapic(int id, u32 acpiid, u8 enabled)
 	return cpu;
 }
 
+static bool __init acpi_is_processor_usable(u32 lapic_flags)
+{
+	if (lapic_flags & ACPI_MADT_ENABLED)
+		return true;
+
+	if (acpi_support_online_capable && (lapic_flags & ACPI_MADT_ONLINE_CAPABLE))
+		return true;
+
+	return false;
+}
+
 static int __init
 acpi_parse_x2apic(union acpi_subtable_headers *header, const unsigned long end)
 {
@@ -212,6 +223,10 @@ acpi_parse_x2apic(union acpi_subtable_headers *header, const unsigned long end)
 	if (apic_id == 0xffffffff)
 		return 0;
 
+	/* don't register processors that cannot be onlined */
+	if (!acpi_is_processor_usable(processor->lapic_flags))
+		return 0;
+
 	/*
 	 * We need to register disabled CPU as well to permit
 	 * counting disabled CPUs. This allows us to size
@@ -250,9 +265,7 @@ acpi_parse_lapic(union acpi_subtable_headers * header, const unsigned long end)
 		return 0;
 
 	/* don't register processors that can not be onlined */
-	if (acpi_support_online_capable &&
-	    !(processor->lapic_flags & ACPI_MADT_ENABLED) &&
-	    !(processor->lapic_flags & ACPI_MADT_ONLINE_CAPABLE))
+	if (!acpi_is_processor_usable(processor->lapic_flags))
 		return 0;
 
 	/*
-- 
2.34.1


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

end of thread, other threads:[~2023-01-03 21:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-28 11:45 [PATCH] x86/acpi/boot: Do not register processors that cannot be onlined for x2apic Kishon Vijay Abraham I
2022-12-30 13:23 ` Zhang, Rui
2022-12-30 13:47   ` Rafael J. Wysocki
2023-01-03 21:24     ` Luck, Tony

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox