[PATCH 1/2] powerpc: Use seq_buf to avoid pr_cont() in __die()
Christophe Leroy
christophe.leroy at c-s.fr
Tue Jan 8 23:18:05 AEDT 2019
Le 08/01/2019 à 13:04, Michael Ellerman a écrit :
> Using pr_cont() risks having our output interleaved with other output
> from other CPUs. Instead use a seq_buf to construct the line and then
> print it as a whole.
Why not simply doing a single printk() or similar on the same model as
X86 for instance ?
(https://elixir.bootlin.com/linux/v5.0-rc1/source/arch/x86/kernel/dumpstack.c#L368)
Christophe
>
> Signed-off-by: Michael Ellerman <mpe at ellerman.id.au>
> ---
> arch/powerpc/kernel/traps.c | 23 ++++++++++++++++-------
> 1 file changed, 16 insertions(+), 7 deletions(-)
>
> diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
> index 64936b60d521..431a86d3f772 100644
> --- a/arch/powerpc/kernel/traps.c
> +++ b/arch/powerpc/kernel/traps.c
> @@ -38,6 +38,7 @@
> #include <linux/kdebug.h>
> #include <linux/ratelimit.h>
> #include <linux/context_tracking.h>
> +#include <linux/seq_buf.h>
> #include <linux/smp.h>
> #include <linux/console.h>
> #include <linux/kmsg_dump.h>
> @@ -255,26 +256,34 @@ NOKPROBE_SYMBOL(oops_end);
>
> static int __die(const char *str, struct pt_regs *regs, long err)
> {
> + char buf[128]; /* enough for all flags and a long platform name */
> + struct seq_buf s;
> +
> + seq_buf_init(&s, buf, sizeof(buf));
> +
> printk("Oops: %s, sig: %ld [#%d]\n", str, err, ++die_counter);
>
> if (IS_ENABLED(CONFIG_CPU_LITTLE_ENDIAN))
> - printk("LE ");
> + seq_buf_puts(&s, "LE ");
> else
> - printk("BE ");
> + seq_buf_puts(&s, "BE ");
>
> if (IS_ENABLED(CONFIG_PREEMPT))
> - pr_cont("PREEMPT ");
> + seq_buf_puts(&s, "PREEMPT ");
>
> if (IS_ENABLED(CONFIG_SMP))
> - pr_cont("SMP NR_CPUS=%d ", NR_CPUS);
> + seq_buf_printf(&s, "SMP NR_CPUS=%d ", NR_CPUS);
>
> if (debug_pagealloc_enabled())
> - pr_cont("DEBUG_PAGEALLOC ");
> + seq_buf_puts(&s, "DEBUG_PAGEALLOC ");
>
> if (IS_ENABLED(CONFIG_NUMA))
> - pr_cont("NUMA ");
> + seq_buf_puts(&s, "NUMA ");
> +
> + if (ppc_md.name)
> + seq_buf_puts(&s, ppc_md.name);
>
> - pr_cont("%s\n", ppc_md.name ? ppc_md.name : "");
> + printk("%s\n", buf);
>
> if (notify_die(DIE_OOPS, str, regs, err, 255, SIGSEGV) == NOTIFY_STOP)
> return 1;
>
More information about the Linuxppc-dev
mailing list