Re: [PATCH 07/29] x86/boot/e820: Print out sizes of E820 memory ranges

From: Andy Shevchenko
Date: Fri May 16 2025 - 05:15:14 EST


On Thu, May 15, 2025 at 12:44:06PM +0200, Ingo Molnar wrote:
> * Andy Shevchenko <andy.shevchenko@xxxxxxxxx> wrote:
> > Mon, Apr 21, 2025 at 08:51:47PM +0200, Ingo Molnar kirjoitti:

...

> > > + if (size & (SZ_1T-1))
> > > + pr_cont(" %4llu.%01llu TB", size/SZ_1T, 10*(size & (SZ_1T-1))/SZ_1T);
> > > + else
> > > + pr_cont(" %4llu TB", size/SZ_1T);
> > > +}
> >
> > Don't you want to use string_helpers.h provided API?
> > string_get_size().
>
> I don't think string_get_size() knows the fine distinction between:
>
> BIOS-e820: [mem 0x00000000fffc0000-0x00000000ffffffff] 256 KB device reserved
>
> and:
>
> BIOS-e820: [mem 0x00000000fffc0000-0x00000000ffffffff] 256.0 KB device reserved
>
> "256 KB" is exactly 256 KB, while "256.0 KB" denotes a value that is a
> bit larger than 256 KB but rounds down to 256 KB at 1 KB granularity.
>
> When reading platform boot logs it's useful to know when such values
> are exact, at a glance.

We can patch string_size() to print precise integers without fractional part.

--
With Best Regards,
Andy Shevchenko