Skip to content

Commit d8ef4b3

Browse files
committed
Revert "cgroup: Add memory barriers to plug cgroup_rstat_updated() race window"
This reverts commit 9a9e97b ("cgroup: Add memory barriers to plug cgroup_rstat_updated() race window"). The commit was added in anticipation of memcg rstat conversion which needed synchronous accounting for the event counters (e.g. oom kill count). However, the conversion didn't get merged due to percpu memory overhead concern which couldn't be addressed at the time. Unfortunately, the patch's addition of smp_mb() to cgroup_rstat_updated() meant that every scheduling event now had to go through an additional full barrier and Mel Gorman noticed it as 1% regression in netperf UDP_STREAM test. There's no need to have this barrier in tree now and even if we need synchronous accounting in the future, the right thing to do is separating that out to a separate function so that hot paths which don't care about synchronous behavior don't have to pay the overhead of the full barrier. Let's revert. Signed-off-by: Tejun Heo <[email protected]> Reported-by: Mel Gorman <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Cc: v4.18+
1 parent 87ebc45 commit d8ef4b3

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

kernel/cgroup/rstat.c

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,9 @@ void cgroup_rstat_updated(struct cgroup *cgrp, int cpu)
3333
return;
3434

3535
/*
36-
* Paired with the one in cgroup_rstat_cpu_pop_updated(). Either we
37-
* see NULL updated_next or they see our updated stat.
38-
*/
39-
smp_mb();
40-
41-
/*
36+
* Speculative already-on-list test. This may race leading to
37+
* temporary inaccuracies, which is fine.
38+
*
4239
* Because @parent's updated_children is terminated with @parent
4340
* instead of NULL, we can tell whether @cgrp is on the list by
4441
* testing the next pointer for NULL.
@@ -134,13 +131,6 @@ static struct cgroup *cgroup_rstat_cpu_pop_updated(struct cgroup *pos,
134131
*nextp = rstatc->updated_next;
135132
rstatc->updated_next = NULL;
136133

137-
/*
138-
* Paired with the one in cgroup_rstat_cpu_updated().
139-
* Either they see NULL updated_next or we see their
140-
* updated stat.
141-
*/
142-
smp_mb();
143-
144134
return pos;
145135
}
146136

0 commit comments

Comments
 (0)