From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 29BFAC83F1B for ; Fri, 11 Jul 2025 19:24:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7358E6B0092; Fri, 11 Jul 2025 15:24:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 70CCF6B0093; Fri, 11 Jul 2025 15:24:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 649966B0096; Fri, 11 Jul 2025 15:24:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 557D66B0092 for ; Fri, 11 Jul 2025 15:24:55 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id CB4121406CC for ; Fri, 11 Jul 2025 19:24:54 +0000 (UTC) X-FDA: 83652961308.06.805CE28 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf13.hostedemail.com (Postfix) with ESMTP id A13932000B for ; Fri, 11 Jul 2025 19:24:52 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=QXOczNP4 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1752261893; a=rsa-sha256; cv=none; b=pYBSv+oWBsrtH4dBtKFe5g+aSPdHVBaECVM5H6KWRFuyH2oU9iQdd7aFL+5VoGHVdm2V/B 8Fg6IeiVkXaG1JGFjw9BvUdEGbN34PXJF+IvfUatceK69GaZNFD0/0cFaP3o/IhGkRrz3k DW6lAsL96MEdTQEUyAHyk6W1SreoTn4= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=QXOczNP4; dmarc=none; spf=none (imf13.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1752261893; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=An5C+0gDMIwtsouH1107rmybVZLRBPlp9Sd8kmMnl+E=; b=BbcmmUGESPa6ayvJW8muS3F3HqraPUHE69a5pZwfwYN+XQORq0E2T0yYBxkDTjpDgDykUv u8gdmtT1s8NXaPu79Nzk48a/DbjkySW4N0qSNSpEY08X/sGy/J0fA8VB2UV9Xpt3VaL5WA WCrz3Ai4dzMI8BXpAjVfzMmJLAgQ5aI= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=An5C+0gDMIwtsouH1107rmybVZLRBPlp9Sd8kmMnl+E=; b=QXOczNP4OEoHhuOgaALaPU/URb uClAjhReAwuuNp4RHmzvF4FCxmQSqkqctqFHgBdZrIno7bvCXciVbei9xOICMBgiC/qSDxN7LAXQg reF2vX8XfxXR4UkJwFpYO1eatqqbaNqfui7mulMYMbtQOe5YEJUryNK8+s6uTYpTAAE/ONI9UMKLS G3F2BFNF5t6AZj0fnrtlSi7S2E9Hyz1VJZcYN6lf/VGcVLqicgOi0JTef4nlx0EHCwh8/+jIsRBZw 18XZpGLirqupNWPRMuSN7/crhMbhxLL3Gn2U14YcB2mZ5WPP/xYDhYFoms3Z6BDhexGeQt9rAI6a0 MhD34mYw==; Received: from willy by casper.infradead.org with local (Exim 4.98.2 #2 (Red Hat Linux)) id 1uaJMW-0000000E8fs-1liL; Fri, 11 Jul 2025 19:24:48 +0000 Date: Fri, 11 Jul 2025 20:24:48 +0100 From: Matthew Wilcox To: Linus Torvalds Cc: David Laight , Martin Uecker , Alejandro Colomar , linux-mm@kvack.org, linux-hardening@vger.kernel.org, Kees Cook , Christopher Bazley , shadow <~hallyn/shadow@lists.sr.ht>, linux-kernel@vger.kernel.org, Andrew Morton , kasan-dev@googlegroups.com, Dmitry Vyukov , Alexander Potapenko , Marco Elver , Christoph Lameter , David Rientjes , Vlastimil Babka , Roman Gushchin , Harry Yoo , Andrew Clayton , Rasmus Villemoes , Michal Hocko , Al Viro , Sam James , Andrew Pinski Subject: Re: [RFC v5 6/7] sprintf: Add [v]sprintf_array() Message-ID: References: <04c1e026a67f1609167e834471d0f2fe977d9cb0.1752182685.git.alx@kernel.org> <28c8689c7976b4755c0b5c2937326b0a3627ebf6.camel@gmail.com> <20250711184541.68d770b9@pumpkin> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: ae9y4z6kgpw7xcst5a9um4ptx3znmwbf X-Rspamd-Queue-Id: A13932000B X-HE-Tag: 1752261892-663392 X-HE-Meta: U2FsdGVkX1+kATLRRdUOTJu9ifAMbuCCqyEAS8GbBazV06YkRQegG1Q2k1eIr2WT98+190THhNi9SHgd9+0WNwxkXyoEj5eUSKeeXr/uvZifbyoGRobmi5AUieYlCxqDMcOsRslPksJoE0BmHwhFRAnyDPAp5m/WchnQrYxXDXfVoOOKus7keXaaNjfCPEyd/d4jSf/pTJw16vCN+NP8spe2Ao7QwswN6QVCSpbF6wQ1/vi7rJNSdqafYZMjO+rCqMpRSUSeAfK452Q9b5wf+q203cIECR9GmUjMhFrebFc3WSy1qCa3DIXQTbt/9PiE6LHp0Xl4+KI0MjeYMjwaSezAB9bOjDYydvyIW8Qz8lwUvX1hfkATF9fbXV7c5RZ0Niy68O76H9Zk1XaRBd6KqNMBoqWpkkZNBOQX3XlXmHLy8hRV+s3a/Ljh5/zpNxpr8EBx8n42b7fEtKnpz/EsQCI1ZHxJkEyUlQ2VUPH1rhjILNdfF6XZU7WYVjBHam81gJnlNGT4d5oqOyB89Fk+sin4NFJyWPOnSzyHjbn6C5pT9g3xi75rMiG6HlKGPAuLTtQw6FE5URXw+SzUEAsrU/OKByyN3Bj/tztGMhiRCOCaiRlCLIG45Xm9qJs8n5Bazlk7YEa/wv67yX50VOkfRtJa811Xf17Dac0W/jMRP2OuRYlOs57lT5SAqQlMVX0lGaACEtxcVuyLoQHgI1QxX0TPFvBa5qO05/pGc2ifx4Xszjx7PZWSS0NGz215vE2BYa37GE/ao26IUFRpjy6T75qWZ7kh2dViqlc+JG0QmcVQ9Z+yF6t5/RtMjzkOziqIUebfZU67co1JanKtN66QhadSOgnBkARPvt+ynwtD0DD9Aq2DNJyWtXsKvSDmakuyl3bD6+wIntzwFDBUSFeBKiPCcB/xiMmRuEYDmL7ybjMOxZE4GsroPWfYqDBSU1o/p+C7HO374JMttKc5kcF l2MpURdZ jz9SKu69mdMYuJkQ8brnjzOoQZztlwm5vTC+v1FsvsPScnCuutHXaT6iJU1o7Zo/FqrM5qoT3ZJbmgVG8aXsqCwANA3+6XtXimfiFKaVDQwD/dOJeGz/WM9YsFFg23qZ8CI1AvDGoAEmW2cVgS5iuG9bd8B8Hvm4ZwBpACNNLmNNthvJTUBfnu8NI0kElm9TLUiKGHirkfHfX5Hy1cu39RTg28x608f7+leuZmiY5NxXOfdpOUaLN29YRuBoUEd2Q8Jw8 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Fri, Jul 11, 2025 at 10:58:56AM -0700, Linus Torvalds wrote: > That kind of "string buffer" obviously isn't useful for things like > the printf family, but we do have others. Like "struct seq_buf", which > already has "seq_buf_printf()" helpers. > > That's the one you probably should use for most kernel "print to > buffer", but it has very few users despite not being complicated to > use: > > struct seq_buf s; > seq_buf_init(&s, buf, szie); > > and you're off to the races, and can do things like > > seq_buf_printf(&s, ....); > > without ever having to worry about overflows etc. I actually wanted to go one step further with this (that's why I took readpos out of seq_buf in d0ed46b60396). If you look at the guts of vsprintf.c, it'd be much improved by using seq_buf internally instead of passing around buf and end. Once we've done that, maybe we can strip these annoying %pXYZ out of vsprintf.c and use seq_buf routines like it's a StringBuilder (or whatever other language/library convention you prefer). Anyway, I ran out of time to work on it, but I still think it's worthwhile. And then there'd be a lot more commonality between regular printing and trace printing, which would be nice.