cgroup: rstat: Mark benign data race to silence KCSAN
authorMichal Koutný <mkoutny@suse.com>
Wed, 3 Nov 2021 16:58:45 +0000 (17:58 +0100)
committerTejun Heo <tj@kernel.org>
Mon, 15 Nov 2021 21:34:17 +0000 (11:34 -1000)
There is a race between updaters and flushers (flush can possibly miss
the latest update(s)). This is expected as explained in
cgroup_rstat_updated() comment, add also machine readable annotation so
that KCSAN results aren't noisy.

Reported-by: Hao Sun <sunhao.th@gmail.com>
Link: https://lore.kernel.org/r/CACkBjsbPVdkub=e-E-p1WBOLxS515ith-53SFdmFHWV_QMo40w@mail.gmail.com
Suggested-by: Hao Sun <sunhao.th@gmail.com>
Signed-off-by: Michal Koutný <mkoutny@suse.com>
Reviewed-by: Shakeel Butt <shakeelb@google.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/cgroup/rstat.c

index 1486768f23185ebb4a79fead2deffe1a3ceb7c57..1abe7411452718a4a1b7b03a6daae31cf41e1410 100644 (file)
@@ -35,7 +35,7 @@ void cgroup_rstat_updated(struct cgroup *cgrp, int cpu)
         * instead of NULL, we can tell whether @cgrp is on the list by
         * testing the next pointer for NULL.
         */
-       if (cgroup_rstat_cpu(cgrp, cpu)->updated_next)
+       if (data_race(cgroup_rstat_cpu(cgrp, cpu)->updated_next))
                return;
 
        raw_spin_lock_irqsave(cpu_lock, flags);