From: Yazen Ghannam <yazen.ghannam@amd.com>
To: Borislav Petkov <bp@alien8.de>
Cc: linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org,
tony.luck@intel.com, x86@kernel.org, avadhut.naik@amd.com,
john.allen@amd.com
Subject: Re: [PATCH 3/3] x86/mce: Use mce_prep_record() helpers for apei_smca_report_x86_error()
Date: Fri, 14 Jun 2024 17:47:36 -0400 [thread overview]
Message-ID: <20240614214736.GA726880@yaz-khff2.amd.com> (raw)
In-Reply-To: <20240603165530.GFZl31gtuABwpe1svP@fat_crate.local>
On Mon, Jun 03, 2024 at 06:55:30PM +0200, Borislav Petkov wrote:
> On Mon, Jun 03, 2024 at 10:34:10AM -0400, Yazen Ghannam wrote:
[...]
> > This is to catch the case where there was no break from the loop.
>
> If the CPU is possible != whether there was a apicid match.
>
> Here's how you do that and I'd let you figure out why yours doesn't
> always work:
>
I don't see why it won't work. If there is no break, then the iterator
ends by setting the variable past the last valid value.
For example, I ran this on a system with 512 CPUs:
unsigned int cpu;
/* Loops over CPUs 0-511. */
for_each_possible_cpu(cpu)
pr_info("loop: cpu=%d\n", cpu);
/* CPU is now set to 512. */
pr_info("final: cpu=%d\n", cpu);
/* CPU 512 is not possible. */
pr_info("CPU %d is %s possible\n", cpu, cpu_possible(cpu) ? "" : "not");
But...I like your suggestion as it is much more explicit. And I might be
missing something. :/
> diff --git a/arch/x86/kernel/cpu/mce/apei.c b/arch/x86/kernel/cpu/mce/apei.c
> index 0cbadfaf2400..3885fe05f01e 100644
> --- a/arch/x86/kernel/cpu/mce/apei.c
> +++ b/arch/x86/kernel/cpu/mce/apei.c
> @@ -66,6 +66,7 @@ EXPORT_SYMBOL_GPL(apei_mce_report_mem_error);
> int apei_smca_report_x86_error(struct cper_ia_proc_ctx *ctx_info, u64 lapic_id)
> {
> const u64 *i_mce = ((const u64 *) (ctx_info + 1));
> + bool apicid_found = false;
> unsigned int cpu;
> struct mce m;
>
> @@ -98,11 +99,13 @@ int apei_smca_report_x86_error(struct cper_ia_proc_ctx *ctx_info, u64 lapic_id)
> return -EINVAL;
>
> for_each_possible_cpu(cpu) {
> - if (cpu_data(cpu).topo.initial_apicid == lapic_id)
> + if (cpu_data(cpu).topo.initial_apicid == lapic_id) {
> + apicid_found = true;
> break;
> + }
> }
>
> - if (!cpu_possible(cpu))
> + if (!apicid_found)
> return -EINVAL;
>
> mce_prep_record_common(&m);
>
>
Would you like me to send another revision with this change? Do you have
any other comments?
Thanks,
Yazen
next prev parent reply other threads:[~2024-06-14 21:47 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-21 12:54 [PATCH 0/3] Rework mce_setup() Yazen Ghannam
2024-05-21 12:54 ` [PATCH 1/3] x86/mce: Rename mce_setup() to mce_prep_record() Yazen Ghannam
2024-05-21 12:54 ` [PATCH 2/3] x86/mce: Define mce_prep_record() helpers for common and per-CPU fields Yazen Ghannam
2024-05-21 12:54 ` [PATCH 3/3] x86/mce: Use mce_prep_record() helpers for apei_smca_report_x86_error() Yazen Ghannam
2024-05-29 17:28 ` Borislav Petkov
2024-06-03 14:34 ` Yazen Ghannam
2024-06-03 16:55 ` Borislav Petkov
2024-06-14 21:47 ` Yazen Ghannam [this message]
2024-06-14 22:44 ` Borislav Petkov
2024-06-18 15:11 ` Yazen Ghannam
2024-06-18 17:24 ` Yazen Ghannam
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=20240614214736.GA726880@yaz-khff2.amd.com \
--to=yazen.ghannam@amd.com \
--cc=avadhut.naik@amd.com \
--cc=bp@alien8.de \
--cc=john.allen@amd.com \
--cc=linux-edac@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tony.luck@intel.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.