linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH v6 1/3] mm/memblock: introduce a new helper memblock_estimated_nr_free_pages()
       [not found]   ` <20240808142405.ttlcfkximywtde6i@master>
@ 2024-08-08 16:10     ` Alexander Gordeev
  0 siblings, 0 replies; 2+ messages in thread
From: Alexander Gordeev @ 2024-08-08 16:10 UTC (permalink / raw)
  To: Wei Yang
  Cc: gerald.schaefer, hca, rppt, akpm, brauner, oleg, linux-s390,
	linux-kernel, linux-mm, David Hildenbrand

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!


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v6 1/3] mm/memblock: introduce a new helper memblock_estimated_nr_free_pages()
       [not found] <20240808001415.6298-1-richard.weiyang@gmail.com>
       [not found] ` <ZrSYruB/Aa8+oBoZ@li-008a6a4c-3549-11b2-a85c-c5cc2836eea2.ibm.com>
@ 2024-08-11 16:38 ` Mike Rapoport
  1 sibling, 0 replies; 2+ messages in thread
From: Mike Rapoport @ 2024-08-11 16:38 UTC (permalink / raw)
  To: agordeev, gerald.schaefer, hca, akpm, brauner, oleg, Wei Yang
  Cc: Mike Rapoport, linux-s390, linux-kernel, linux-mm, David Hildenbrand

From: Mike Rapoport (Microsoft) <rppt@kernel.org>

On Thu, 08 Aug 2024 00:14:13 +0000, Wei Yang wrote:
> During bootup, system may need the number of free pages in the whole system
> to do some calculation before all pages are freed to buddy system. Usually
> this number is get from totalram_pages(). Since we plan to move the free
> pages accounting in __free_pages_core(), this value may not represent
> total free pages at the early stage, especially when
> CONFIG_DEFERRED_STRUCT_PAGE_INIT is enabled.
> 
> [...]

Applied to for-next branch of memblock.git tree, thanks!

[1/3] mm/memblock: introduce a new helper memblock_estimated_nr_free_pages()
      commit: d0f8a8973f265f6a276f99d091af99edfb2b87de
[2/3] kernel/fork.c: get estimated free pages by memblock api
      commit: 0910bf0ef85c5404aac94394cb31e076e4eb03f1
[3/3] s390/mm: get estimated free pages by memblock api
      commit: cb088e38aab4c7e9ce711c18c66e851c8f4227bb

tree: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/memblock
branch: for-next

--
Sincerely yours,
Mike.



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-08-11 16:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20240808001415.6298-1-richard.weiyang@gmail.com>
     [not found] ` <ZrSYruB/Aa8+oBoZ@li-008a6a4c-3549-11b2-a85c-c5cc2836eea2.ibm.com>
     [not found]   ` <20240808142405.ttlcfkximywtde6i@master>
2024-08-08 16:10     ` [PATCH v6 1/3] mm/memblock: introduce a new helper memblock_estimated_nr_free_pages() Alexander Gordeev
2024-08-11 16:38 ` Mike Rapoport

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox