Re: [PATCH] cgroup/cpuset: move PF_EXITING check before __GFP_HARDWALL in cpuset_current_node_allowed()
From: Waiman Long
Date: Thu May 07 2026 - 09:56:54 EST
On 5/7/26 8:33 AM, Michal Koutný wrote:
On Thu, May 07, 2026 at 06:54:34PM +0800, Chen Wandun <chenwandun1@xxxxxxxxx> wrote:
This makes it unreachable in the common case, so dying tasks can get(OTOH, the caused OOM could select this task and bypass the hardwall. So
stuck in direct reclaim or even trigger OOM while trying to exit,
despite being allowed to allocate from any node.
this should only expedite but no unblock the exit path.)
Move the PF_EXITING check before __GFP_HARDWALL so that dying tasksThis makes sense to me on its own (given other hardwall exemptions,
can allocate memory from any node to exit quickly, even when cpusets
are enabled.
namely the commit c596d9f320aaf ("cpusets: allow TIF_MEMDIE threads to
allocate anywhere")).
Acked-by: Michal Koutný <mkoutny@xxxxxxxx>
This looks good to me too.
Acked-by: Waiman Long <longman@xxxxxxxxxx>
At first, I wondered whether this could happen on cpuset v2 -- it can --
because only per-cpuset hardwalling is absent but the generic logic for
GFP_USER allocations is still meant to be in place. Nevertheless, it
occured to me we can spare callback_lock in this function (a separate
chaneg for cpuset_current_node_allowed()):
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -4213,6 +4213,9 @@ bool cpuset_current_node_allowed(int node, gfp_t gfp_mask)
if (current->flags & PF_EXITING) /* Let dying task have memory */
return true;
+ if (is_in_v2_mode())
+ return true;
+
/* Not hardwall and node outside mems_allowed: scan up cpusets */
spin_lock_irqsave(&callback_lock, flags);
Yes, it is a performance optimization that is worth to have as cgroup v2 doesn't have the concept of memory hardwall yet.
Cheers,
Longman