]> Gentwo Git Trees - linux/.git/commit
cgroup/cpuset: Always use cpu_active_mask
authorWaiman Long <longman@redhat.com>
Mon, 7 Apr 2025 21:21:03 +0000 (17:21 -0400)
committerTejun Heo <tj@kernel.org>
Mon, 7 Apr 2025 22:04:51 +0000 (12:04 -1000)
commit7a0aabd9ce697fc581ec691b21f748050fbcf004
treedad489e5a5358d1917d3e378b1895bdda25f611a
parenta97915559f5c5ff1972d678b94fd460c72a3b5f2
cgroup/cpuset: Always use cpu_active_mask

The current cpuset code uses both cpu_active_mask and cpu_online_mask
and it can be confusing which one should be used if we need to update
the code.

The top_cpuset is always synchronized to cpu_active_mask and we should
avoid using cpu_online_mask as much as possible. An active CPU is always
an online CPU, but not vice versa. cpu_active_mask and cpu_online_mask
can differ during hotplug operations.

A CPU is marked active at the last stage of CPU bringup (CPUHP_AP_ACTIVE).
It is also the stage where cpuset hotplug code will be called to update
the sched domains so that the scheduler can move a normal task to a
newly active CPU or remove tasks away from a newly inactivated CPU. The
online bit is set much earlier in the CPU bringup process and cleared
much later in CPU teardown.

If cpu_online_mask is used while a hotunplug operation is happening in
parallel, we may leave an offline CPU in cpu_allowed or have a higher
chance of leaving an offline CPU in some other masks.  Avoid this
problem by always using cpu_active_mask in the cpuset code and leave
a comment as to why the use of cpu_online_mask is discouraged.

Signed-off-by: Waiman Long <longman@redhat.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/cgroup/cpuset.c