Skip to contentSkip to conversation

block/blk-cgroup-rwstat: use data_race() for online test

PATCH Superseded Tao Cui 2 participants 2 messages Aug 2 – Aug 3

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Tao Cui

author
#0 lore raw

PATCH 1/1 block/blk-cgroup-rwstat: use data_race() for online test

From: Tao Cui <[email protected]>

blkg_rwstat_recursive_sum() reads pos_blkg->online without the queue lock that its doc comment requires, since blkcg_print_blkgs() stopped holding it in 56cc24f59c14. Concurrent blkg_create/destroy flips ->online, tripping KCSAN. The race is harmless (RCU-protected, stale online only causes minor stat noise). Use data_race() to annotate the intentional lockless read.

---
 block/blk-cgroup-rwstat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
block/blk-cgroup-rwstat.c +1 -1
index aae910713814..71f74052ae03 100644
@@ -107,7 +107,7 @@ void blkg_rwstat_recursive_sum(struct blkcg_gq *blkg, struct blkcg_policy *pol,
 	blkg_for_each_descendant_pre(pos_blkg, pos_css, blkg) {
 		struct blkg_rwstat *rwstat;
 
-		if (!pos_blkg->online)
+		if (!data_race(pos_blkg->online))
 			continue;
 
 		if (pol) {
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Tao Cui

From: Tao Cui<[email protected]>

blkg_rwstat_recursive_sum() reads pos_blkg->online without the queue lock that its doc comment requires, since blkcg_print_blkgs() stopped holding it in 56cc24f59c14. Concurrent blkg_create/destroy flips ->online, tripping KCSAN. The race is harmless (RCU-protected, stale online only causes minor stat noise). Use data_race() to annotate the intentional lockless read.

Quoted 4 lines
---
  block/blk-cgroup-rwstat.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 2 lines
Thanks,
Kuai