]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
cgroup/cpuset: move PF_EXITING check before __GFP_HARDWALL in cpuset_current_node_all...
authorChen Wandun <chenwandun@lixiang.com>
Thu, 7 May 2026 10:54:34 +0000 (18:54 +0800)
committerTejun Heo <tj@kernel.org>
Thu, 7 May 2026 21:57:31 +0000 (11:57 -1000)
commitdde2f938d02f2c740d49bb5113dea941f941026a
tree91c81508a1d7bd89e2a83200138d5965a188d218
parentd8769544bde51b0ac980d10f8fe9f9fed6c95995
cgroup/cpuset: move PF_EXITING check before __GFP_HARDWALL in cpuset_current_node_allowed()

Since prepare_alloc_pages() unconditionally adds __GFP_HARDWALL for the
fast path when cpusets are enabled, the __GFP_HARDWALL check in
cpuset_current_node_allowed() causes the PF_EXITING escape path to be
skipped on the first allocation attempt.  This makes it unreachable in
the common case, so dying tasks can get stuck in direct reclaim or even
trigger OOM while trying to exit, despite being allowed to allocate from
any node.

Move the PF_EXITING check before __GFP_HARDWALL so that dying tasks
can allocate memory from any node to exit quickly, even when cpusets
are enabled.

Also update the function comment to reflect the actual behavior of
prepare_alloc_pages() and the corrected check ordering.

Signed-off-by: Chen Wandun <chenwandun@lixiang.com>
Acked-by: Michal Koutný <mkoutny@suse.com>
Acked-by: Waiman Long <longman@redhat.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/cgroup/cpuset.c