[PATCH v2 4/4] sched/core: use put_task_struct_atomic_safe() to avoid potential splat

Wander Lairson Costa
2023-01-20T15:04:43Z

push_cpu_stop() is called form a context in which it must not sleep.
Since push_cpu_stop() calls put_task_struct(), it potentially can sleep
under PREEMPT_RT if the usage count reaches zero.

Use put_task_struct_atomic_safe(0 instead to avoid this potential splat.

Signed-off-by: Wander Lairson Costa <wander@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
---
kernel/sched/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index c437260e19b0..e5d0c66cb90c 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2565,7 +2565,7 @@ int push_cpu_stop(void *arg)
raw_spin_rq_unlock(rq);
raw_spin_unlock_irq(&p->pi_lock);

- put_task_struct(p);
+ put_task_struct_atomic_safe(p);
return 0;
}

--
2.39.0