Re: [PATCH v6 1/3] mm/memblock: introduce a new helper memblock_estimated_nr_free_pages()

Alexander Gordeev
2024-08-08T10:06:47Z

On Thu, Aug 08, 2024 at 12:14:13AM +0000, Wei Yang wrote:

Hi Wei,

...
> + * Return:
> + * 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.

Also, the returned value is not an estimation. Meaning the function name
is rather unfortunate AFAICT.

> +#define PHYS_PFN(x) ((unsigned long)((x) >> PAGE_SHIFT))

Thanks!