* Re: [PATCH] mm/page_alloc: Fix memory accept before watermarks gets initialized
[not found] <20250310082855.2587122-1-kirill.shutemov@linux.intel.com>
@ 2025-03-10 11:37 ` Vlastimil Babka
2025-03-10 12:06 ` Kirill A. Shutemov
2025-03-11 20:15 ` Vlastimil Babka
2025-03-12 19:14 ` Gupta, Pankaj
2 siblings, 1 reply; 4+ messages in thread
From: Vlastimil Babka @ 2025-03-10 11:37 UTC (permalink / raw)
To: Kirill A. Shutemov, Andrew Morton
Cc: Mike Rapoport, David Hildenbrand, Mel Gorman, Tom Lendacky,
Kalra, Ashish, Rick Edgecombe, linux-mm, linux-coco,
linux-kernel, Farrah Chen
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@linux.intel.com>
> Reported-and-tested-by: Farrah Chen <farrah.chen@intel.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));
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mm/page_alloc: Fix memory accept before watermarks gets initialized
2025-03-10 11:37 ` [PATCH] mm/page_alloc: Fix memory accept before watermarks gets initialized Vlastimil Babka
@ 2025-03-10 12:06 ` Kirill A. Shutemov
0 siblings, 0 replies; 4+ messages in thread
From: Kirill A. Shutemov @ 2025-03-10 12:06 UTC (permalink / raw)
To: Vlastimil Babka
Cc: Andrew Morton, Mike Rapoport, David Hildenbrand, Mel Gorman,
Tom Lendacky, Kalra, Ashish, Rick Edgecombe, linux-mm,
linux-coco, linux-kernel, Farrah Chen
On Mon, Mar 10, 2025 at 12:37:25PM +0100, Vlastimil Babka wrote:
> 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?
Premature OOM on boot.
It can be triggered with certain combinations of number of vCPUs and
memory size.
> > To ensure progress, accept one MAX_ORDER page if the watermark is zero.
> >
> > Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> > Reported-and-tested-by: Farrah Chen <farrah.chen@intel.com>
>
> Fixes:, Cc: stable etc?
Fixes: dcdfdd40fa82 ("mm: Add support for unaccepted memory")
Cc: stable@@vger.kernel.org # v6.5+
--
Kiryl Shutsemau / Kirill A. Shutemov
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mm/page_alloc: Fix memory accept before watermarks gets initialized
[not found] <20250310082855.2587122-1-kirill.shutemov@linux.intel.com>
2025-03-10 11:37 ` [PATCH] mm/page_alloc: Fix memory accept before watermarks gets initialized Vlastimil Babka
@ 2025-03-11 20:15 ` Vlastimil Babka
2025-03-12 19:14 ` Gupta, Pankaj
2 siblings, 0 replies; 4+ messages in thread
From: Vlastimil Babka @ 2025-03-11 20:15 UTC (permalink / raw)
To: Kirill A. Shutemov, Andrew Morton
Cc: Mike Rapoport, David Hildenbrand, Mel Gorman, Tom Lendacky,
Kalra, Ashish, Rick Edgecombe, linux-mm, linux-coco,
linux-kernel, Farrah Chen
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.
>
> To ensure progress, accept one MAX_ORDER page if the watermark is zero.
>
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> Reported-and-tested-by: Farrah Chen <farrah.chen@intel.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
> ---
> 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));
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mm/page_alloc: Fix memory accept before watermarks gets initialized
[not found] <20250310082855.2587122-1-kirill.shutemov@linux.intel.com>
2025-03-10 11:37 ` [PATCH] mm/page_alloc: Fix memory accept before watermarks gets initialized Vlastimil Babka
2025-03-11 20:15 ` Vlastimil Babka
@ 2025-03-12 19:14 ` Gupta, Pankaj
2 siblings, 0 replies; 4+ messages in thread
From: Gupta, Pankaj @ 2025-03-12 19:14 UTC (permalink / raw)
To: Kirill A. Shutemov, Andrew Morton
Cc: Mike Rapoport, David Hildenbrand, Vlastimil Babka, Mel Gorman,
Tom Lendacky, Kalra, Ashish, Rick Edgecombe, linux-mm,
linux-coco, linux-kernel, Farrah Chen
> 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.
>
> To ensure progress, accept one MAX_ORDER page if the watermark is zero.
>
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> Reported-and-tested-by: Farrah Chen <farrah.chen@intel.com>
Reviewed-by: Pankaj Gupta <pankaj.gupta@amd.com>
Also, did a basic boot test of SNP guest kernel 6.14-rc6 with the patch
applied on top.
> ---
> 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));
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-03-12 19:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20250310082855.2587122-1-kirill.shutemov@linux.intel.com>
2025-03-10 11:37 ` [PATCH] mm/page_alloc: Fix memory accept before watermarks gets initialized Vlastimil Babka
2025-03-10 12:06 ` Kirill A. Shutemov
2025-03-11 20:15 ` Vlastimil Babka
2025-03-12 19:14 ` Gupta, Pankaj
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox