From: "Vlastimil Babka (SUSE)" <vbabka@kernel.org>
To: Thomas Gleixner <tglx@kernel.org>, LKML <linux-kernel@vger.kernel.org>
Cc: Vlastimil Babka <vbabka@suse.cz>,
Peter Zijlstra <peterz@infradead.org>,
Alexei Starovoitov <ast@kernel.org>,
linux-mm@vger.kernel.org,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Subject: Re: debugobject: Make it work with deferred page initialization - again
Date: Tue, 23 Jun 2026 22:50:19 +0200 [thread overview]
Message-ID: <a9825502-fbb3-4a2a-91ab-b91755ab5ead@kernel.org> (raw)
In-Reply-To: <87pl6gznti.ffs@tglx>
On 2/7/26 14:27, Thomas Gleixner wrote:
> debugobjects uses __GFP_HIGH for allocations as it might be invoked
> within locked regions. That worked perfectly fine until v6.18. It still
> works correctly when deferred page initialization is disabled and works
> by chance when no page allocation is required before deferred page
> initialization has completed.
>
> Since v6.18 allocations w/o a reclaim flag cause new_slab() to end up in
> alloc_frozen_pages_nolock_noprof(), which returns early when deferred
> page initialization has not yet completed. As the deferred page
> initialization takes quite a while the debugobject pool is depleted and
> debugobjects are disabled.
>
> This can be worked around when PREEMPT_COUNT is enabled as that allows
> debugobjects to add __GFP_KSWAPD_RECLAIM to the GFP flags when the context
> is preemtible. When PREEMPT_COUNT is disabled the context is unknown and
> the reclaim bit can't be set because the caller might hold locks which
> might deadlock in the allocator.
>
> In preemptible context the reclaim bit is harmless and not a performance
> issue as that's usually invoked from slow path initialization context.
>
> That makes debugobjects depend on PREEMPT_COUNT || !DEFERRED_STRUCT_PAGE_INIT.
>
> Fixes: af92793e52c3 ("slab: Introduce kmalloc_nolock() and kfree_nolock().")
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
FYI, it should now be possible to revert this workaround:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=335c347686e76df9d2c7d7f61b5ea627a4c5cb4c
> ---
> lib/Kconfig.debug | 1 +
> lib/debugobjects.c | 19 ++++++++++++++++++-
> 2 files changed, 19 insertions(+), 1 deletion(-)
>
> --- a/lib/Kconfig.debug
> +++ b/lib/Kconfig.debug
> @@ -753,6 +753,7 @@ source "mm/Kconfig.debug"
>
> config DEBUG_OBJECTS
> bool "Debug object operations"
> + depends on PREEMPT_COUNT || !DEFERRED_STRUCT_PAGE_INIT
> depends on DEBUG_KERNEL
> help
> If you say Y here, additional code will be inserted into the
> --- a/lib/debugobjects.c
> +++ b/lib/debugobjects.c
> @@ -398,9 +398,26 @@ static void fill_pool(void)
>
> atomic_inc(&cpus_allocating);
> while (pool_should_refill(&pool_global)) {
> + gfp_t gfp = __GFP_HIGH | __GFP_NOWARN;
> HLIST_HEAD(head);
>
> - if (!kmem_alloc_batch(&head, obj_cache, __GFP_HIGH | __GFP_NOWARN))
> + /*
> + * Allow reclaim only in preemptible context and during
> + * early boot. If not preemptible, the caller might hold
> + * locks causing a deadlock in the allocator.
> + *
> + * If the reclaim flag is not set during early boot then
> + * allocations, which happen before deferred page
> + * initialization has completed, will fail.
> + *
> + * In preemptible context the flag is harmless and not a
> + * performance issue as that's usually invoked from slow
> + * path initialization context.
> + */
> + if (preemptible() || system_state < SYSTEM_SCHEDULING)
> + gfp |= __GFP_KSWAPD_RECLAIM;
> +
> + if (!kmem_alloc_batch(&head, obj_cache, gfp))
> break;
>
> guard(raw_spinlock_irqsave)(&pool_lock);
>
next prev parent reply other threads:[~2026-06-23 20:50 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-07 13:27 Thomas Gleixner
2026-02-07 19:23 ` Alexei Starovoitov
2026-02-09 11:39 ` Vlastimil Babka
2026-02-10 7:37 ` Sebastian Andrzej Siewior
2026-02-10 10:51 ` [tip: core/debugobjects] " tip-bot2 for Thomas Gleixner
2026-02-10 13:10 ` tip-bot2 for Thomas Gleixner
2026-06-23 20:50 ` Vlastimil Babka (SUSE) [this message]
2026-06-24 9:20 ` Thomas Gleixner
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=a9825502-fbb3-4a2a-91ab-b91755ab5ead@kernel.org \
--to=vbabka@kernel.org \
--cc=ast@kernel.org \
--cc=bigeasy@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@kernel.org \
--cc=vbabka@suse.cz \
/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
all inboxes | Powered by JetHome®