lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Fri, 26 Apr 2024 18:42:43 +0300
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Geert Uytterhoeven <geert@...ux-m68k.org>
Cc: Rasmus Villemoes <linux@...musvillemoes.dk>,
	Matthew Wilcox <willy@...radead.org>,
	Petr Mladek <pmladek@...e.com>,
	Steven Rostedt <rostedt@...dmis.org>,
	Sergey Senozhatsky <senozhatsky@...omium.org>,
	Randy Dunlap <rdunlap@...radead.org>, linux-kernel@...r.kernel.org
Subject: Re: [RFC] Printing numbers in SI units

On Fri, Apr 26, 2024 at 05:27:08PM +0200, Geert Uytterhoeven wrote:
> On Wed, Jan 24, 2024 at 11:43 PM Rasmus Villemoes
> <linux@...musvillemoes.dk> wrote:
> > On 24/01/2024 19.58, Matthew Wilcox wrote:
> > > I was looking at hugetlbfs and it has several snippets of code like
> > > this:
> > >
> > >         string_get_size(huge_page_size(h), 1, STRING_UNITS_2, buf, 32);
> > >         pr_warn("HugeTLB: allocating %u of page size %s failed node%d.  Only allocated %lu hugepages.\n",
> > >                 h->max_huge_pages_node[nid], buf, nid, i);
> > >
> > > That's not terribly ergonomic, so I wondered if I could do better.
> > > Unfortunately, I decided to do it using the SPECIAL flag which GCC
> > > warns about.  But I've written the code now, so I'm sending it out in
> > > case anybody has a better idea for how to incorporate it.
> >
> > Well, something that gcc will warn about with Wformat isn't gonna fly,
> > obviously. But my man page also mentions ' as a possible flag for d
> > conversions:
> >
> >        '      For decimal conversion (i, d, u, f, F, g, G) the output is
> > to be grouped with thousands'
> >               grouping characters if the locale information indicates any.
> 
> > Obviously, our printf wouldn't implement that, [...]
> 
> Why not? ;-)

:-)

> Old Gmail-white-space-damaged patch below, which I wrote when I got
> fed up with meticulously counting zeros in GHz-range clock
> frequencies...

..

>     lib/vsprintf.c: Add support for thousands' grouping
> 
>     Use an underscore as the grouping character.
> 
>     TODO:
>       - Documentation
>       - Self test

Definitely won't fly without these two.

>       - Do we want to use this in /sys/kernel/debug/clk/clk_summary ?
>         RFC patch, compatibility was already broken by commit
>         e55a839a7a1c561b ("clk: add clock protection mechanism to clk
>         core")
> 
>     Signed-off-by: Geert Uytterhoeven <geert+renesas@...der.be>
>     ---
>     Originally I wanted to use grouping by 4 for octal and hexadecimal
>     numbers.

Not sure about octals, but for the hexadecimal we have hex_dump_to_buffer()
and %ph. The latter one can be modified to support grouping.

-- 
With Best Regards,
Andy Shevchenko



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ