From: "Vlastimil Babka (SUSE)" <vbabka@kernel.org>
To: Usama Arif <usama.arif@linux.dev>, lirongqing <lirongqing@baidu.com>
Cc: Jonathan Corbet <corbet@lwn.net>,
Shuah Khan <skhan@linuxfoundation.org>,
Harry Yoo <harry@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Hao Li <hao.li@linux.dev>, Christoph Lameter <cl@gentwo.org>,
David Rientjes <rientjes@google.com>,
Roman Gushchin <roman.gushchin@linux.dev>,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-mm@kvack.org
Subject: Re: [PATCH] mm/mempool: use static key for boot-time debug enablement
Date: Wed, 27 May 2026 18:43:58 +0200 [thread overview]
Message-ID: <33300bb7-fcbc-41f4-9352-9491256ffb82@kernel.org> (raw)
In-Reply-To: <20260527130337.983366-1-usama.arif@linux.dev>
On 5/27/26 15:03, Usama Arif wrote:
> On Wed, 27 May 2026 06:46:34 -0400 lirongqing <lirongqing@baidu.com> wrote:
>> static int __init mempool_faul_inject_init(void)
>> {
>> int error;
>> @@ -37,7 +54,6 @@ static int __init mempool_faul_inject_init(void)
>> }
>> late_initcall(mempool_faul_inject_init);
>>
>> -#ifdef CONFIG_SLUB_DEBUG_ON
>> static void poison_error(struct mempool *pool, void *element, size_t size,
>> size_t byte)
>> {
>> @@ -73,6 +89,9 @@ static void __check_element(struct mempool *pool, void *element, size_t size)
>>
>> static void check_element(struct mempool *pool, void *element)
>> {
>> + if (!static_branch_unlikely(&mempool_debug_enabled))
>> + return;
>> +
>> /* Skip checking: KASAN might save its metadata in the element. */
>> if (kasan_enabled())
>> return;
>> @@ -112,6 +131,9 @@ static void __poison_element(void *element, size_t size)
>>
>> static void poison_element(struct mempool *pool, void *element)
>> {
>> + if (!static_branch_unlikely(&mempool_debug_enabled))
>> + return;
>> +
>
> Before this change, building with CONFIG_SLUB_DEBUG_ON=y compiled in
> check_element() and poison_element() unconditionally, so the
> poisoning and corruption checks ran on every mempool free/alloc.
> After this change those checks are gated on the mempool_debug boot
> parameter even when CONFIG_SLUB_DEBUG_ON=y.
The same would apply to the dmapool_debug [1]
https://lore.kernel.org/all/20260524034015.1830-1-lirongqing@baidu.com/
> Existing users who relied on CONFIG_SLUB_DEBUG_ON=y giving them
> mempool poison checking will silently lose it on upgrade unless they
> also add "mempool_debug" to the command line.
>
> Would it be worth defaulting the static key to true under
> CONFIG_SLUB_DEBUG_ON=y, for example:
>
> #ifdef CONFIG_SLUB_DEBUG_ON
> static DEFINE_STATIC_KEY_TRUE(mempool_debug_enabled);
> #else
> static DEFINE_STATIC_KEY_FALSE(mempool_debug_enabled);
> #endif
>
> so the previous default behaviour is preserved.
There's DEFINE_STATIC_KEY_MAYBE for this.
But I think nobody will care really. My objection was that this and
dmapool_debug was tied to CONFIG_SLUB_DEBUG_ON in the first place, despite
not being part of slab. I'd rather disconnect it completely.
If testing bots relied on this, we could give them heads up to start using
those boot options. I assume they already use some for stuff that has no
CONFIG_ enablement.
>> /* Skip poisoning: KASAN might save its metadata in the element. */
>> if (kasan_enabled())
>> return;
>> @@ -140,14 +162,6 @@ static void poison_element(struct mempool *pool, void *element)
>> #endif
>> }
>> }
>> -#else /* CONFIG_SLUB_DEBUG_ON */
>> -static inline void check_element(struct mempool *pool, void *element)
>> -{
>> -}
>> -static inline void poison_element(struct mempool *pool, void *element)
>> -{
>> -}
>> -#endif /* CONFIG_SLUB_DEBUG_ON */
>>
>> static __always_inline bool kasan_poison_element(struct mempool *pool,
>> void *element)
>> --
>> 2.9.4
>>
>>
next prev parent reply other threads:[~2026-05-27 16:44 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-27 10:46 lirongqing
2026-05-27 13:03 ` Usama Arif
2026-05-27 16:43 ` Vlastimil Babka (SUSE) [this message]
2026-05-28 3:00 ` 答复: [外部邮件] " Li,Rongqing(ACG CCN)
2026-05-28 10:33 ` Usama Arif
2026-05-28 10:50 ` 答复: " Li,Rongqing(ACG CCN)
2026-05-28 12:59 ` Usama Arif
2026-05-29 9:39 ` Vlastimil Babka (SUSE)
2026-06-01 1:28 ` 答复: " Li,Rongqing(ACG CCN)
2026-05-27 20:06 ` Andrew Morton
2026-05-28 7:54 ` Vlastimil Babka (SUSE)
2026-05-27 21:29 ` Christoph Lameter (Ampere)
2026-05-27 22:13 ` Matthew Wilcox
2026-05-27 23:06 ` Christoph Lameter (Ampere)
2026-05-27 23:09 ` Matthew Wilcox
2026-05-28 7:57 ` 答复: [????] " Li,Rongqing(ACG CCN)
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=33300bb7-fcbc-41f4-9352-9491256ffb82@kernel.org \
--to=vbabka@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=cl@gentwo.org \
--cc=corbet@lwn.net \
--cc=hao.li@linux.dev \
--cc=harry@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lirongqing@baidu.com \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=skhan@linuxfoundation.org \
--cc=usama.arif@linux.dev \
/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®