From: Yazen Ghannam <yazen.ghannam@amd.com>
To: Borislav Petkov <bp@alien8.de>
Cc: yazen.ghannam@amd.com, linux-edac@vger.kernel.org,
linux-kernel@vger.kernel.org, tony.luck@intel.com,
x86@kernel.org, Avadhut.Naik@amd.com,
Smita.KoralahalliChannabasappa@amd.com,
amd-gfx@lists.freedesktop.org,
linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH 02/20] x86/mce: Define mce_setup() helpers for global and per-CPU fields
Date: Mon, 27 Nov 2023 09:52:35 -0500 [thread overview]
Message-ID: <c822cc63-3ff4-4edd-9416-015c52f9fb5b@amd.com> (raw)
In-Reply-To: <20231122182451.GHZV5Hc/49OYomyejc@fat_crate.local>
On 11/22/2023 1:24 PM, Borislav Petkov wrote:
> On Sat, Nov 18, 2023 at 01:32:30PM -0600, Yazen Ghannam wrote:
>> +void mce_setup_global(struct mce *m)
>
> We usually call those things "common":
>
> mce_setup_common().
>
>> +{
>> + memset(m, 0, sizeof(struct mce));
>> +
>> + m->cpuid = cpuid_eax(1);
>> + m->cpuvendor = boot_cpu_data.x86_vendor;
>> + m->mcgcap = __rdmsr(MSR_IA32_MCG_CAP);
>> + /* need the internal __ version to avoid deadlocks */
>> + m->time = __ktime_get_real_seconds();
>> +}
>> +
>> +void mce_setup_per_cpu(struct mce *m)
>
> And call this
>
> mce_setup_for_cpu(unsigned int cpu, struct mce *m);
>
> so that it doesn't look like some per_cpu helper.
>
> And yes, you should supply the CPU number as an argument. Because
> otherwise, when you look at your next change:
>
>
> + mce_setup_global(&m);
> + m.cpu = m.extcpu = cpu;
> + mce_setup_per_cpu(&m);
>
> This contains the "hidden" requirement that m.extcpu happens *always*
> *before* the mce_setup_per_cpu() call and that is flaky and error prone.
>
> So make that:
>
> mce_setup_common(&m);
> mce_setup_for_cpu(m.extcpu, &m);
>
> and do m.cpu = m.extcpu = cpu inside the second function.
>
> And then it JustWorks(tm) and you can't "forget" assigning m.extcpu and
> there's no subtlety.
>
> Ok?
>
Yep, understood. Thanks!
-Yazen
next prev parent reply other threads:[~2023-11-27 14:52 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-18 19:32 [PATCH 00/20] MCA Updates Yazen Ghannam
2023-11-18 19:32 ` [PATCH 01/20] x86/mce/inject: Clear test status value Yazen Ghannam
2023-11-18 19:32 ` [PATCH 02/20] x86/mce: Define mce_setup() helpers for global and per-CPU fields Yazen Ghannam
2023-11-22 18:24 ` Borislav Petkov
2023-11-27 14:52 ` Yazen Ghannam [this message]
2023-11-18 19:32 ` [PATCH 03/20] x86/mce: Use mce_setup() helpers for apei_smca_report_x86_error() Yazen Ghannam
2023-11-22 18:28 ` Borislav Petkov
2023-11-27 14:53 ` Yazen Ghannam
2023-11-18 19:32 ` [PATCH 04/20] x86/mce/amd, EDAC/mce_amd: Move long names to decoder module Yazen Ghannam
2023-11-18 19:32 ` [PATCH 05/20] x86/mce/amd: Use helper for UMC bank type check Yazen Ghannam
2023-11-27 11:43 ` Borislav Petkov
2023-11-27 15:00 ` Yazen Ghannam
2023-11-18 19:32 ` [PATCH 06/20] x86/mce/amd: Use helper for GPU UMC bank type checks Yazen Ghannam
2023-11-27 11:46 ` Borislav Petkov
2023-11-27 15:12 ` Yazen Ghannam
2023-11-18 19:32 ` [PATCH 07/20] x86/mce/amd: Use fixed bank number for quirks Yazen Ghannam
2023-11-18 19:32 ` [PATCH 08/20] x86/mce/amd: Look up bank type by IPID Yazen Ghannam
2023-11-18 19:32 ` [PATCH 09/20] x86/mce/amd: Clean up SMCA configuration Yazen Ghannam
2023-11-18 19:32 ` [PATCH 10/20] x86/mce/amd: Prep DFR handler before enabling banks Yazen Ghannam
2023-11-18 19:32 ` [PATCH 11/20] x86/mce/amd: Simplify DFR handler setup Yazen Ghannam
2023-11-18 19:32 ` [PATCH 12/20] x86/mce/amd: Clean up enable_deferred_error_interrupt() Yazen Ghannam
2023-11-18 19:32 ` [PATCH 13/20] x86/mce: Unify AMD THR handler with MCA Polling Yazen Ghannam
2023-11-18 19:32 ` [PATCH 14/20] x86/mce/amd: Unify AMD DFR " Yazen Ghannam
2023-11-18 19:32 ` [PATCH 15/20] x86/mce: Skip AMD threshold init if no threshold banks found Yazen Ghannam
2023-11-18 19:32 ` [PATCH 16/20] x86/mce/amd: Support SMCA Corrected Error Interrupt Yazen Ghannam
2023-11-18 19:32 ` [PATCH 17/20] x86/mce: Add wrapper for struct mce to export vendor specific info Yazen Ghannam
2023-11-18 19:32 ` [PATCH 18/20] x86/mce, EDAC/mce_amd: Add support for new MCA_SYND{1,2} registers Yazen Ghannam
2023-11-18 19:32 ` [PATCH 19/20] x86/mce/apei: Handle variable register array size Yazen Ghannam
2023-11-18 19:32 ` [PATCH 20/20] EDAC/mce_amd: Add support for FRU Text in MCA 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=c822cc63-3ff4-4edd-9416-015c52f9fb5b@amd.com \
--to=yazen.ghannam@amd.com \
--cc=Avadhut.Naik@amd.com \
--cc=Smita.KoralahalliChannabasappa@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=bp@alien8.de \
--cc=linux-edac@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-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