From: "Zhang, Rui" <rui.zhang@intel.com>
To: "Brown, Len" <len.brown@intel.com>,
"kvijayab@amd.com" <kvijayab@amd.com>,
"rafael@kernel.org" <rafael@kernel.org>,
"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
"mingo@redhat.com" <mingo@redhat.com>,
"pavel@ucw.cz" <pavel@ucw.cz>,
"tglx@linutronix.de" <tglx@linutronix.de>,
"Mario.Limonciello@amd.com" <Mario.Limonciello@amd.com>,
"bp@alien8.de" <bp@alien8.de>
Cc: "hpa@zytor.com" <hpa@zytor.com>,
"suravee.suthikulpanit@amd.com" <suravee.suthikulpanit@amd.com>,
"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
"bpetkov@amd.com" <bpetkov@amd.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"x86@kernel.org" <x86@kernel.org>,
"santosh.shukla@amd.com" <santosh.shukla@amd.com>
Subject: Re: [PATCH] x86/acpi/boot: Do not register processors that cannot be onlined for x2apic
Date: Fri, 30 Dec 2022 13:23:01 +0000 [thread overview]
Message-ID: <0e299876606352ca868d7b71991c66a1c1d361cb.camel@intel.com> (raw)
In-Reply-To: <20221228114558.3504-1-kvijayab@amd.com>
Hi, Kishon,
On Wed, 2022-12-28 at 11:45 +0000, Kishon Vijay Abraham I wrote:
> 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.
ACPI spec 6.4 is released, so better to refer to the latest ACPI spec,
say,
https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/05_ACPI_Software_Programming_Model/ACPI_Software_Programming_Model.html#processor-local-x2apic-structure
or
https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/05_ACPI_Software_Programming_Model/ACPI_Software_Programming_Model.html#local-apic-flags
> 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.
Thanks for catching this. I had the same question when I was reading
this piece of code recently.
> Make sure Linux parses both "enabled" and "online capable" flags for
> x2APIC to correctly determine if the processor is usable.
A dumb question, the Local SAPIC structure also uses the Local APIC
flags, and should we add the same check in acpi_parse_sapic()?
> Fixes: 7237d3de78ff ("x86, ACPI: add support for x2apic ACPI
> extensions")
I'm not sure if this "Fixes" tag is accurate or not.
Checking for the Local APIC flags was just added last year, by commit
aa06e20f1be6 ("x86/ACPI: Don't add CPUs that are not online capable"),
and the variable 'acpi_support_online_capable' used in this patch is
also introduced by that commit. So, to me, this patch fixes a gap in aa
06e20f1be6, rather than the original x2apic support commit.
thanks,
rui
> 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;
>
> /*
next prev parent reply other threads:[~2022-12-30 13:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2022-12-30 13:47 ` Rafael J. Wysocki
2023-01-03 21:24 ` Luck, Tony
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0e299876606352ca868d7b71991c66a1c1d361cb.camel@intel.com \
--to=rui.zhang@intel.com \
--cc=Mario.Limonciello@amd.com \
--cc=bp@alien8.de \
--cc=bpetkov@amd.com \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=kvijayab@amd.com \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pavel@ucw.cz \
--cc=rafael@kernel.org \
--cc=santosh.shukla@amd.com \
--cc=suravee.suthikulpanit@amd.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox