All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm/slub: mark racy access on slab->freelist
@ 2024-04-27  8:51 linke li
  2024-04-28  8:10 ` David Rientjes
  2024-05-02 12:23 ` Vlastimil Babka
  0 siblings, 2 replies; 4+ messages in thread
From: linke li @ 2024-04-27  8:51 UTC (permalink / raw)
  Cc: xujianhao01, linke li, Christoph Lameter, Pekka Enberg,
	David Rientjes, Joonsoo Kim, Andrew Morton, Vlastimil Babka,
	Roman Gushchin, Hyeonggon Yoo, linux-mm, linux-kernel

In deactivate_slab(), slab->freelist can be changed concurrently. Mark
data race on slab->freelist as benign using READ_ONCE.

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>
---
 mm/slub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/slub.c b/mm/slub.c
index 0d700f6ca547..bb0e05a321e9 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -2813,7 +2813,7 @@ static void deactivate_slab(struct kmem_cache *s, struct slab *slab,
 	struct slab new;
 	struct slab old;
 
-	if (slab->freelist) {
+	if (READ_ONCE(slab->freelist)) {
 		stat(s, DEACTIVATE_REMOTE_FREES);
 		tail = DEACTIVATE_TO_TAIL;
 	}
-- 
2.39.3 (Apple Git-146)


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] mm/slub: mark racy access on slab->freelist
  2024-04-27  8:51 [PATCH] mm/slub: mark racy access on slab->freelist linke li
@ 2024-04-28  8:10 ` David Rientjes
  2024-04-29  2:25   ` linke li
  2024-05-02 12:23 ` Vlastimil Babka
  1 sibling, 1 reply; 4+ messages in thread
From: David Rientjes @ 2024-04-28  8:10 UTC (permalink / raw)
  To: linke li
  Cc: xujianhao01, Christoph Lameter, Pekka Enberg, Joonsoo Kim,
	Andrew Morton, Vlastimil Babka, Roman Gushchin, Hyeonggon Yoo,
	linux-mm, linux-kernel

On Sat, 27 Apr 2024, linke li wrote:

> In deactivate_slab(), slab->freelist can be changed concurrently. Mark
> data race on slab->freelist as benign using READ_ONCE.
> 
> This patch is aimed at reducing the number of benign races reported by
> KCSAN in order to focus future debugging effort on harmful races.
> 

Thanks!  Do you have a data race report to copy+paste into the commit 
description so people can search for it if they stumble across the same 
thing?

> Signed-off-by: linke li <lilinke99@qq.com>
> ---
>  mm/slub.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/slub.c b/mm/slub.c
> index 0d700f6ca547..bb0e05a321e9 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -2813,7 +2813,7 @@ static void deactivate_slab(struct kmem_cache *s, struct slab *slab,
>  	struct slab new;
>  	struct slab old;
>  
> -	if (slab->freelist) {
> +	if (READ_ONCE(slab->freelist)) {
>  		stat(s, DEACTIVATE_REMOTE_FREES);
>  		tail = DEACTIVATE_TO_TAIL;
>  	}
> -- 
> 2.39.3 (Apple Git-146)
> 
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mm/slub: mark racy access on slab->freelist
  2024-04-28  8:10 ` David Rientjes
@ 2024-04-29  2:25   ` linke li
  0 siblings, 0 replies; 4+ messages in thread
From: linke li @ 2024-04-29  2:25 UTC (permalink / raw)
  To: rientjes
  Cc: 42.hyeyoo, akpm, cl, iamjoonsoo.kim, lilinke99, linux-kernel,
	linux-mm, penberg, roman.gushchin, vbabka, xujianhao01

> Thanks!  Do you have a data race report to copy+paste into the commit 
> description so people can search for it if they stumble across the same 
> thing?

I don't have a data race report, just try to analyze the code statically
and then check it manually. I hope I could help in some way.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mm/slub: mark racy access on slab->freelist
  2024-04-27  8:51 [PATCH] mm/slub: mark racy access on slab->freelist linke li
  2024-04-28  8:10 ` David Rientjes
@ 2024-05-02 12:23 ` Vlastimil Babka
  1 sibling, 0 replies; 4+ messages in thread
From: Vlastimil Babka @ 2024-05-02 12:23 UTC (permalink / raw)
  To: linke li
  Cc: xujianhao01, Christoph Lameter, Pekka Enberg, David Rientjes,
	Joonsoo Kim, Andrew Morton, Roman Gushchin, Hyeonggon Yoo,
	linux-mm, linux-kernel

On 4/27/24 10:51, linke li wrote:
> In deactivate_slab(), slab->freelist can be changed concurrently. Mark
> data race on slab->freelist as benign using READ_ONCE.
> 
> 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>

Added to slab/for-6.10, thanks

> ---
>  mm/slub.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/slub.c b/mm/slub.c
> index 0d700f6ca547..bb0e05a321e9 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -2813,7 +2813,7 @@ static void deactivate_slab(struct kmem_cache *s, struct slab *slab,
>  	struct slab new;
>  	struct slab old;
>  
> -	if (slab->freelist) {
> +	if (READ_ONCE(slab->freelist)) {
>  		stat(s, DEACTIVATE_REMOTE_FREES);
>  		tail = DEACTIVATE_TO_TAIL;
>  	}

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-05-02 12:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-27  8:51 [PATCH] mm/slub: mark racy access on slab->freelist linke li
2024-04-28  8:10 ` David Rientjes
2024-04-29  2:25   ` linke li
2024-05-02 12:23 ` Vlastimil Babka

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.