* [RFC] mm, page_alloc: reintroduce page allocation stall warning
@ 2026-03-22 3:03 David Rientjes
2026-03-22 20:28 ` David Rientjes
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: David Rientjes @ 2026-03-22 3:03 UTC (permalink / raw)
To: Andrew Morton, Vlastimil Babka
Cc: Suren Baghdasaryan, Michal Hocko, Brendan Jackman,
Johannes Weiner, Zi Yan, linux-mm, linux-kernel
Previously, we had warnings when a single page allocation took longer
than reasonably expected. This was introduced in commit 63f53dea0c98
("mm: warn about allocations which stall for too long").
The warning was subsequently reverted in commit 400e22499dd9 ("mm: don't
warn about allocations which stall for too long") but for reasons
unrelated to the warning itself.
Page allocation stalls in excess of 10 seconds are always useful to debug
because they can result in severe userspace unresponsiveness. Adding
this artifact can be used to correlate with userspace going out to lunch
and to understand the state of memory at the time.
There should be a reasonable expectation that this warning will never
trigger given it is very passive, it starts with a 10 second floor to
begin with. If it does trigger, this reveals an issue that should be
fixed: a single page allocation should never loop for more than 10
seconds without oom killing to make memory available.
Unlike the original implementation, this implementation only reports
stalls that are at least a second longer than the longest stall reported
thus far.
Signed-off-by: David Rientjes <rientjes@google.com>
---
mm/page_alloc.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
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;
}
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC] mm, page_alloc: reintroduce page allocation stall warning
2026-03-22 3:03 [RFC] mm, page_alloc: reintroduce page allocation stall warning David Rientjes
@ 2026-03-22 20:28 ` David Rientjes
2026-03-23 14:24 ` Vlastimil Babka (SUSE)
` (2 subsequent siblings)
3 siblings, 0 replies; 8+ messages in thread
From: David Rientjes @ 2026-03-22 20:28 UTC (permalink / raw)
To: Andrew Morton, Vlastimil Babka
Cc: Suren Baghdasaryan, Michal Hocko, Brendan Jackman,
Johannes Weiner, Zi Yan, linux-mm, linux-kernel
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.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC] mm, page_alloc: reintroduce page allocation stall warning
2026-03-22 3:03 [RFC] mm, page_alloc: reintroduce page allocation stall warning David Rientjes
2026-03-22 20:28 ` David Rientjes
@ 2026-03-23 14:24 ` Vlastimil Babka (SUSE)
2026-03-24 1:06 ` David Rientjes
2026-03-23 16:53 ` Michal Hocko
2026-03-23 19:05 ` Andrew Morton
3 siblings, 1 reply; 8+ messages in thread
From: Vlastimil Babka (SUSE) @ 2026-03-23 14:24 UTC (permalink / raw)
To: David Rientjes, Andrew Morton
Cc: Suren Baghdasaryan, Michal Hocko, Brendan Jackman,
Johannes Weiner, Zi Yan, linux-mm, linux-kernel
On 3/22/26 4:03 AM, David Rientjes wrote:
> Previously, we had warnings when a single page allocation took longer
> than reasonably expected. This was introduced in commit 63f53dea0c98
> ("mm: warn about allocations which stall for too long").
>
> The warning was subsequently reverted in commit 400e22499dd9 ("mm: don't
> warn about allocations which stall for too long") but for reasons
> unrelated to the warning itself.
>
> Page allocation stalls in excess of 10 seconds are always useful to debug
> because they can result in severe userspace unresponsiveness. Adding
> this artifact can be used to correlate with userspace going out to lunch
> and to understand the state of memory at the time.
>
> There should be a reasonable expectation that this warning will never
> trigger given it is very passive, it starts with a 10 second floor to
> begin with. If it does trigger, this reveals an issue that should be
> fixed: a single page allocation should never loop for more than 10
> seconds without oom killing to make memory available.
>
> Unlike the original implementation, this implementation only reports
> stalls that are at least a second longer than the longest stall reported
> thus far.
>
> Signed-off-by: David Rientjes <rientjes@google.com>
I think, why not, if it's useful and we can reintroduce it without the
issues it had.
Maybe instead of requiring the stall time to increase by a second, we
could just limit the stall reports to once per 10 second. If there are
multiple ones in progress, one of them will win that report slot
randomly. This would also cover a stall that's so long it reports itself
multiple times (as in the original commit).
> ---
> mm/page_alloc.c | 32 ++++++++++++++++++++++++++++++++
> 1 file changed, 32 insertions(+)
>
> 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;
This check without lock is while I'm not worried about calling this
liberally (as you discuss in your self-reply).
> + if (gfp_mask & __GFP_NOWARN)
> + return;
> +
> + spin_lock_irqsave(&max_alloc_stall_lock, flags);
This could make parallel stallers spin for no good reason while one that
has the lock is printing. I think we could use trylock here, and if it
fails, do nothing. Then it also shouldn't be necessary to disable irqs.
> + 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);
But placed here it defeats the purpose to some extent, no? We'll only
learn about a stall that ended. With the shared 10s rate-limit, we
should be able to do it in the repeat loop for stalls in progress, as
the original commit did.
> return page;
> }
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC] mm, page_alloc: reintroduce page allocation stall warning
2026-03-22 3:03 [RFC] mm, page_alloc: reintroduce page allocation stall warning David Rientjes
2026-03-22 20:28 ` David Rientjes
2026-03-23 14:24 ` Vlastimil Babka (SUSE)
@ 2026-03-23 16:53 ` Michal Hocko
2026-03-24 1:13 ` David Rientjes
2026-03-23 19:05 ` Andrew Morton
3 siblings, 1 reply; 8+ messages in thread
From: Michal Hocko @ 2026-03-23 16:53 UTC (permalink / raw)
To: David Rientjes
Cc: Andrew Morton, Vlastimil Babka, Suren Baghdasaryan,
Brendan Jackman, Johannes Weiner, Zi Yan, linux-mm, linux-kernel,
Petr Mladek, Steven Rostedt, John Ogness, Sergey Senozhatsky
On Sat 21-03-26 20:03:16, David Rientjes wrote:
> Previously, we had warnings when a single page allocation took longer
> than reasonably expected. This was introduced in commit 63f53dea0c98
> ("mm: warn about allocations which stall for too long").
>
> The warning was subsequently reverted in commit 400e22499dd9 ("mm: don't
> warn about allocations which stall for too long") but for reasons
> unrelated to the warning itself.
>
> Page allocation stalls in excess of 10 seconds are always useful to debug
> because they can result in severe userspace unresponsiveness. Adding
> this artifact can be used to correlate with userspace going out to lunch
> and to understand the state of memory at the time.
>
> There should be a reasonable expectation that this warning will never
> trigger given it is very passive, it starts with a 10 second floor to
> begin with. If it does trigger, this reveals an issue that should be
> fixed: a single page allocation should never loop for more than 10
> seconds without oom killing to make memory available.
>
> Unlike the original implementation, this implementation only reports
> stalls that are at least a second longer than the longest stall reported
> thus far.
Am all for reintroducing the warning in some shape. The biggest problem
back then was printk being too eager to stomp all the work at a single
executing context. Not sure this is still the case. Let's add printk
maintainers.
Also it makes some sense to differentiate stalled callers and show_mem
which is more verbose. The former tells us who is affected and the
second will give us more context and we want to get some information
about all of them. The latter can be printed much less often as it will
describe situation for a batch of concurrent ones.
> Signed-off-by: David Rientjes <rientjes@google.com>
> ---
> mm/page_alloc.c | 32 ++++++++++++++++++++++++++++++++
> 1 file changed, 32 insertions(+)
>
> 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;
> }
>
--
Michal Hocko
SUSE Labs
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC] mm, page_alloc: reintroduce page allocation stall warning
2026-03-22 3:03 [RFC] mm, page_alloc: reintroduce page allocation stall warning David Rientjes
` (2 preceding siblings ...)
2026-03-23 16:53 ` Michal Hocko
@ 2026-03-23 19:05 ` Andrew Morton
3 siblings, 0 replies; 8+ messages in thread
From: Andrew Morton @ 2026-03-23 19:05 UTC (permalink / raw)
To: David Rientjes
Cc: Vlastimil Babka, Suren Baghdasaryan, Michal Hocko,
Brendan Jackman, Johannes Weiner, Zi Yan, linux-mm, linux-kernel
On Sat, 21 Mar 2026 20:03:16 -0700 (PDT) David Rientjes <rientjes@google.com> wrote:
> Previously, we had warnings when a single page allocation took longer
> than reasonably expected. This was introduced in commit 63f53dea0c98
> ("mm: warn about allocations which stall for too long").
>
> The warning was subsequently reverted in commit 400e22499dd9 ("mm: don't
> warn about allocations which stall for too long") but for reasons
> unrelated to the warning itself.
>
> Page allocation stalls in excess of 10 seconds are always useful to debug
> because they can result in severe userspace unresponsiveness. Adding
> this artifact can be used to correlate with userspace going out to lunch
> and to understand the state of memory at the time.
>
> There should be a reasonable expectation that this warning will never
> trigger given it is very passive, it starts with a 10 second floor to
> begin with. If it does trigger, this reveals an issue that should be
> fixed: a single page allocation should never loop for more than 10
> seconds without oom killing to make memory available.
>
> Unlike the original implementation, this implementation only reports
> stalls that are at least a second longer than the longest stall reported
> thus far.
AI review: https://sashiko.dev/#/patchset/30945cc3-9c4d-94bb-e7e7-dde71483800c@google.com
The warn_alloc_show_mem() inside spin_lock_irqsave() does sound
problematic.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC] mm, page_alloc: reintroduce page allocation stall warning
2026-03-23 14:24 ` Vlastimil Babka (SUSE)
@ 2026-03-24 1:06 ` David Rientjes
0 siblings, 0 replies; 8+ messages in thread
From: David Rientjes @ 2026-03-24 1:06 UTC (permalink / raw)
To: Vlastimil Babka (SUSE)
Cc: Andrew Morton, Suren Baghdasaryan, Michal Hocko, Brendan Jackman,
Johannes Weiner, Zi Yan, linux-mm, linux-kernel
On Mon, 23 Mar 2026, Vlastimil Babka (SUSE) wrote:
> On 3/22/26 4:03 AM, David Rientjes wrote:
> > Previously, we had warnings when a single page allocation took longer
> > than reasonably expected. This was introduced in commit 63f53dea0c98
> > ("mm: warn about allocations which stall for too long").
> >
> > The warning was subsequently reverted in commit 400e22499dd9 ("mm: don't
> > warn about allocations which stall for too long") but for reasons
> > unrelated to the warning itself.
> >
> > Page allocation stalls in excess of 10 seconds are always useful to debug
> > because they can result in severe userspace unresponsiveness. Adding
> > this artifact can be used to correlate with userspace going out to lunch
> > and to understand the state of memory at the time.
> >
> > There should be a reasonable expectation that this warning will never
> > trigger given it is very passive, it starts with a 10 second floor to
> > begin with. If it does trigger, this reveals an issue that should be
> > fixed: a single page allocation should never loop for more than 10
> > seconds without oom killing to make memory available.
> >
> > Unlike the original implementation, this implementation only reports
> > stalls that are at least a second longer than the longest stall reported
> > thus far.
> >
> > Signed-off-by: David Rientjes <rientjes@google.com>
>
> I think, why not, if it's useful and we can reintroduce it without the
> issues it had.
> Maybe instead of requiring the stall time to increase by a second, we
> could just limit the stall reports to once per 10 second. If there are
> multiple ones in progress, one of them will win that report slot
> randomly. This would also cover a stall that's so long it reports itself
> multiple times (as in the original commit).
>
I like that a lot, thanks. Since part of the motivation is to correlate
userspace unresponsiveness with page allocation stalls in the kernel, we
increasingly lack that visiblity if a single long page allocation took 60
seconds a month ago, for example, and we have to reach that threshold to
report again.
The original patch ended up at line 4839 here:
4833) }
4834) }
4835)
4836) /* Caller is not willing to reclaim, we can't balance anything */
4837) if (!can_direct_reclaim)
4838) goto nopage;
4839) <===== HERE
4840) /* Avoid recursion of direct reclaim */
4841) if (current->flags & PF_MEMALLOC)
4842) goto nopage;
4843)
4844) /* Try direct reclaim and then allocating */
Which looks like the right place to put it, but probably after the
PF_MEMALLOC check.
If we set a minimum reporting threshold of 10 seconds and only report
system wide every 10 seconds, I think this will work very well. And, as
you mention, this also reports stalls for allocations that never actually
return.
I'll implement this and send out a formal patch for it.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC] mm, page_alloc: reintroduce page allocation stall warning
2026-03-23 16:53 ` Michal Hocko
@ 2026-03-24 1:13 ` David Rientjes
2026-03-24 8:05 ` Petr Mladek
0 siblings, 1 reply; 8+ messages in thread
From: David Rientjes @ 2026-03-24 1:13 UTC (permalink / raw)
To: Michal Hocko
Cc: Andrew Morton, Vlastimil Babka, Suren Baghdasaryan,
Brendan Jackman, Johannes Weiner, Zi Yan, linux-mm, linux-kernel,
Petr Mladek, Steven Rostedt, John Ogness, Sergey Senozhatsky
On Mon, 23 Mar 2026, Michal Hocko wrote:
> On Sat 21-03-26 20:03:16, David Rientjes wrote:
> > Previously, we had warnings when a single page allocation took longer
> > than reasonably expected. This was introduced in commit 63f53dea0c98
> > ("mm: warn about allocations which stall for too long").
> >
> > The warning was subsequently reverted in commit 400e22499dd9 ("mm: don't
> > warn about allocations which stall for too long") but for reasons
> > unrelated to the warning itself.
> >
> > Page allocation stalls in excess of 10 seconds are always useful to debug
> > because they can result in severe userspace unresponsiveness. Adding
> > this artifact can be used to correlate with userspace going out to lunch
> > and to understand the state of memory at the time.
> >
> > There should be a reasonable expectation that this warning will never
> > trigger given it is very passive, it starts with a 10 second floor to
> > begin with. If it does trigger, this reveals an issue that should be
> > fixed: a single page allocation should never loop for more than 10
> > seconds without oom killing to make memory available.
> >
> > Unlike the original implementation, this implementation only reports
> > stalls that are at least a second longer than the longest stall reported
> > thus far.
>
> Am all for reintroducing the warning in some shape. The biggest problem
> back then was printk being too eager to stomp all the work at a single
> executing context. Not sure this is still the case. Let's add printk
> maintainers.
Thanks.
> Also it makes some sense to differentiate stalled callers and show_mem
> which is more verbose. The former tells us who is affected and the
> second will give us more context and we want to get some information
> about all of them. The latter can be printed much less often as it will
> describe situation for a batch of concurrent ones.
>
Based on Vlastimil's suggestion I think this is trending in the direction
of 10-second reporting windows system wide unless that doesn't work for
some reason. I do worry about reporting many stalls even without
show_mem(), however. In situations where the allocations are
unconstained, all userspace goes out to lunch for 10 seconds and that can
result in thousands of threads all reporting stalls and spamming the
kernel log.
Idea is a 10 second threshold for reporting stalls and then only one stall
report across a 10 second sliding window globally.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC] mm, page_alloc: reintroduce page allocation stall warning
2026-03-24 1:13 ` David Rientjes
@ 2026-03-24 8:05 ` Petr Mladek
0 siblings, 0 replies; 8+ messages in thread
From: Petr Mladek @ 2026-03-24 8:05 UTC (permalink / raw)
To: David Rientjes
Cc: Michal Hocko, Andrew Morton, Vlastimil Babka, Suren Baghdasaryan,
Brendan Jackman, Johannes Weiner, Zi Yan, linux-mm, linux-kernel,
Steven Rostedt, John Ogness, Sergey Senozhatsky
On Mon 2026-03-23 18:13:21, David Rientjes wrote:
> On Mon, 23 Mar 2026, Michal Hocko wrote:
>
> > On Sat 21-03-26 20:03:16, David Rientjes wrote:
> > > Previously, we had warnings when a single page allocation took longer
> > > than reasonably expected. This was introduced in commit 63f53dea0c98
> > > ("mm: warn about allocations which stall for too long").
> > >
> > > The warning was subsequently reverted in commit 400e22499dd9 ("mm: don't
> > > warn about allocations which stall for too long") but for reasons
> > > unrelated to the warning itself.
> > >
> > > Page allocation stalls in excess of 10 seconds are always useful to debug
> > > because they can result in severe userspace unresponsiveness. Adding
> > > this artifact can be used to correlate with userspace going out to lunch
> > > and to understand the state of memory at the time.
> > >
> > > There should be a reasonable expectation that this warning will never
> > > trigger given it is very passive, it starts with a 10 second floor to
> > > begin with. If it does trigger, this reveals an issue that should be
> > > fixed: a single page allocation should never loop for more than 10
> > > seconds without oom killing to make memory available.
> > >
> > > Unlike the original implementation, this implementation only reports
> > > stalls that are at least a second longer than the longest stall reported
> > > thus far.
> >
> > Am all for reintroducing the warning in some shape. The biggest problem
> > back then was printk being too eager to stomp all the work at a single
> > executing context. Not sure this is still the case. Let's add printk
> > maintainers.
printk() is still a constraint. There is an API which allows to
offload printk() into a kthread but only few console drivers have been
converted so far. Most console drivers, including the most common
uart 8250, are still using the legacy loop in
printk()/console_unlock().
In addition, the new API introduced an emergency context which forces
synchronous flush of printk messages even for the converted console
drivers. The emergency context is currently used, for example, by
WARN() or RCU stall report. So, there always will be a risk that
too many pending messages might cause a stall.
> > Also it makes some sense to differentiate stalled callers and show_mem
> > which is more verbose. The former tells us who is affected and the
> > second will give us more context and we want to get some information
> > about all of them. The latter can be printed much less often as it will
> > describe situation for a batch of concurrent ones.
> >
>
> Based on Vlastimil's suggestion I think this is trending in the direction
> of 10-second reporting windows system wide unless that doesn't work for
> some reason.
This is a wise idea.
> I do worry about reporting many stalls even without
> show_mem(), however. In situations where the allocations are
> unconstained, all userspace goes out to lunch for 10 seconds and that can
> result in thousands of threads all reporting stalls and spamming the
> kernel log.
Yeah, this looks scary even when all console drivers handled messages
in kthreads. I believe that printing details about all the stalled
tasks is not worth it. It might be enough to add an atomic counter
and print the number of stalled tasks within last 10 seconds.
> Idea is a 10 second threshold for reporting stalls and then only one stall
> report across a 10 second sliding window globally.
I wonder if this even could be added to the existing watchdog,
aka report the number of stalled allocations in watchdog_timer_fn().
Best Regards,
Petr
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-03-24 8:05 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-22 3:03 [RFC] mm, page_alloc: reintroduce page allocation stall warning David Rientjes
2026-03-22 20:28 ` David Rientjes
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox