[PATCH 3/4] riscv: ptdump: use seq_puts() in pt_dump_seq_puts() macro

Paul Walmsley pjw at kernel.org
Sat Oct 18 17:21:52 PDT 2025


On Sat, 18 Oct 2025, Josephine Pfeiffer wrote:

> The pt_dump_seq_puts() macro incorrectly uses seq_printf() instead of
> seq_puts(). This is both a performance issue and conceptually wrong,
> as the macro name suggests plain string output (puts) but the
> implementation uses formatted output (printf).
> 
> The macro is used in ptdump.c:301 to output a newline character. Using
> seq_printf() adds unnecessary overhead for format string parsing when
> outputting this constant string.

Hard to accept that it's a performance issue.  But I think you're right 
that generating a newline should be done with seq_puts().

> This bug was introduced in commit 59c4da8640cc ("riscv: Add support to
> dump the kernel page tables") in 2020, which copied the implementation
> pattern from other architectures that had the same bug.
> 
> Fixes: 59c4da8640cc ("riscv: Add support to dump the kernel page tables")
> Signed-off-by: Josephine Pfeiffer <hi at josie.lol>

A better fix would seem to be to just get rid of pt_dump_seq_puts().  It's 
only used once in arch/riscv.

Taking a broader view, both pt_dump_seq_puts() and pt_dump_seq_printf() 
look completely pointless.  Is there any argument for keeping them?


- Paul



More information about the linux-riscv mailing list