public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* FAILED: patch "[PATCH] mm/page_alloc: fix memory accept before watermarks gets" failed to apply to 6.6-stable tree
@ 2025-03-24 15:32 gregkh
  2025-03-25 12:16 ` [PATCH 6.6.y] mm/page_alloc: fix memory accept before watermarks gets initialized Kirill A. Shutemov
  0 siblings, 1 reply; 4+ messages in thread
From: gregkh @ 2025-03-24 15:32 UTC (permalink / raw)
  To: kirill.shutemov, akpm, ashish.kalra, david, farrah.chen, mgorman,
	pankaj.gupta, rick.p.edgecombe, rppt, stable, thomas.lendacky,
	vbabka
  Cc: stable


The patch below does not apply to the 6.6-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.6.y
git checkout FETCH_HEAD
git cherry-pick -x 800f1059c99e2b39899bdc67a7593a7bea6375d8
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2025032417-prior-uncooked-bf1f@gregkh' --subject-prefix 'PATCH 6.6.y' HEAD^..

Possible dependencies:



thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 800f1059c99e2b39899bdc67a7593a7bea6375d8 Mon Sep 17 00:00:00 2001
From: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Date: Mon, 10 Mar 2025 10:28:55 +0200
Subject: [PATCH] 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/20250310082855.2587122-1-kirill.shutemov@linux.intel.com
Fixes: dcdfdd40fa82 ("mm: Add support for unaccepted memory")
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Tested-by: Farrah Chen <farrah.chen@intel.com>
Reported-by: Farrah Chen <farrah.chen@intel.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Reviewed-by: Pankaj Gupta <pankaj.gupta@amd.com>
Cc: Ashish Kalra <ashish.kalra@amd.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: "Edgecombe, Rick P" <rick.p.edgecombe@intel.com>
Cc: Mel Gorman <mgorman@techsingularity.net>
Cc: "Mike Rapoport (IBM)" <rppt@kernel.org>
Cc: Thomas Lendacky <thomas.lendacky@amd.com>
Cc: <stable@vger.kernel.org>	[6.5+]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 94917c729120..542d25f77be8 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));


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

* [PATCH 6.6.y] mm/page_alloc: fix memory accept before watermarks gets initialized
  2025-03-24 15:32 FAILED: patch "[PATCH] mm/page_alloc: fix memory accept before watermarks gets" failed to apply to 6.6-stable tree gregkh
@ 2025-03-25 12:16 ` Kirill A. Shutemov
  2025-03-25 16:56   ` Sasha Levin
  0 siblings, 1 reply; 4+ messages in thread
From: Kirill A. Shutemov @ 2025-03-25 12:16 UTC (permalink / raw)
  To: stable
  Cc: Kirill A. Shutemov, Farrah Chen, Vlastimil Babka, Pankaj Gupta,
	Ashish Kalra, David Hildenbrand, Edgecombe, Rick P, Mel Gorman,
	Mike Rapoport (IBM), Thomas Lendacky, Andrew Morton

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/20250310082855.2587122-1-kirill.shutemov@linux.intel.com
Fixes: dcdfdd40fa82 ("mm: Add support for unaccepted memory")
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Tested-by: Farrah Chen <farrah.chen@intel.com>
Reported-by: Farrah Chen <farrah.chen@intel.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Reviewed-by: Pankaj Gupta <pankaj.gupta@amd.com>
Cc: Ashish Kalra <ashish.kalra@amd.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: "Edgecombe, Rick P" <rick.p.edgecombe@intel.com>
Cc: Mel Gorman <mgorman@techsingularity.net>
Cc: "Mike Rapoport (IBM)" <rppt@kernel.org>
Cc: Thomas Lendacky <thomas.lendacky@amd.com>
Cc: <stable@vger.kernel.org>	[6.5+]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit 800f1059c99e2b39899bdc67a7593a7bea6375d8)
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
---
 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 191f0f95d3ed..bc62bb2a3b13 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -6653,7 +6653,7 @@ static bool try_to_accept_memory_one(struct zone *zone)
 
 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())
@@ -6662,8 +6662,18 @@ static bool cond_accept_memory(struct zone *zone, unsigned int order)
 	if (list_empty(&zone->unaccepted_pages))
 		return false;
 
+	wmark = high_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 high watermark? */
-	to_accept = high_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));
-- 
2.47.2


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

* Re: [PATCH 6.6.y] mm/page_alloc: fix memory accept before watermarks gets initialized
  2025-03-25 12:16 ` [PATCH 6.6.y] mm/page_alloc: fix memory accept before watermarks gets initialized Kirill A. Shutemov
@ 2025-03-25 16:56   ` Sasha Levin
  2025-03-26  6:50     ` Kirill A. Shutemov
  0 siblings, 1 reply; 4+ messages in thread
From: Sasha Levin @ 2025-03-25 16:56 UTC (permalink / raw)
  To: stable, kirill.shutemov; +Cc: Sasha Levin

[ Sasha's backport helper bot ]

Hi,

Summary of potential issues:
⚠️ Found matching upstream commit but patch is missing proper reference to it

Found matching upstream commit: 800f1059c99e2b39899bdc67a7593a7bea6375d8

Status in newer kernel trees:
6.13.y | Present (different SHA1: 18c31f7ee240)
6.12.y | Present (different SHA1: f4bc2f91e6f5)

Note: The patch differs from the upstream commit:
---
1:  800f1059c99e2 ! 1:  48ab092457a25 mm/page_alloc: fix memory accept before watermarks gets initialized
    @@ Commit message
         Cc: Thomas Lendacky <thomas.lendacky@amd.com>
         Cc: <stable@vger.kernel.org>    [6.5+]
         Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    +    (cherry picked from commit 800f1059c99e2b39899bdc67a7593a7bea6375d8)
    +    Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
     
      ## mm/page_alloc.c ##
    -@@ mm/page_alloc.c: static inline bool has_unaccepted_memory(void)
    +@@ mm/page_alloc.c: static bool try_to_accept_memory_one(struct zone *zone)
      
      static bool cond_accept_memory(struct zone *zone, unsigned int order)
      {
    @@ mm/page_alloc.c: static bool cond_accept_memory(struct zone *zone, unsigned int
      	if (list_empty(&zone->unaccepted_pages))
      		return false;
      
    -+	wmark = promo_wmark_pages(zone);
    ++	wmark = high_wmark_pages(zone);
     +
     +	/*
     +	 * Watermarks have not been initialized yet.
    @@ mm/page_alloc.c: static bool cond_accept_memory(struct zone *zone, unsigned int
     +	if (!wmark)
     +		return try_to_accept_memory_one(zone);
     +
    - 	/* How much to accept to get to promo watermark? */
    --	to_accept = promo_wmark_pages(zone) -
    + 	/* How much to accept to get to high watermark? */
    +-	to_accept = high_wmark_pages(zone) -
     +	to_accept = wmark -
      		    (zone_page_state(zone, NR_FREE_PAGES) -
      		    __zone_watermark_unusable_free(zone, order, 0) -
---

Results of testing on various branches:

| Branch                    | Patch Apply | Build Test |
|---------------------------|-------------|------------|
| stable/linux-6.6.y        |  Success    |  Success   |

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

* Re: [PATCH 6.6.y] mm/page_alloc: fix memory accept before watermarks gets initialized
  2025-03-25 16:56   ` Sasha Levin
@ 2025-03-26  6:50     ` Kirill A. Shutemov
  0 siblings, 0 replies; 4+ messages in thread
From: Kirill A. Shutemov @ 2025-03-26  6:50 UTC (permalink / raw)
  To: Sasha Levin; +Cc: stable

On Tue, Mar 25, 2025 at 12:56:44PM -0400, Sasha Levin wrote:
> [ Sasha's backport helper bot ]
> 
> Hi,
> 
> Summary of potential issues:
> ⚠️ Found matching upstream commit but patch is missing proper reference to it
> 
> Found matching upstream commit: 800f1059c99e2b39899bdc67a7593a7bea6375d8
> 
> Status in newer kernel trees:
> 6.13.y | Present (different SHA1: 18c31f7ee240)
> 6.12.y | Present (different SHA1: f4bc2f91e6f5)
> 
> Note: The patch differs from the upstream commit:

That's okay. Stable tree doesn't include 59149bf8cea9 ("mm: accept to promo watermark")


-- 
  Kiryl Shutsemau / Kirill A. Shutemov

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

end of thread, other threads:[~2025-03-26  6:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-24 15:32 FAILED: patch "[PATCH] mm/page_alloc: fix memory accept before watermarks gets" failed to apply to 6.6-stable tree gregkh
2025-03-25 12:16 ` [PATCH 6.6.y] mm/page_alloc: fix memory accept before watermarks gets initialized Kirill A. Shutemov
2025-03-25 16:56   ` Sasha Levin
2025-03-26  6:50     ` Kirill A. Shutemov

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