[merged mm-stable] mm-annotate-data-race-in-cpu_needs_drain.patch removed from -mm tree
Andrew Morton <[email protected]> Tue, 28 Jul 2026 21:14:44 -0700
| Newsgroups | org.kernel.vger.mm-commits |
|---|---|
| Message-ID | <[email protected]> |
The quilt patch titled
Subject: mm: annotate data-race in cpu_needs_drain()
has been removed from the -mm tree. Its filename was
mm-annotate-data-race-in-cpu_needs_drain.patch
This patch was dropped because it was merged into the mm-stable branch
of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: Xuewen Wang <[email protected]>
Subject: mm: annotate data-race in cpu_needs_drain()
Date: Fri, 26 Jun 2026 13:37:00 +0800
KCSAN reports a data-race when cpu_needs_drain() reads another CPU's
per-cpu folio_batch->nr without locking, while the owning CPU writes to it
via folio_batch_add().
Reading a slightly stale value is harmless -- cpu_needs_drain() only
decides whether to schedule a drain, and the next iteration of
__lru_add_drain_all() will re-check. Use data_race() to annotate the
intentional race.
[[email protected]: reindent cpu_needs_drain, per David & Lorenzo]
Link: https://lore.kernel.org/[email protected]
Signed-off-by: Xuewen Wang <[email protected]>
Acked-by: David Hildenbrand (Arm) <[email protected]>
Reviewed-by: Pedro Falcato <[email protected]>
Reviewed-by: Lorenzo Stoakes <[email protected]>
Cc: Axel Rasmussen <[email protected]>
Cc: Baoquan He <[email protected]>
Cc: Barry Song <[email protected]>
Cc: Chris Li <[email protected]>
Cc: Jann Horn <[email protected]>
Cc: Kairui Song <[email protected]>
Cc: Kemeng Shi <[email protected]>
Cc: Liam R. Howlett <[email protected]>
Cc: Nhat Pham <[email protected]>
Cc: Shakeel Butt <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Cc: Wei Xu <[email protected]>
Cc: Yuanchu Xie <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
---
mm/swap.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
--- a/mm/swap.c~mm-annotate-data-race-in-cpu_needs_drain
+++ a/mm/swap.c
@@ -831,13 +831,13 @@ static bool cpu_needs_drain(unsigned int
struct cpu_fbatches *fbatches = &per_cpu(cpu_fbatches, cpu);
/* Check these in order of likelihood that they're not zero */
- return folio_batch_count(&fbatches->lru_add) ||
- folio_batch_count(&fbatches->lru_move_tail) ||
- folio_batch_count(&fbatches->lru_deactivate_file) ||
- folio_batch_count(&fbatches->lru_deactivate) ||
- folio_batch_count(&fbatches->lru_lazyfree) ||
- folio_batch_count(&fbatches->lru_activate) ||
- need_mlock_drain(cpu) ||
+ return data_race(folio_batch_count(&fbatches->lru_add) ||
+ folio_batch_count(&fbatches->lru_move_tail) ||
+ folio_batch_count(&fbatches->lru_deactivate_file) ||
+ folio_batch_count(&fbatches->lru_deactivate) ||
+ folio_batch_count(&fbatches->lru_lazyfree) ||
+ folio_batch_count(&fbatches->lru_activate) ||
+ need_mlock_drain(cpu)) ||
has_bh_in_lru(cpu, NULL);
}
_
Patches currently in -mm which might be from [email protected] are
mm-damon-remove-trailing-semicolons-after-function-definitions.patch