Skip to content
Snippets Groups Projects
Commit 7f19c751 authored by Kaiqian Zhu's avatar Kaiqian Zhu Committed by kaiqian zhu
Browse files

BACKPORT: FROMGIT: cgroup/cpuset: Make cpuset hotplug processing synchronous


Since commit 3a5a6d0c("cpuset: don't nest cgroup_mutex inside
get_online_cpus()"), cpuset hotplug was done asynchronously via a work
function. This is to avoid recursive locking of cgroup_mutex.

Since then, the cgroup locking scheme has changed quite a bit. A
cpuset_mutex was introduced to protect cpuset specific operations.
The cpuset_mutex is then replaced by a cpuset_rwsem. With commit
d74b27d6 ("cgroup/cpuset: Change cpuset_rwsem and hotplug lock
order"), cpu_hotplug_lock is acquired before cpuset_rwsem. Later on,
cpuset_rwsem is reverted back to cpuset_mutex. All these locking changes
allow the hotplug code to call into cpuset core directly.

The following commits were also merged due to the asynchronous nature
of cpuset hotplug processing.

- commit b22afcdf ("cpu/hotplug: Cure the cpusets trainwreck")
- commit 50e76632 ("sched/cpuset/pm: Fix cpuset vs. suspend-resume
bugs")
- commit 28b89b9e ("cpuset: handle race between CPU hotplug and
cpuset_hotplug_work")

Clean up all these bandages by making cpuset hotplug
processing synchronous again with the exception that the call to
cgroup_transfer_tasks() to transfer tasks out of an empty cgroup v1
cpuset, if necessary, will still be done via a work function due to the
existing cgroup_mutex -> cpu_hotplug_lock dependency. It is possible
to reverse that dependency, but that will require updating a number of
different cgroup controllers. This special hotplug code path should be
rarely taken anyway.

As all the cpuset states will be updated by the end of the hotplug
operation, we can revert most the above commits except commit
50e76632 ("sched/cpuset/pm: Fix cpuset vs. suspend-resume bugs")
which is partially reverted. Also removing some cpus_read_lock trylock
attempts in the cpuset partition code as they are no longer necessary
since the cpu_hotplug_lock is now held for the whole duration of the
cpuset hotplug code path.

Signed-off-by: default avatarWaiman Long <longman@redhat.com>
Tested-by: default avatarValentin Schneider <vschneid@redhat.com>
Signed-off-by: default avatarTejun Heo <tj@kernel.org>

Bug: 401393559
Bug: 402078031
(cherry picked from commit 2125c003 https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

 master)
[kaiqian: Removed all the cpus_read_trylock() related functions introduced in later cpuset updates]
Change-Id: I252e24629388a0be5746ac4cc3f475ea6767a462
Signed-off-by: default avatarZhu Kaiqian <zhukaiqian@xiaomi.com>
parent 12cad3f6
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment