Re: [PATCH 1/4 Rebase] x86, MCE: Provide a lock-less memory pool to save error record

From: Borislav Petkov
Date: Wed May 20 2015 - 06:36:19 EST


On Wed, May 20, 2015 at 03:35:35PM -0400, Chen, Gong wrote:
> printk is not safe to use in MCE context. Add a lockless memory
> allocator pool to save error records in MCE context. Issual of those
> records will be delayed to a context safe to do printk. This idea is
> inspired by APEI/GHES driver.
>
> We're very conservative and allocate only two pages for it but since
> we're going to use those pages throughout the system's lifetime, we
> allocate them statically to avoid early boot time allocation woes.
>
> Signed-off-by: Chen, Gong <gong.chen@xxxxxxxxxxxxxxx>
> Link: http://lkml.kernel.org/r/1407830375-11087-1-git-send-email-gong.chen@xxxxxxxxxxxxxxx
> [Boris: rewrite. ]
> Signed-off-by: Borislav Petkov <bp@xxxxxxx>
> ---
> arch/x86/Kconfig | 1 +
> arch/x86/include/uapi/asm/mce.h | 3 +-
> arch/x86/kernel/cpu/mcheck/Makefile | 2 +-
> arch/x86/kernel/cpu/mcheck/mce-genpool.c | 102 ++++++++++++++++++++++++++++++
> arch/x86/kernel/cpu/mcheck/mce-internal.h | 12 ++++
> arch/x86/kernel/cpu/mcheck/mce.c | 8 ++-
> 6 files changed, 125 insertions(+), 3 deletions(-)
> create mode 100644 arch/x86/kernel/cpu/mcheck/mce-genpool.c

Applied, thanks...

> diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
> index e535533d5ab8..ba91777a7ad8 100644
> --- a/arch/x86/kernel/cpu/mcheck/mce.c
> +++ b/arch/x86/kernel/cpu/mcheck/mce.c
> @@ -115,7 +115,7 @@ static void (*quirk_no_way_out)(int bank, struct mce *m, struct pt_regs *regs);
> * CPU/chipset specific EDAC code can register a notifier call here to print
> * MCE errors in a human-readable form.
> */
> -static ATOMIC_NOTIFIER_HEAD(x86_mce_decoder_chain);
> +ATOMIC_NOTIFIER_HEAD(x86_mce_decoder_chain);
>
> /* Do initial initialization of a struct mce */
> void mce_setup(struct mce *m)
> @@ -1688,6 +1688,12 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
> if (mca_cfg.disabled)
> return;
>
> + if (mce_genpool_init()) {
> + mca_cfg.disabled = true;
> + pr_emerg("Couldn't allocate MCE records pool!\n");
> + return;
> + }
> +
> if (__mcheck_cpu_ancient_init(c))
> return;

... and moved this pool initialization right before we assign
machine_check_vector so that we don't do it unnecessarily if we return
earlier due to missing MCA features/MCA not enabled.

--
Regards/Gruss,
Boris.

ECO tip #101: Trim your mails when you reply.
--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/