arm64: Show three registers per line
diff mbox series

Message ID 20210420172245.3679077-1-willy@infradead.org
State Accepted
Commit 0bca3ec846d7a9ea5bddc3b5ab55f6968e690a84
Headers show
Series
  • arm64: Show three registers per line
Related show

Commit Message

Matthew Wilcox April 20, 2021, 5:22 p.m. UTC
Displaying two registers per line takes 15 lines.  That improves to just
10 lines if we display three registers per line, which reduces the amount
of information lost when oopses are cut off.  It stays within 80 columns
and matches x86-64.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 arch/arm64/kernel/process.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

Comments

Kees Cook April 20, 2021, 6:57 p.m. UTC | #1
On Tue, Apr 20, 2021 at 06:22:45PM +0100, Matthew Wilcox (Oracle) wrote:
> Displaying two registers per line takes 15 lines.  That improves to just
> 10 lines if we display three registers per line, which reduces the amount
> of information lost when oopses are cut off.  It stays within 80 columns
> and matches x86-64.
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>

Reviewed-by: Kees Cook <keescook@chromium.org>
David Laight April 21, 2021, 8:31 a.m. UTC | #2
From: Matthew Wilcox
> Sent: 20 April 2021 18:23
>
> Displaying two registers per line takes 15 lines.  That improves to just
> 10 lines if we display three registers per line, which reduces the amount
> of information lost when oopses are cut off.  It stays within 80 columns
> and matches x86-64.
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
>  arch/arm64/kernel/process.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
> index 6e60aa3b5ea9..aff5a2c12297 100644
> --- a/arch/arm64/kernel/process.c
> +++ b/arch/arm64/kernel/process.c
> @@ -294,13 +294,10 @@ void __show_regs(struct pt_regs *regs)
>  	i = top_reg;
> 
>  	while (i >= 0) {
> -		printk("x%-2d: %016llx ", i, regs->regs[i]);
> -		i--;
> +		printk("x%-2d: %016llx", i, regs->regs[i]);
> 
> -		if (i % 2 == 0) {
> -			pr_cont("x%-2d: %016llx ", i, regs->regs[i]);
> -			i--;
> -		}
> +		while (i-- % 3)
> +			pr_cont(" x%-2d: %016llx", i, regs->regs[i]);
> 
>  		pr_cont("\n");
>  	}

I think I'd avoid pr_cont() to avoid 'mishaps' during concurrent oops.
This probably needs something like:
	for (; i >= 0; i -= 3) {
		switch (i) {
		case 0:
			printk("x%-2d: %016llx\n", i, regs->regs[i]);
			break;
		case 1:
			printk("x%-2d: %016llx x%-2d: %016llx\n",
			       i, regs->regs[i], i - 1, regs->regs[i - 1]);
			break;
		default:
			printk("x%-2d: %016llx x%-2d: %016llx x%-2d: %016llx\n",
			       i, regs->regs[i], i - 1, regs->regs[i - 1],
				 i - 2, regs->regs[i - 2]);
			continue;
		}
		break;
	}

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Will Deacon April 22, 2021, 10:35 a.m. UTC | #3
On Tue, Apr 20, 2021 at 06:22:45PM +0100, Matthew Wilcox (Oracle) wrote:
> Displaying two registers per line takes 15 lines.  That improves to just
> 10 lines if we display three registers per line, which reduces the amount
> of information lost when oopses are cut off.  It stays within 80 columns
> and matches x86-64.
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
>  arch/arm64/kernel/process.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)

Acked-by: Will Deacon <will@kernel.org>

Will
Catalin Marinas April 23, 2021, 5:11 p.m. UTC | #4
On Tue, 20 Apr 2021 18:22:45 +0100, Matthew Wilcox (Oracle) wrote:
> Displaying two registers per line takes 15 lines.  That improves to just
> 10 lines if we display three registers per line, which reduces the amount
> of information lost when oopses are cut off.  It stays within 80 columns
> and matches x86-64.

Applied to arm64 (for-next/core), thanks!

[1/1] arm64: Show three registers per line
      https://git.kernel.org/arm64/c/0bca3ec846d7

Patch
diff mbox series

diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
index 6e60aa3b5ea9..aff5a2c12297 100644
--- a/arch/arm64/kernel/process.c
+++ b/arch/arm64/kernel/process.c
@@ -294,13 +294,10 @@  void __show_regs(struct pt_regs *regs)
 	i = top_reg;
 
 	while (i >= 0) {
-		printk("x%-2d: %016llx ", i, regs->regs[i]);
-		i--;
+		printk("x%-2d: %016llx", i, regs->regs[i]);
 
-		if (i % 2 == 0) {
-			pr_cont("x%-2d: %016llx ", i, regs->regs[i]);
-			i--;
-		}
+		while (i-- % 3)
+			pr_cont(" x%-2d: %016llx", i, regs->regs[i]);
 
 		pr_cont("\n");
 	}