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]
Message-ID: <ZrTt8NLqaPpKBZKr@li-008a6a4c-3549-11b2-a85c-c5cc2836eea2.ibm.com>
Date: Thu, 8 Aug 2024 18:10:24 +0200
From: Alexander Gordeev <agordeev@...ux.ibm.com>
To: Wei Yang <richard.weiyang@...il.com>
Cc: gerald.schaefer@...ux.ibm.com, hca@...ux.ibm.com, rppt@...nel.org,
        akpm@...ux-foundation.org, brauner@...nel.org, oleg@...hat.com,
        linux-s390@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-mm@...ck.org, David Hildenbrand <david@...hat.com>
Subject: Re: [PATCH v6 1/3] mm/memblock: introduce a new helper
 memblock_estimated_nr_free_pages()

On Thu, Aug 08, 2024 at 02:24:05PM +0000, Wei Yang wrote:
> >> + * An estimated number of free pages from memblock point of view.
> >> + */
> >> +unsigned long __init memblock_estimated_nr_free_pages(void)
> >> +{
> >> +	return PHYS_PFN(memblock_phys_mem_size() - memblock_reserved_size());
> >> +}
> >
> >This could possibly be short on up to two pages due to lack of alignment.
> >The current uses are okay, but since you make it generic it probably matters.
> >
> 
> I don't follow, would you mind giving more detail?

memblock_estimated_nr_free_pages() returns number of pages, not bytes.
Yet, both memblock_phys_mem_size() and memblock_reserved_size() return
a value which is not aligned on PAGE_SIZE. Therefore, the result of
PHYS_PFN() applied to the difference between the two functions might
be short on one (two?) page(s).

> >Also, the returned value is not an estimation. Meaning the function name
> >is rather unfortunate AFAICT.
> 
> From my point of view, this is an estimation for two reasons:
> 
> * value from memblock_xxx is not page size aligned
> * reserved memory maybe released during boot stage
> 
> It is not that easy to get the exact number of free pages here. Do I miss
> something?

No, with this reasoning it makes sense to me.

> -- 
> Wei Yang
> Help you, Help me

Thank you for the clarification!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ