From: Vlastimil Babka <vbabka@suse.cz>
To: Hao Ge <hao.ge@linux.dev>, Suren Baghdasaryan <surenb@google.com>
Cc: Harry Yoo <harry.yoo@oracle.com>,
Andrew Morton <akpm@linux-foundation.org>,
Christoph Lameter <cl@gentwo.org>,
David Rientjes <rientjes@google.com>,
Roman Gushchin <roman.gushchin@linux.dev>,
Shakeel Butt <shakeel.butt@linux.dev>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Hao Ge <gehao@kylinos.cn>
Subject: Re: [PATCH] slab: Avoid race on slab->obj_exts in alloc_slab_obj_exts
Date: Mon, 20 Oct 2025 12:20:57 +0200 [thread overview]
Message-ID: <da90b3a5-a256-49f7-a640-6585f2cce340@suse.cz> (raw)
In-Reply-To: <3efc2a94-54c7-48a8-a804-c231d06b5ed5@linux.dev>
On 10/20/25 04:01, Hao Ge wrote:
>
>> I think retrying like this should work:
>>
>> +retry:
>> old_exts = READ_ONCE(slab->obj_exts);
>> handle_failed_objexts_alloc(old_exts, vec, objects);
>> if (new_slab) {
>> @@ -2145,8 +2146,7 @@ int alloc_slab_obj_exts(struct slab *slab,
>> struct kmem_cache *s,
>> * be simply assigned.
>> */
>> slab->obj_exts = new_exts;
>> - } else if ((old_exts & ~OBJEXTS_FLAGS_MASK) ||
>> - cmpxchg(&slab->obj_exts, old_exts, new_exts) != old_exts) {
>> + } else if (old_exts & ~OBJEXTS_FLAGS_MASK) {
>> /*
>> * If the slab is already in use, somebody can allocate and
>> * assign slabobj_exts in parallel. In this case the existing
>> @@ -2158,6 +2158,8 @@ int alloc_slab_obj_exts(struct slab *slab,
>> struct kmem_cache *s,
>> else
>> kfree(vec);
>> return 0;
>> + } else if (cmpxchg(&slab->obj_exts, old_exts, new_exts) != old_exts) {
>> + goto retry;
>> }
>
> Agree with this. If there are no issues with my comment above,
>
> I will send V2 based on Suren's suggestion.
Great.
> Additionally, I believe the "Fixes" field should be written as follows:
>
> Fixes: 09c46563ff6d ("codetag: debug: introduce OBJEXTS_ALLOC_FAIL to
> mark failed slab_ext allocations")
>
> Am I wrong?
I think it was safe before this one:
f7381b911640 ("slab: mark slab->obj_exts allocation failures unconditionally")
prev parent reply other threads:[~2025-10-20 10:21 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-17 4:57 Hao Ge
2025-10-17 6:05 ` Harry Yoo
2025-10-17 6:42 ` Hao Ge
2025-10-17 7:40 ` Harry Yoo
2025-10-17 8:21 ` Vlastimil Babka
2025-10-17 10:02 ` Hao Ge
2025-10-17 10:40 ` Vlastimil Babka
2025-10-17 21:52 ` Suren Baghdasaryan
2025-10-20 2:01 ` Hao Ge
2025-10-20 10:20 ` Vlastimil Babka [this message]
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=da90b3a5-a256-49f7-a640-6585f2cce340@suse.cz \
--to=vbabka@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=cl@gentwo.org \
--cc=gehao@kylinos.cn \
--cc=hao.ge@linux.dev \
--cc=harry.yoo@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=shakeel.butt@linux.dev \
--cc=surenb@google.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