[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6712bf8240b8d_10a03294a6@dwillia2-mobl3.amr.corp.intel.com.notmuch>
Date: Fri, 18 Oct 2024 13:05:22 -0700
From: Dan Williams <dan.j.williams@...el.com>
To: Ira Weiny <ira.weiny@...el.com>, Andrew Morton
<akpm@...ux-foundation.org>, Petr Mladek <pmladek@...e.com>, Steven Rostedt
<rostedt@...dmis.org>, Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Rasmus Villemoes <linux@...musvillemoes.dk>, Sergey Senozhatsky
<senozhatsky@...omium.org>, Jonathan Corbet <corbet@....net>, Davidlohr Bueso
<dave@...olabs.net>, Jonathan Cameron <jonathan.cameron@...wei.com>, "Dave
Jiang" <dave.jiang@...el.com>, Alison Schofield <alison.schofield@...el.com>,
Vishal Verma <vishal.l.verma@...el.com>, Dan Williams
<dan.j.williams@...el.com>
CC: Fan Ni <fan.ni@...sung.com>, Bagas Sanjaya <bagasdotme@...il.com>,
<linux-kernel@...r.kernel.org>, <linux-doc@...r.kernel.org>,
<linux-cxl@...r.kernel.org>, Ira Weiny <ira.weiny@...el.com>
Subject: Re: [PATCH 2/3] printf: Add print format (%pra) for struct range
Ira Weiny wrote:
> The use of struct range in the CXL subsystem is growing. In particular,
> the addition of Dynamic Capacity devices uses struct range in a number
> of places which are reported in debug and error messages.
>
> To wit requiring the printing of the start/end fields in each print
> became cumbersome. Dan Williams mentions in [1] that it might be time
> to have a print specifier for struct range similar to struct resource
>
> A few alternatives were considered including '%par', '%r', and '%pn'.
> %pra follows that struct range is similar to struct resource (%p[rR])
> but needs to be different. Based on discussions with Petr and Andy
> '%pra' was chosen.[2]
>
> Andy also suggested to keep the range prints similar to struct resource
> though combined code. Add hex_range() to handle printing for both
> pointer types.
>
> Finally introduce DEFINE_RANGE() as a parallel to DEFINE_RES_*() and use
> it in the tests.
>
> Cc: Jonathan Corbet <corbet@....net> (maintainer:DOCUMENTATION)
> Cc: linux-doc@...r.kernel.org
> Cc: linux-kernel@...r.kernel.org (open list)
> Link: https://lore.kernel.org/all/663922b475e50_d54d72945b@dwillia2-xfh.jf.intel.com.notmuch/ [1]
> Link: https://lore.kernel.org/all/66cea3bf3332f_f937b29424@iweiny-mobl.notmuch/ [2]
> Suggested-by: "Dan Williams" <dan.j.williams@...el.com>
> Signed-off-by: Ira Weiny <ira.weiny@...el.com>
>
> ---
> Changes:
> [iweiny: split from CXL patch set]
> [Andy: Define DEFINE_RANGE()]
> [Andy: rework hex_range() logic]
> [Andy: Don't use fallthrough]
> [Andy: clean up help comment]
> [Fan: clean up printk comment]
> [Rasmus: fix buf processing in hex_range()]
> [Rasmus: simplify buffer sizing]
> [Rasmus: add '[' to string]
> [Bagas: Clarify the start == end print behavior]
> ---
> Documentation/core-api/printk-formats.rst | 13 +++++++
> include/linux/range.h | 6 ++++
> lib/test_printf.c | 17 +++++++++
> lib/vsprintf.c | 57 +++++++++++++++++++++++++++----
> 4 files changed, 87 insertions(+), 6 deletions(-)
>
> diff --git a/Documentation/core-api/printk-formats.rst b/Documentation/core-api/printk-formats.rst
> index 14e093da3ccd..e1ebf0376154 100644
> --- a/Documentation/core-api/printk-formats.rst
> +++ b/Documentation/core-api/printk-formats.rst
> @@ -231,6 +231,19 @@ width of the CPU data path.
>
> Passed by reference.
>
> +Struct Range
> +------------
> +
> +::
> +
> + %pra [range 0x0000000060000000-0x000000006fffffff]
> + %pra [range 0x0000000060000000]
> +
> +For printing struct range. struct range holds an arbitrary range of u64
> +values. If start is equal to end only print the start value.
I was going to say "why this special case that does not exist for the
%pr case?", but then checked the code and found it *does* do this for %pr.
So if you're going to document this special case for %pra might as well
update the documentation for %pr too.
Alternatively, drop the new %pra documentation for this corner case as
accommodating the U64_MAX size range case is arguably a mistake in the
caller.
Either way, just make it consistent.
Powered by blists - more mailing lists