[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231122182451.GHZV5Hc/49OYomyejc@fat_crate.local>
Date: Wed, 22 Nov 2023 19:24:51 +0100
From: Borislav Petkov <bp@...en8.de>
To: Yazen Ghannam <yazen.ghannam@....com>
Cc: linux-edac@...r.kernel.org, linux-kernel@...r.kernel.org,
tony.luck@...el.com, x86@...nel.org, Avadhut.Naik@....com,
Smita.KoralahalliChannabasappa@....com,
amd-gfx@...ts.freedesktop.org, linux-trace-kernel@...r.kernel.org
Subject: Re: [PATCH 02/20] x86/mce: Define mce_setup() helpers for global and
per-CPU fields
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?
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
Powered by blists - more mailing lists