* [PATCH] mm/vmstat: annotate data race for zone->free_area[order].nr_free
@ 2021-09-08 1:56 Liu Shixin
2021-09-15 4:10 ` Andrew Morton
0 siblings, 1 reply; 2+ messages in thread
From: Liu Shixin @ 2021-09-08 1:56 UTC (permalink / raw)
To: Andrew Morton, Paul E . McKenney; +Cc: linux-mm, linux-kernel, Liu Shixin
KCSAN reports a data-race on v5.10 which also exists on mainline:
==================================================================
BUG: KCSAN: data-race in extfrag_for_order+0x33/0x2d0
race at unknown origin, with read to 0xffff9ee9bfffab48 of 8 bytes by task 34 on cpu 1:
extfrag_for_order+0x33/0x2d0
kcompactd+0x5f0/0xce0
kthread+0x1f9/0x220
ret_from_fork+0x22/0x30
Reported by Kernel Concurrency Sanitizer on:
CPU: 1 PID: 34 Comm: kcompactd0 Not tainted 5.10.0+ #2
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Ubuntu-1.8.2-1ubuntu1 04/01/2014
==================================================================
Access to zone->free_area[order].nr_free in extfrag_for_order()/frag_show_print()
is lockless. That's intentional and the stats are a rough estimate anyway.
Annotate them with data_race().
Signed-off-by: Liu Shixin <liushixin2@huawei.com>
---
mm/vmstat.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mm/vmstat.c b/mm/vmstat.c
index 0885a34197b7..17d1f9ec4fd4 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -1023,7 +1023,7 @@ static void fill_contig_page_info(struct zone *zone,
unsigned long blocks;
/* Count number of free blocks */
- blocks = zone->free_area[order].nr_free;
+ blocks = data_race(zone->free_area[order].nr_free);
info->free_blocks_total += blocks;
/* Count free base pages */
@@ -1397,7 +1397,7 @@ static void frag_show_print(struct seq_file *m, pg_data_t *pgdat,
seq_printf(m, "Node %d, zone %8s ", pgdat->node_id, zone->name);
for (order = 0; order < MAX_ORDER; ++order)
- seq_printf(m, "%6lu ", zone->free_area[order].nr_free);
+ seq_printf(m, "%6lu ", data_race(zone->free_area[order].nr_free));
seq_putc(m, '\n');
}
--
2.18.0.huawei.25
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mm/vmstat: annotate data race for zone->free_area[order].nr_free
2021-09-08 1:56 [PATCH] mm/vmstat: annotate data race for zone->free_area[order].nr_free Liu Shixin
@ 2021-09-15 4:10 ` Andrew Morton
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2021-09-15 4:10 UTC (permalink / raw)
To: Liu Shixin; +Cc: Paul E . McKenney, linux-mm, linux-kernel
On Wed, 8 Sep 2021 09:56:06 +0800 Liu Shixin <liushixin2@huawei.com> wrote:
> KCSAN reports a data-race on v5.10 which also exists on mainline:
>
> ==================================================================
> BUG: KCSAN: data-race in extfrag_for_order+0x33/0x2d0
>
> race at unknown origin, with read to 0xffff9ee9bfffab48 of 8 bytes by task 34 on cpu 1:
> extfrag_for_order+0x33/0x2d0
> kcompactd+0x5f0/0xce0
> kthread+0x1f9/0x220
> ret_from_fork+0x22/0x30
>
> Reported by Kernel Concurrency Sanitizer on:
> CPU: 1 PID: 34 Comm: kcompactd0 Not tainted 5.10.0+ #2
> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Ubuntu-1.8.2-1ubuntu1 04/01/2014
> ==================================================================
>
> Access to zone->free_area[order].nr_free in extfrag_for_order()/frag_show_print()
> is lockless. That's intentional and the stats are a rough estimate anyway.
> Annotate them with data_race().
checkpatch helpfully says
WARNING: data_race without comment
#40: FILE: mm/vmstat.c:1074:
+ blocks = data_race(zone->free_area[order].nr_free);
can we please add a comment ;)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-09-15 4:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-08 1:56 [PATCH] mm/vmstat: annotate data race for zone->free_area[order].nr_free Liu Shixin
2021-09-15 4:10 ` Andrew Morton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).