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 04A5AC7115B for ; Fri, 20 Jun 2025 06:00:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9E8E26B008A; Fri, 20 Jun 2025 02:00:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9BFF16B008C; Fri, 20 Jun 2025 02:00:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8FD386B0092; Fri, 20 Jun 2025 02:00:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 7EDB86B008A for ; Fri, 20 Jun 2025 02:00:57 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id D6C0B141780 for ; Fri, 20 Jun 2025 06:00:56 +0000 (UTC) X-FDA: 83574730512.17.2301086 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf24.hostedemail.com (Postfix) with ESMTP id F416C180003 for ; Fri, 20 Jun 2025 06:00:54 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=none; spf=pass (imf24.hostedemail.com: domain of anshuman.khandual@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=anshuman.khandual@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1750399255; a=rsa-sha256; cv=none; b=LLXPbik3IfKHmxoPSwMHo1RiFZqafWoP3ctoH6PF4V0YF+6dqcpwl22QAqJjp7tOGOamXa pb0Tljt6JBgxeiTX1F1Xv+GATUt7QG4j89aY4xVL518P/3S6txEy+peZK6kKT7jjnAQgTN vrn3syFCHDWnC6uY6JftYtCsJBrtaZY= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none; spf=pass (imf24.hostedemail.com: domain of anshuman.khandual@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=anshuman.khandual@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1750399255; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ls/5GLw9PnCeaOmOm4YiVNr5F2EDgJDhZphItWs1Ft8=; b=7hZOkdW78kNCAz4if939H6AgwG4jVye5w+kqIXRAoXM6waFxmi/Navxs8R/DFn5n47LtRN 2rxGuC8tgiyN7vNCJnWPpGEQsHzxjKFwNzv38Pnd5jy97MUcC4Q50qdX1AukjzohTDQ6v9 zcIA/W2jRyLcx96HvsYcU489AaDmncI= Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 48362176A; Thu, 19 Jun 2025 23:00:34 -0700 (PDT) Received: from [10.164.146.15] (J09HK2D2RT.blr.arm.com [10.164.146.15]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 518583F66E; Thu, 19 Jun 2025 23:00:50 -0700 (PDT) Message-ID: <9f3fdc4f-2f44-4a3b-9b8b-425003b0be99@arm.com> Date: Fri, 20 Jun 2025 11:30:47 +0530 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC 1/2] lib/vsprintf: Add support for pte_t To: Petr Mladek , Pedro Falcato Cc: David Hildenbrand , linux-mm@kvack.org, Andy Shevchenko , Rasmus Villemoes , Sergey Senozhatsky , Steven Rostedt , Jonathan Corbet , Andrew Morton , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org References: <20250618041235.1716143-1-anshuman.khandual@arm.com> <20250618041235.1716143-2-anshuman.khandual@arm.com> <5d037cb6-91a7-47b7-a902-c3e36f2adefb@arm.com> Content-Language: en-US From: Anshuman Khandual In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Stat-Signature: 77zn5n5orz19xi498wo6yazixamztg49 X-Rspamd-Queue-Id: F416C180003 X-Rspam-User: X-Rspamd-Server: rspam06 X-HE-Tag: 1750399254-802561 X-HE-Meta: U2FsdGVkX1/MfZLXtLIGQXjaathlmxJk/YBh8aIl90ew5hRzncDueU7czeis0AqJd6exUsQ6JN6RVHoj4kwVf1QejVyqnFpc9KW7uQnvysPLKm1x2cM2qZhOpq6lgf3RrhOyliYhn0j1zxdSxluorDxcryZCHE2LwGpwgINPabpsYZk3wAvQOAhZ3g92LXy8X0kU0PB/WMLcZ77vef27Td+fGk9JlzOGWJN1PjECwq65ywhejCmMx/3pb6hsJ4DJ8m3/x7tfpq3O/Vvq/ep3HNmxT2tVGfzQAdmO59SA/1dUPy8Kme3gkaASn3N5o8NmsIh/mASbZdmhRnczAQrILG/zDkRFzaKfvMX/1o2KdOcvQKNxKJ+lEdl44kjLnEM87OVELOn73re0yt4OGpBcnTDw+6a/2Ayc8+iDDTvLennc2EYn15NFHV034W9Ngi8ib/kpwdDvUR6M7Duf4FqA7XsTzOpwBIjTnWAPvpm17/VgfD6HZfivw3ofNNsGsOfjjAL0z1TypddKguOCT3bJAd7yx40RLeiDUmNFOD6Te3C9U8ivYaPvEzkPiHz7IAFrLIVKoQF+08d+NEVCaKMcsEZCYswSNLXZSApCzNBhJKdIaEt2qumRYwKatrIpPWwjx/FvywHXkqc/1khDN3Cp+RfRwYYpmFpGPc+AQonEt/ep3H2nOeqV1LtRYn3Q9RhO1EZ9tuFHlz4hRQZPo2T9uNPwYSYuiSqnQJcxsIjQolKqHb3kaTwwkhvdNZ0FJ4j7K5nnKFD2NwValsvqiWY5Mr47CCGcBS4o44Z5seIx+5EHCVWamkJyInrkRdzfWDaSRvet1doQt334UxxSvpbBoExvAKaD3la0tAetn7jMVY5MPb4PaNLjQ7E4kJnSdU8tho+Fo1DRANg= 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 19/06/25 6:38 PM, Petr Mladek wrote: > On Wed 2025-06-18 19:16:00, Pedro Falcato wrote: >> On Wed, Jun 18, 2025 at 10:44:20AM +0200, David Hildenbrand wrote: >>> On 18.06.25 10:37, Anshuman Khandual wrote: >>>> >>>> >>>> On 18/06/25 1:48 PM, David Hildenbrand wrote: >>>>> On 18.06.25 06:12, Anshuman Khandual wrote: >>>>>> Add a new format for printing page table entries. >>>>>> >>>>>> Cc: Petr Mladek >>>>>> Cc: Steven Rostedt >>>>>> Cc: Jonathan Corbet >>>>>> Cc: Andrew Morton >>>>>> Cc: David Hildenbrand >>>>>> Cc: linux-doc@vger.kernel.org >>>>>> Cc: linux-kernel@vger.kernel.org >>>>>> Cc: linux-mm@kvack.org >>>>>> Signed-off-by: Anshuman Khandual >>>>>> --- >>>>>>   Documentation/core-api/printk-formats.rst | 14 ++++++++++++++ >>>>>>   lib/vsprintf.c                            | 20 ++++++++++++++++++++ >>>>>>   mm/memory.c                               |  5 ++--- >>>>>>   scripts/checkpatch.pl                     |  2 +- >>>>>>   4 files changed, 37 insertions(+), 4 deletions(-) >>>>>> >>>>>> diff --git a/Documentation/core-api/printk-formats.rst b/Documentation/core-api/printk-formats.rst >>>>>> index 4b7f3646ec6ce..75a110b059ee1 100644 >>>>>> --- a/Documentation/core-api/printk-formats.rst >>>>>> +++ b/Documentation/core-api/printk-formats.rst >>>>>> @@ -689,6 +689,20 @@ Rust >>>>>>   Only intended to be used from Rust code to format ``core::fmt::Arguments``. >>>>>>   Do *not* use it from C. >>>>>>   +Page Table Entry >>>>>> +---------------- >>>>>> + >>>>>> +:: >>>>>> +        %ppte >>>>>> + >>>>>> +Print standard page table entry pte_t. >>>>>> + >>>>>> +Passed by reference. >>>>> >>>>> Curious, why the decision to pass by reference? >>>> >>>> Just to make this via %p<> based address mechanism. But wondering >>>> will it be better for the pte to be represented via value instead >>>> of reference ? >>> >>> We commonly pass ptes to functions through value, not reference, that's why >>> I am asking. >> >> >> All printf/printk extensions in the kernel follow %p and use >> pointers because %p takes pointers, so it lets us use -Wformat with no issues. >> >> So yes, taking a pte_t * is required. > > Correct. But the pointer is usually needed because the %pxx format > need to access a structure. Right. > > Passing a pointer is another potential source of errors. I mean that > the callers might pass an invalid pointer by mistake... Agreed - could be a source of error when not used properly. > > Another aspect is performance. It is likely not a big deal for classic > printk() which is a slow path. But trace_printk() tries to optimize > the speed by deferred formatting where possible, see vbin_printf() > and bstr_printf(). > > I think that this is not a blocker for this patchset. But you should > know that using %pxx has a cost. Got it - thanks for the explanation.