Re: [PATCH] page_alloc: avoid the negative free for meminfo available

From: Michal Hocko
Date: Tue Jan 03 2023 - 03:03:42 EST


On Tue 03-01-23 16:28:07, Jaewon Kim wrote:
> The totalreserve_pages could be higher than the free because of
> watermark high or watermark boost. Handle this situation and fix it to 0
> free size.

What is the actual problem you are trying to address by this change?

> Signed-off-by: Jaewon Kim <jaewon31.kim@xxxxxxxxxxx>
> ---
> mm/page_alloc.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 218b28ee49ed..e510ae83d5f3 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -5948,6 +5948,8 @@ long si_mem_available(void)
> * without causing swapping or OOM.
> */
> available = global_zone_page_state(NR_FREE_PAGES) - totalreserve_pages;
> + if (available < 0)
> + available = 0;
>
> /*
> * Not all the page cache can be freed, otherwise the system will
> --
> 2.17.1

--
Michal Hocko
SUSE Labs