public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Catalin Marinas <catalin.marinas@arm.com>
To: David Sauerwein <dssauerw@amazon.de>
Cc: Will Deacon <will@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, nh-open-source@amazon.com
Subject: Re: [PATCH] arm64: Fix garbled logs caused by race between multiple stack traces
Date: Wed, 6 May 2026 11:58:44 +0100	[thread overview]
Message-ID: <afse5Ld52p7DmidK@arm.com> (raw)
In-Reply-To: <20260430084738.73909-1-dssauerw@amazon.de>

On Thu, Apr 30, 2026 at 08:47:38AM +0000, David Sauerwein wrote:
> When multiple stack traces are printed at the same time, the lines that
> contain register values may get split into multiple separate lines.
> Some stray empty lines may appear as well.
> 
> [ 2013.814455] ------------[ cut here ]------------
> [ 2013.814455] ------------[ cut here ]------------
> [ 2013.814459] WARNING: CPU: 12 PID: 626 at src/arch/arm64/kvm/../../../virt/kvm/kvm_main.c:3860 mark_page_dirty_in_slot+0x5c/0xd8
> [ 2013.814457] WARNING: CPU: 3 PID: 620 at src/arch/arm64/kvm/../../../virt/kvm/kvm_main.c:3860 mark_page_dirty_in_slot+0x5c/0xd8
> [...]
> [ 2013.814483] x29: ffff8000873b3b10
> [ 2013.814484] x29: ffff800083fd3b10
> [ 2013.814484]  x28: ffff00001d71e300 x27: 0000000000000001
> [ 2013.814486] x26: ffff800080c63b80 x25: ffff800080c63000
> [ 2013.814487]  x28: ffff00001d71a100 x27: 0000000000000001
> [ 2013.814488]  x24: 0000000000401b14
> [ 2013.814489]
> [ 2013.814489] x26: ffff800080f5bb80 x25: ffff800080f5b000
> [ 2013.814491]
> [ 2013.814491] x23: ffff0000117b2000 x22: ffff00001e22bd88 x21: 0000ff9cc1b14000
> [ 2013.814493]  x24: 0000000000402230
> [ 2013.814494]
> [ 2013.814495] x20: ffff800080c63000
> [ 2013.814495] x23: ffff00001d916f00
> [ 2013.814496]  x19: 0000000000000000 x18: ffff8000808c1660
> [ 2013.814497] x17: 0000000000000000
> [...]
[...]
> @@ -235,12 +235,22 @@ void __show_regs(struct pt_regs *regs)
>  	i = top_reg;
>  
>  	while (i >= 0) {
> -		printk("x%-2d: %016llx", i, regs->regs[i]);
> +		/*
> +		 * Buffer is big enough to hold the output for 3 register
> +		 * plus some extra.
> +		 */
> +		char buf[80];
> +		int len;
> +
> +		len = scnprintf(buf, sizeof(buf), "x%-2d: %016llx",
> +				i, regs->regs[i]);
>  
>  		while (i-- % 3)
> -			pr_cont(" x%-2d: %016llx", i, regs->regs[i]);
> +			len += scnprintf(buf + len, sizeof(buf) - len,
> +					 " x%-2d: %016llx",
> +					 i, regs->regs[i]);
>  
> -		pr_cont("\n");
> +		printk("%s\n", buf);

While the above does solve the line splitting, the trace is still not
that readable as we get line interleaving.

I wonder whether we could do something like dump_stack_lvl() at the
show_regs() level to synchronise the printing. If that works, we
wouldn't need the above change (which isn't incorrect but maybe we can
do better).

Thanks.

-- 
Catalin

      reply	other threads:[~2026-05-06 10:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-30  8:47 [PATCH] arm64: Fix garbled logs caused by race between multiple stack traces David Sauerwein
2026-05-06 10:58 ` Catalin Marinas [this message]

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=afse5Ld52p7DmidK@arm.com \
    --to=catalin.marinas@arm.com \
    --cc=dssauerw@amazon.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=nh-open-source@amazon.com \
    --cc=will@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