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

Message ID 20230120150246.20797-5-wander@redhat.com
State New
Headers
Series Fix put_task_struct() calls under PREEMPT_RT |

Commit Message

Wander Lairson Costa Jan. 20, 2023, 3:02 p.m. UTC
  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(-)
  

Patch

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;
 }