[PATCH v3 2/3] m68k: Avoid pointless recursion in debug console rendering

Finn Thain posted 3 patches 8 months, 3 weeks ago
[PATCH v3 2/3] m68k: Avoid pointless recursion in debug console rendering
Posted by Finn Thain 8 months, 3 weeks ago
The recursive call to console_putc to effect a carriage return is
needlessly slow and complicated. Instead, just clear the column counter
directly. Setup %a0 earlier to avoid a repeated comparison.

Signed-off-by: Finn Thain <fthain@linux-m68k.org>
---
 arch/m68k/kernel/head.S | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/arch/m68k/kernel/head.S b/arch/m68k/kernel/head.S
index 9bd8adaa756d..49e079b0d0b5 100644
--- a/arch/m68k/kernel/head.S
+++ b/arch/m68k/kernel/head.S
@@ -3533,19 +3533,16 @@ func_start	console_putc,%a0/%a1/%d0-%d7
 	tstl	%pc@(L(console_font))
 	jeq	L(console_exit)
 
+	lea	%pc@(L(console_globals)),%a0
+
 	/* Output character in d7 on console.
 	 */
 	movel	ARG1,%d7
 	cmpib	#'\n',%d7
-	jbne	1f
+	jne	L(console_not_lf)
 
-	/* A little safe recursion is good for the soul */
-	console_putc	#'\r'
-1:
-	lea	%pc@(L(console_globals)),%a0
+	clrl	%a0@(Lconsole_struct_cur_column)	/* implicit \r */
 
-	cmpib	#10,%d7
-	jne	L(console_not_lf)
 	movel	%a0@(Lconsole_struct_cur_row),%d0
 	movel	%a0@(Lconsole_struct_num_rows),%d1
 	cmpl	%d1,%d0
-- 
2.45.3
Re: [PATCH v3 2/3] m68k: Avoid pointless recursion in debug console rendering
Posted by Geert Uytterhoeven 5 months, 1 week ago
On Thu, 27 Mar 2025 at 23:44, Finn Thain <fthain@linux-m68k.org> wrote:
> The recursive call to console_putc to effect a carriage return is
> needlessly slow and complicated. Instead, just clear the column counter
> directly. Setup %a0 earlier to avoid a repeated comparison.
>
> Signed-off-by: Finn Thain <fthain@linux-m68k.org>

Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
i.e. will queue in the m68k tree for v6.17.

Gr{oetje,eeting}s,

                        Geert


--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds