RFC: FROMLIST: cgroup: avoid synchronize_sched() in __cgroup_procs_write()
authorPeter Zijlstra <peterz@infradead.org>
Thu, 11 Aug 2016 16:54:13 +0000 (18:54 +0200)
committerAmit Pundir <amit.pundir@linaro.org>
Wed, 14 Sep 2016 08:56:20 +0000 (14:26 +0530)
commita81c69e149012f7437d8edd9e84ca141c2228cd6
tree2e3199189ed7e38c9a91ffb6a934114e396e18e7
parentd4d74af4b871915fe926d2f267e311949e0bf4b4
RFC: FROMLIST: cgroup: avoid synchronize_sched() in __cgroup_procs_write()

The current percpu-rwsem read side is entirely free of serializing insns
at the cost of having a synchronize_sched() in the write path.

The latency of the synchronize_sched() is too high for cgroups. The
commit 1ed1328792ff talks about the write path being a fairly cold path
but this is not the case for Android which moves task to the foreground
cgroup and back around binder IPC calls from foreground processes to
background processes, so it is significantly hotter than human initiated
operations.

Switch cgroup_threadgroup_rwsem into the slow mode for now to avoid the
problem, hopefully it should not be that slow after another commit
80127a39681b ("locking/percpu-rwsem: Optimize readers and reduce global
impact").

We could just add rcu_sync_enter() into cgroup_init() but we do not want
another synchronize_sched() at boot time, so this patch adds the new helper
which doesn't block but currently can only be called before the first use.

Cc: Tejun Heo <tj@kernel.org>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Reported-by: John Stultz <john.stultz@linaro.org>
Reported-by: Dmitry Shmidt <dimitrysh@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
[jstultz: backported to 4.4]
Change-Id: I34aa9c394d3052779b56976693e96d861bd255f2
Mailing-list-URL: https://lkml.org/lkml/2016/8/11/557
Signed-off-by: John Stultz <john.stultz@linaro.org>
include/linux/rcu_sync.h
kernel/cgroup.c
kernel/rcu/sync.c