[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <03b53f18-8c16-4716-8ed4-1902d7247354@suse.cz>
Date: Mon, 10 Mar 2025 12:37:25 +0100
From: Vlastimil Babka <vbabka@...e.cz>
To: "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
Andrew Morton <akpm@...ux-foundation.org>
Cc: Mike Rapoport <rppt@...nel.org>, David Hildenbrand <david@...hat.com>,
Mel Gorman <mgorman@...hsingularity.net>,
Tom Lendacky <thomas.lendacky@....com>, "Kalra, Ashish"
<ashish.kalra@....com>, Rick Edgecombe <rick.p.edgecombe@...el.com>,
linux-mm@...ck.org, linux-coco@...ts.linux.dev,
linux-kernel@...r.kernel.org, Farrah Chen <farrah.chen@...el.com>
Subject: Re: [PATCH] mm/page_alloc: Fix memory accept before watermarks gets
initialized
On 3/10/25 09:28, Kirill A. Shutemov wrote:
> Watermarks are initialized during the postcore initcall. Until then, all
> watermarks are set to zero. This causes cond_accept_memory() to
> incorrectly skip memory acceptance because a watermark of 0 is always
> met.
What are the user-visible consequences of that?
> To ensure progress, accept one MAX_ORDER page if the watermark is zero.
>
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@...ux.intel.com>
> Reported-and-tested-by: Farrah Chen <farrah.chen@...el.com>
Fixes:, Cc: stable etc?
> ---
> mm/page_alloc.c | 14 ++++++++++++--
> 1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 579789600a3c..4fe93029bcb6 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -7004,7 +7004,7 @@ static inline bool has_unaccepted_memory(void)
>
> static bool cond_accept_memory(struct zone *zone, unsigned int order)
> {
> - long to_accept;
> + long to_accept, wmark;
> bool ret = false;
>
> if (!has_unaccepted_memory())
> @@ -7013,8 +7013,18 @@ static bool cond_accept_memory(struct zone *zone, unsigned int order)
> if (list_empty(&zone->unaccepted_pages))
> return false;
>
> + wmark = promo_wmark_pages(zone);
> +
> + /*
> + * Watermarks have not been initialized yet.
> + *
> + * Accepting one MAX_ORDER page to ensure progress.
> + */
> + if (!wmark)
> + return try_to_accept_memory_one(zone);
> +
> /* How much to accept to get to promo watermark? */
> - to_accept = promo_wmark_pages(zone) -
> + to_accept = wmark -
> (zone_page_state(zone, NR_FREE_PAGES) -
> __zone_watermark_unusable_free(zone, order, 0) -
> zone_page_state(zone, NR_UNACCEPTED));
Powered by blists - more mailing lists