public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
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: Tue, 18 Jun 2024 11:11:51 -0400	[thread overview]
Message-ID: <20240618151151.GA1153@yaz-khff2.amd.com> (raw)
In-Reply-To: <20240614224420.GGZmzHxDEH2D2TLpjN@fat_crate.local>

On Sat, Jun 15, 2024 at 12:44:20AM +0200, Borislav Petkov wrote:
> On Fri, Jun 14, 2024 at 05:47:36PM -0400, Yazen Ghannam wrote:
> > 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. :/
> 
> I can think of at least three:
> 
> * CPU topology and the initial_apicid sometimes can get programmed wrong by the
> * FW. Nothing new.
> 
> * nr_cpus= - you can enable less CPUs than actually physically present so an MCE
> on a CPU which is not enabled by Linux will be -EINVAL
> 
> * possible_cpus= - pretty much the same thing
> 
> But I haven't actually tried them - am just looking at the code.
> 
> And yes, with the apicid_found boolean it is perfectly clear what's going on.
> 
> And looking at
> 
>   convert_apicid_to_cpu()
> 
> which already does that loop, we probably should talk to tglx whether we can
> simply export that helper.
> 
> And better yet if he's done some more helpful caching of the reverse mapping:
> apicid to CPU number. As part of the topology rewrite. Because then we don't
> need the loop at all.
>

Agreed. Here's another option: topo_lookup_cpuid()

Thanks,
Yazen

  reply	other threads:[~2024-06-18 15:12 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
2024-06-14 22:44           ` Borislav Petkov
2024-06-18 15:11             ` Yazen Ghannam [this message]
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=20240618151151.GA1153@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox