public inbox for linux-mm@kvack.org
 help / color / mirror / Atom feed
From: David Rientjes <rientjes@google.com>
To: Andrew Morton <akpm@linux-foundation.org>,
	 Vlastimil Babka <vbabka@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>,
	Michal Hocko <mhocko@suse.com>,
	 Brendan Jackman <jackmanb@google.com>,
	 Johannes Weiner <hannes@cmpxchg.org>, Zi Yan <ziy@nvidia.com>,
	 linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC] mm, page_alloc: reintroduce page allocation stall warning
Date: Sun, 22 Mar 2026 13:28:43 -0700 (PDT)	[thread overview]
Message-ID: <a96fe8ff-06c8-3cb2-8ec1-b21ed9b75f9e@google.com> (raw)
In-Reply-To: <30945cc3-9c4d-94bb-e7e7-dde71483800c@google.com>

On Sat, 21 Mar 2026, David Rientjes wrote:

> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -4706,6 +4706,36 @@ check_retry_cpuset(int cpuset_mems_cookie, struct alloc_context *ac)
>  	return false;
>  }
>  
> +static unsigned long max_alloc_stall_warn_msecs = 10 * 1000L;
> +
> +static void check_alloc_stall_warn(gfp_t gfp_mask, nodemask_t *nodemask,
> +				   unsigned int order, unsigned long alloc_start_time)
> +{
> +	static DEFINE_SPINLOCK(max_alloc_stall_lock);
> +	unsigned long stall_msecs = jiffies_to_msecs(jiffies - alloc_start_time);
> +	unsigned long flags;
> +
> +	if (likely(stall_msecs <= READ_ONCE(max_alloc_stall_warn_msecs)))
> +		return;
> +	if (gfp_mask & __GFP_NOWARN)
> +		return;
> +
> +	spin_lock_irqsave(&max_alloc_stall_lock, flags);
> +	if (stall_msecs > max_alloc_stall_warn_msecs) {
> +		pr_warn("%s: page allocation stall for %lu secs: order:%d, mode:%#x(%pGg) nodemask=%*pbl",
> +			current->comm, stall_msecs / MSEC_PER_SEC, order, gfp_mask, &gfp_mask,
> +			nodemask_pr_args(nodemask));
> +		cpuset_print_current_mems_allowed();
> +		pr_cont("\n");
> +		dump_stack();
> +		warn_alloc_show_mem(gfp_mask, nodemask);
> +
> +		/* Only print future stalls that are more than a second longer */
> +		WRITE_ONCE(max_alloc_stall_warn_msecs, stall_msecs + MSEC_PER_SEC);
> +	}
> +	spin_unlock_irqrestore(&max_alloc_stall_lock, flags);
> +}
> +
>  static inline struct page *
>  __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
>  						struct alloc_context *ac)
> @@ -4726,6 +4756,7 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
>  	int reserve_flags;
>  	bool compact_first = false;
>  	bool can_retry_reserves = true;
> +	unsigned long alloc_start_time = jiffies;
>  
>  	if (unlikely(nofail)) {
>  		/*
> @@ -4990,6 +5021,7 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
>  	warn_alloc(gfp_mask, ac->nodemask,
>  			"page allocation failure: order:%u", order);
>  got_pg:
> +	check_alloc_stall_warn(gfp_mask, ac->nodemask, order, alloc_start_time);
>  	return page;
>  }
>  
> 

Another option here if we're concerned about calling 
check_alloc_stall_warn() on every slowpath allocation is to check this 
right after calling into should_reclaim_retry().  We'd normally be looping 
in the page allocator if a single call is taking >10s.  That could output 
multiple stall warnings for a single page allocation, though, so in this 
case we'd probably want to (1) increase the amount of time between one 
warning and another beyond one second and (2) cap the output when some 
time duration is reached like 60 seconds.


  reply	other threads:[~2026-03-22 20:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-22  3:03 [RFC] mm, page_alloc: reintroduce page allocation stall warning David Rientjes
2026-03-22 20:28 ` David Rientjes [this message]
2026-03-23 14:24 ` Vlastimil Babka (SUSE)
2026-03-24  1:06   ` David Rientjes
2026-03-23 16:53 ` Michal Hocko
2026-03-24  1:13   ` David Rientjes
2026-03-24  8:05     ` Petr Mladek
2026-03-23 19:05 ` Andrew Morton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a96fe8ff-06c8-3cb2-8ec1-b21ed9b75f9e@google.com \
    --to=rientjes@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=jackmanb@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=surenb@google.com \
    --cc=vbabka@kernel.org \
    --cc=ziy@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox