Skip to contentSkip to conversation

cgroup/cpuset: Wake up cpuset_attach_wq tasks in cpuset_cancel_attach()

PATCH New Waiman Long 1 participant 1 message Apr 17, 2023 Stable branch

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cgroup/cpuset: Wake up cpuset_attach_wq tasks in cpuset_cancel_attach()

commit ba9182a89626d5f83c2ee4594f55cb9c1e60f0e2 upstream.

After a successful cpuset_can_attach() call which increments the attach_in_progress flag, either cpuset_cancel_attach() or cpuset_attach() will be called later. In cpuset_attach(), tasks in cpuset_attach_wq, if present, will be woken up at the end. That is not the case in cpuset_cancel_attach(). So missed wakeup is possible if the attach operation is somehow cancelled. Fix that by doing the wakeup in cpuset_cancel_attach() as well.

Fixes e44193d39e8d ("cpuset: let hotplug propagation work wait for task attaching")
Cc [email protected] # v3.11+
---
 kernel/cgroup/cpuset.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/cgroup/cpuset.c +3 -1
index 0b82e3857d33..20c1ccc6a0bb 100644
@@ -1508,7 +1508,9 @@ static void cpuset_cancel_attach(struct cgroup_taskset *tset)
 	cs = css_cs(css);
 
 	mutex_lock(&cpuset_mutex);
-	css_cs(css)->attach_in_progress--;
+	cs->attach_in_progress--;
+	if (!cs->attach_in_progress)
+		wake_up(&cpuset_attach_wq);
 	mutex_unlock(&cpuset_mutex);
 }
 
Signature · 1 line
2.31.1