Skip to content

Commit 17e7896

Browse files
committed
mm/page_alloc: fix memory accept before watermarks gets initialized
commit 800f105 Author: Kirill A. Shutemov <[email protected]> Date: Mon Mar 10 10:28:55 2025 +0200 mm/page_alloc: fix memory accept before watermarks gets initialized 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. This can lead to a premature OOM on boot. To ensure progress, accept one MAX_ORDER page if the watermark is zero. Link: https://lkml.kernel.org/r/[email protected] Fixes: dcdfdd4 ("mm: Add support for unaccepted memory") Signed-off-by: Kirill A. Shutemov <[email protected]> Tested-by: Farrah Chen <[email protected]> Reported-by: Farrah Chen <[email protected]> Acked-by: Vlastimil Babka <[email protected]> Reviewed-by: Pankaj Gupta <[email protected]> Cc: Ashish Kalra <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: "Edgecombe, Rick P" <[email protected]> Cc: Mel Gorman <[email protected]> Cc: "Mike Rapoport (IBM)" <[email protected]> Cc: Thomas Lendacky <[email protected]> Cc: <[email protected]> [6.5+] Signed-off-by: Andrew Morton <[email protected]> JIRA: https://issues.redhat.com/browse/RHEL-77742 Signed-off-by: Nico Pache <[email protected]>
1 parent 7c34b72 commit 17e7896

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

mm/page_alloc.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6956,7 +6956,7 @@ static inline bool has_unaccepted_memory(void)
69566956

69576957
static bool cond_accept_memory(struct zone *zone, unsigned int order)
69586958
{
6959-
long to_accept;
6959+
long to_accept, wmark;
69606960
bool ret = false;
69616961

69626962
if (!has_unaccepted_memory())
@@ -6965,8 +6965,18 @@ static bool cond_accept_memory(struct zone *zone, unsigned int order)
69656965
if (list_empty(&zone->unaccepted_pages))
69666966
return false;
69676967

6968+
wmark = promo_wmark_pages(zone);
6969+
6970+
/*
6971+
* Watermarks have not been initialized yet.
6972+
*
6973+
* Accepting one MAX_ORDER page to ensure progress.
6974+
*/
6975+
if (!wmark)
6976+
return try_to_accept_memory_one(zone);
6977+
69686978
/* How much to accept to get to promo watermark? */
6969-
to_accept = promo_wmark_pages(zone) -
6979+
to_accept = wmark -
69706980
(zone_page_state(zone, NR_FREE_PAGES) -
69716981
__zone_watermark_unusable_free(zone, order, 0) -
69726982
zone_page_state(zone, NR_UNACCEPTED));

0 commit comments

Comments
 (0)