From: Vlastimil Babka <vbabka@suse.cz>
To: linke li <lilinke99@qq.com>
Cc: xujianhao01@gmail.com, Chengming Zhou <chengming.zhou@linux.dev>,
Christoph Lameter <cl@linux.com>,
Pekka Enberg <penberg@kernel.org>,
David Rientjes <rientjes@google.com>,
Joonsoo Kim <iamjoonsoo.kim@lge.com>,
Andrew Morton <akpm@linux-foundation.org>,
Roman Gushchin <roman.gushchin@linux.dev>,
Hyeonggon Yoo <42.hyeyoo@gmail.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] mm/slub: mark racy accesses on slab->slabs
Date: Mon, 25 Mar 2024 09:48:03 +0100 [thread overview]
Message-ID: <8b146695-4ff5-4f9a-ab64-6cbed4168f98@suse.cz> (raw)
In-Reply-To: <tencent_909E215498A54E4E100E456A92A7F13DAD06@qq.com>
On 3/21/24 4:48 AM, linke li wrote:
> The reads of slab->slabs are racy because it may be changed by
> put_cpu_partial concurrently. In slabs_cpu_partial_show() and
> show_slab_objects(), slab->slabs is only used for showing information.
>
> Data-racy reads from shared variables that are used only for diagnostic
> purposes should typically use data_race(), since it is normally not a
> problem if the values are off by a little.
>
> This patch is aimed at reducing the number of benign races reported by
> KCSAN in order to focus future debugging effort on harmful races.
>
> Signed-off-by: linke li <lilinke99@qq.com>
> Reviewed-by: Chengming Zhou <chengming.zhou@linux.dev>
Chengming provided feedback to v1 but not offered a Reviewed-by: AFAICS? Or
maybe will offer it now? :)
Vlastimil
> ---
> mm/slub.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/mm/slub.c b/mm/slub.c
> index 2ef88bbf56a3..0d700f6ca547 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -6052,7 +6052,7 @@ static ssize_t show_slab_objects(struct kmem_cache *s,
> else if (flags & SO_OBJECTS)
> WARN_ON_ONCE(1);
> else
> - x = slab->slabs;
> + x = data_race(slab->slabs);
> total += x;
> nodes[node] += x;
> }
> @@ -6257,7 +6257,7 @@ static ssize_t slabs_cpu_partial_show(struct kmem_cache *s, char *buf)
> slab = slub_percpu_partial(per_cpu_ptr(s->cpu_slab, cpu));
>
> if (slab)
> - slabs += slab->slabs;
> + slabs += data_race(slab->slabs);
> }
> #endif
>
> @@ -6271,7 +6271,7 @@ static ssize_t slabs_cpu_partial_show(struct kmem_cache *s, char *buf)
>
> slab = slub_percpu_partial(per_cpu_ptr(s->cpu_slab, cpu));
> if (slab) {
> - slabs = READ_ONCE(slab->slabs);
> + slabs = data_race(slab->slabs);
> objects = (slabs * oo_objects(s->oo)) / 2;
> len += sysfs_emit_at(buf, len, " C%d=%d(%d)",
> cpu, objects, slabs);
next prev parent reply other threads:[~2024-03-25 8:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-21 3:48 linke li
2024-03-25 8:48 ` Vlastimil Babka [this message]
2024-03-25 8:49 ` Chengming Zhou
2024-03-25 8:51 ` Vlastimil Babka
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=8b146695-4ff5-4f9a-ab64-6cbed4168f98@suse.cz \
--to=vbabka@suse.cz \
--cc=42.hyeyoo@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=chengming.zhou@linux.dev \
--cc=cl@linux.com \
--cc=iamjoonsoo.kim@lge.com \
--cc=lilinke99@qq.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=penberg@kernel.org \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=xujianhao01@gmail.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