From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3379333064C for ; Mon, 5 Jan 2026 17:11:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767633086; cv=none; b=W2qkQyOiOI2m8UpTCuFh7RL32Jf85kodTtF4oeomDdjvCTUd4Dv9CwnpOK4Qk+UEeDWIHJ4qZavN268XDAbtdX56segJa5QyDkL4APO2uKAxmb+I8KgxDVkfh1Sh9RLS0wqSxDtkYc+r7nOxE15fwkMtQ1DxTsLZUQKc3Lh+yRw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767633086; c=relaxed/simple; bh=4IJW8PtwfE62HLVFioMlKVN/Aa3YduhpWOed1uWROUw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=nYjkhgeybryThXNWCyUcN4Za2S3cpwBWNh3CwZP9hoWFHUTNd/hmlPCp2905vjOyy4b0nO5PGBYkrCDodU/KjvMDQhmAfwOewWNpe7ag/9Zj7PfFCg5sK/6f+w7BVcoZGlvsydbcPfQNhdJ+dGkD0UYEYhTcBGHm0yuXMpiK4pI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rC3cuSGx; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rC3cuSGx" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3EB7C116D0; Mon, 5 Jan 2026 17:11:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767633085; bh=4IJW8PtwfE62HLVFioMlKVN/Aa3YduhpWOed1uWROUw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=rC3cuSGxXTz4TkHwyqP6XTCF+pBVrzO3YP/Rwbt7RRRYU4TBI3S5UNUAoKkdspEAc /o3PWdu51kAS9/RkCiQZPP7CPaEnm/RhU5skhirfEvObCnOxvc7F9bTbkNa+vF5+JJ g2zrhS4y5s/wFk/5tCcN09ezjm2GqcZyLswtkSh9WNuDI6PG/tCueAWvzg86YUAqUR 3WEeCbXUUE5suEsVVVjx8VOp3ihuMiIFq3dC+aplBVOCL2roX08nkEuo6GjJXF/LjL /XahwB6QVK9icCfcXcTYcs0ITDPFSBil9Ttg2O1oOm4ig1jxkXGFHqXl7oNUa5UoHJ PnexfcIfYHxiQ== Date: Mon, 5 Jan 2026 17:11:21 +0000 From: Will Deacon To: Josephine Pfeiffer Cc: catalin.marinas@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/4] arm64: ptdump: use seq_puts() in pt_dump_seq_puts() macro Message-ID: References: <20251018170416.3355249-1-hi@josie.lol> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20251018170416.3355249-1-hi@josie.lol> On Sat, Oct 18, 2025 at 07:04:16PM +0200, 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). What's conceptually wrong with using printf() to print an unformatted string? There are loads of printk() calls that do that and I think it's fine. > arch/arm64/mm/ptdump.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/arm64/mm/ptdump.c b/arch/arm64/mm/ptdump.c > index ab9899ca1e5f..a35fcd62bf75 100644 > --- a/arch/arm64/mm/ptdump.c > +++ b/arch/arm64/mm/ptdump.c > @@ -35,7 +35,7 @@ > #define pt_dump_seq_puts(m, fmt) \ > ({ \ > if (m) \ > - seq_printf(m, fmt); \ > + seq_puts(m, fmt); \ > }) Given that this macro has exactly one caller and it isn't a fast path, wouldn't it be better to go the other way around and remove this helper in favour of using pt_dump_seq_printf() everywhere? i.e. something like the diff below Will --->8 diff --git a/arch/arm64/mm/ptdump.c b/arch/arm64/mm/ptdump.c index ab9899ca1e5f..8a03b2c9f88b 100644 --- a/arch/arm64/mm/ptdump.c +++ b/arch/arm64/mm/ptdump.c @@ -32,12 +32,6 @@ seq_printf(m, fmt, ##args); \ }) -#define pt_dump_seq_puts(m, fmt) \ -({ \ - if (m) \ - seq_printf(m, fmt); \ -}) - static const struct ptdump_prot_bits pte_bits[] = { { .mask = PTE_VALID, @@ -232,7 +226,7 @@ void note_page(struct ptdump_state *pt_st, unsigned long addr, int level, if (st->current_prot && pg_level[st->level].bits) dump_prot(st, pg_level[st->level].bits, pg_level[st->level].num); - pt_dump_seq_puts(st->seq, "\n"); + pt_dump_seq_printf(st->seq, "\n"); if (addr >= st->marker[1].start_address) { st->marker++;