* [PATCH v1] mm/slub: add comment explaining intentional kobject handling in sysfs_slab_add
@ 2026-07-13 7:00 Hongling Zeng
2026-07-13 7:26 ` Harry Yoo
2026-07-13 13:54 ` Vlastimil Babka (SUSE)
0 siblings, 2 replies; 5+ messages in thread
From: Hongling Zeng @ 2026-07-13 7:00 UTC (permalink / raw)
To: vbabka, harry, akpm, hao.li, cl, rientjes, roman.gushchin,
vdavydov.dev, davej
Cc: linux-mm, linux-kernel, zhongling0719, Hongling Zeng
Add a comment to clarify why we don't call kobject_put() when
kobject_init_and_add() fails in sysfs_slab_add().
Per commit 2420baa8e046 ("mm/slab: Allow cache creation to proceed
even if sysfs registration fails"), sysfs failures are treated as
non-fatal and the cache continues to be used. Calling kobject_put()
would trigger slab_kmem_cache_release() which frees the entire
cache structure, so we intentionally skip it.
Suggested-by: Harry Yoo <harry@kernel.org>
Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn>
---
Change in v1:
-Correct the email
---
mm/slub.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/mm/slub.c b/mm/slub.c
index 9ec774dc7009..edc822d7d9ea 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -9690,6 +9690,11 @@ static int sysfs_slab_add(struct kmem_cache *s)
s->kobj.kset = kset;
err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, "%s", name);
+ /*
+ * Intentionally skip kobject_put(). See commit 2420baa8e046
+ * ("mm/slab: Allow cache creation to proceed even if sysfs
+ * registration fails")
+ */
if (err)
goto out;
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH v1] mm/slub: add comment explaining intentional kobject handling in sysfs_slab_add
2026-07-13 7:00 [PATCH v1] mm/slub: add comment explaining intentional kobject handling in sysfs_slab_add Hongling Zeng
@ 2026-07-13 7:26 ` Harry Yoo
2026-07-13 7:45 ` Hongling Zeng
2026-07-13 13:54 ` Vlastimil Babka (SUSE)
1 sibling, 1 reply; 5+ messages in thread
From: Harry Yoo @ 2026-07-13 7:26 UTC (permalink / raw)
To: Hongling Zeng, vbabka, akpm, hao.li, cl, rientjes, roman.gushchin,
vdavydov.dev, davej
Cc: linux-mm, linux-kernel, zhongling0719
[-- Attachment #1.1: Type: text/plain, Size: 1382 bytes --]
On 7/13/26 4:00 PM, Hongling Zeng wrote:
> Add a comment to clarify why we don't call kobject_put() when
> kobject_init_and_add() fails in sysfs_slab_add().
>
> Per commit 2420baa8e046 ("mm/slab: Allow cache creation to proceed
> even if sysfs registration fails"), sysfs failures are treated as
> non-fatal and the cache continues to be used. Calling kobject_put()
> would trigger slab_kmem_cache_release() which frees the entire
> cache structure, so we intentionally skip it.
>
> Suggested-by: Harry Yoo <harry@kernel.org>
> Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn>
> ---
>
> Change in v1:
> -Correct the email
Hmm, the email "Hyeonggon Kim <pictureone@kakao.com>" came out of
nowhere. Could you please explain why this happened?
> ---
> mm/slub.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/mm/slub.c b/mm/slub.c
> index 9ec774dc7009..edc822d7d9ea 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -9690,6 +9690,11 @@ static int sysfs_slab_add(struct kmem_cache *s)
>
> s->kobj.kset = kset;
> err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, "%s", name);
> + /*
> + * Intentionally skip kobject_put(). See commit 2420baa8e046
> + * ("mm/slab: Allow cache creation to proceed even if sysfs
> + * registration fails")
> + */
> if (err)
> goto out;
--
Cheers,
Harry / Hyeonggon
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v1] mm/slub: add comment explaining intentional kobject handling in sysfs_slab_add
2026-07-13 7:26 ` Harry Yoo
@ 2026-07-13 7:45 ` Hongling Zeng
2026-07-13 8:49 ` Harry Yoo
0 siblings, 1 reply; 5+ messages in thread
From: Hongling Zeng @ 2026-07-13 7:45 UTC (permalink / raw)
To: Harry Yoo, Hongling Zeng, vbabka, akpm, hao.li, cl, rientjes,
roman.gushchin, vdavydov.dev, davej
Cc: linux-mm, linux-kernel
在 2026年07月13日 15:26, Harry Yoo 写道:
> On 7/13/26 4:00 PM, Hongling Zeng wrote:
>> Add a comment to clarify why we don't call kobject_put() when
>> kobject_init_and_add() fails in sysfs_slab_add().
>>
>> Per commit 2420baa8e046 ("mm/slab: Allow cache creation to proceed
>> even if sysfs registration fails"), sysfs failures are treated as
>> non-fatal and the cache continues to be used. Calling kobject_put()
>> would trigger slab_kmem_cache_release() which frees the entire
>> cache structure, so we intentionally skip it.
>>
>> Suggested-by: Harry Yoo <harry@kernel.org>
>> Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn>
>> ---
>>
>> Change in v1:
>> -Correct the email
> Hmm, the email "Hyeonggon Kim <pictureone@kakao.com>" came out of
> nowhere. Could you please explain why this happened?
My apologies for the confusion.
I incorrectly retrieved your email from a signature search :)
>> ---
>> mm/slub.c | 5 +++++
>> 1 file changed, 5 insertions(+)
>>
>> diff --git a/mm/slub.c b/mm/slub.c
>> index 9ec774dc7009..edc822d7d9ea 100644
>> --- a/mm/slub.c
>> +++ b/mm/slub.c
>> @@ -9690,6 +9690,11 @@ static int sysfs_slab_add(struct kmem_cache *s)
>>
>> s->kobj.kset = kset;
>> err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, "%s", name);
>> + /*
>> + * Intentionally skip kobject_put(). See commit 2420baa8e046
>> + * ("mm/slab: Allow cache creation to proceed even if sysfs
>> + * registration fails")
>> + */
>> if (err)
>> goto out;
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v1] mm/slub: add comment explaining intentional kobject handling in sysfs_slab_add
2026-07-13 7:45 ` Hongling Zeng
@ 2026-07-13 8:49 ` Harry Yoo
0 siblings, 0 replies; 5+ messages in thread
From: Harry Yoo @ 2026-07-13 8:49 UTC (permalink / raw)
To: Hongling Zeng, Hongling Zeng, vbabka, akpm, hao.li, cl, rientjes,
roman.gushchin, vdavydov.dev, davej
Cc: linux-mm, linux-kernel
[-- Attachment #1.1: Type: text/plain, Size: 1190 bytes --]
On 7/13/26 4:45 PM, Hongling Zeng wrote:
> 在 2026年07月13日 15:26, Harry Yoo 写道:
>> On 7/13/26 4:00 PM, Hongling Zeng wrote:
>>> Add a comment to clarify why we don't call kobject_put() when
>>> kobject_init_and_add() fails in sysfs_slab_add().
>>>
>>> Per commit 2420baa8e046 ("mm/slab: Allow cache creation to proceed
>>> even if sysfs registration fails"), sysfs failures are treated as
>>> non-fatal and the cache continues to be used. Calling kobject_put()
>>> would trigger slab_kmem_cache_release() which frees the entire
>>> cache structure, so we intentionally skip it.
>>>
>>> Suggested-by: Harry Yoo <harry@kernel.org>
>>> Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn>
>>> ---
FWIW, the patch looks fine to me, so:
Acked-by: Harry Yoo (Oracle) <harry@kernel.org>
>>> Change in v1:
>>> -Correct the email
>>
>> Hmm, the email "Hyeonggon Kim <pictureone@kakao.com>" came out of
>> nowhere. Could you please explain why this happened?
> My apologies for the confusion.
>
> I incorrectly retrieved your email from a signature search :)
You mean retrieved from your local address book?
--
Cheers,
Harry / Hyeonggon
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1] mm/slub: add comment explaining intentional kobject handling in sysfs_slab_add
2026-07-13 7:00 [PATCH v1] mm/slub: add comment explaining intentional kobject handling in sysfs_slab_add Hongling Zeng
2026-07-13 7:26 ` Harry Yoo
@ 2026-07-13 13:54 ` Vlastimil Babka (SUSE)
1 sibling, 0 replies; 5+ messages in thread
From: Vlastimil Babka (SUSE) @ 2026-07-13 13:54 UTC (permalink / raw)
To: Hongling Zeng, harry, akpm, hao.li, cl, rientjes, roman.gushchin,
vdavydov.dev, davej
Cc: linux-mm, linux-kernel, zhongling0719
On 7/13/26 09:00, Hongling Zeng wrote:
> Add a comment to clarify why we don't call kobject_put() when
> kobject_init_and_add() fails in sysfs_slab_add().
>
> Per commit 2420baa8e046 ("mm/slab: Allow cache creation to proceed
> even if sysfs registration fails"), sysfs failures are treated as
> non-fatal and the cache continues to be used. Calling kobject_put()
> would trigger slab_kmem_cache_release() which frees the entire
> cache structure, so we intentionally skip it.
>
> Suggested-by: Harry Yoo <harry@kernel.org>
> Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn>
Thanks, added to slab/for-next
> ---
> Change in v1:
> -Correct the email
> ---
> mm/slub.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/mm/slub.c b/mm/slub.c
> index 9ec774dc7009..edc822d7d9ea 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -9690,6 +9690,11 @@ static int sysfs_slab_add(struct kmem_cache *s)
>
> s->kobj.kset = kset;
> err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, "%s", name);
> + /*
> + * Intentionally skip kobject_put(). See commit 2420baa8e046
> + * ("mm/slab: Allow cache creation to proceed even if sysfs
> + * registration fails")
> + */
> if (err)
> goto out;
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-07-13 16:24 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-13 7:00 [PATCH v1] mm/slub: add comment explaining intentional kobject handling in sysfs_slab_add Hongling Zeng
2026-07-13 7:26 ` Harry Yoo
2026-07-13 7:45 ` Hongling Zeng
2026-07-13 8:49 ` Harry Yoo
2026-07-13 13:54 ` Vlastimil Babka (SUSE)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox