* sched: restore the behavior of put_task_struct() for non-rt
@ 2025-08-01 12:24 Luis Claudio R. Goncalves
0 siblings, 0 replies; only message in thread
From: Luis Claudio R. Goncalves @ 2025-08-01 12:24 UTC (permalink / raw)
To: Oleg Nesterov, Peter Zijlstra, Sebastian Andrzej Siewior,
Clark Williams, Steven Rostedt, Tejun Heo, David Vernet,
Barret Rhoden, Josh Don, Crystal Wood, linux-kernel,
linux-rt-devel, Juri Lelli, Ben Segall, Dietmar Eggemann,
Ingo Molnar, Mel Gorman, Valentin Schneider, Vincent Guittot,
Thomas Gleixner, Wander Lairson Costa
Commit 8671bad873eb ("sched: Do not call __put_task_struct() on rt
if pi_blocked_on is set") changed the behavior of put_task_struct()
unconditionally, even when PREEMPT_RT was not enabled, in clear mismatch
with the commit description.
Restore the previous behavior of put_task_struct() for the PREEMPT_RT
disabled case.
Fixes: 8671bad873eb ("sched: Do not call __put_task_struct() on rt if pi_blocked_on is set")
Acked-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Luis Claudio R. Goncalves <lgoncalv@redhat.com>
---
diff --git a/include/linux/sched/task.h b/include/linux/sched/task.h
index ea41795a352b..51678a541477 100644
--- a/include/linux/sched/task.h
+++ b/include/linux/sched/task.h
@@ -130,6 +133,16 @@ static inline void put_task_struct(struct task_struct *t)
if (!refcount_dec_and_test(&t->usage))
return;
+ /* In !RT, it is always safe to call __put_task_struct(). */
+ if (!IS_ENABLED(CONFIG_PREEMPT_RT)) {
+ static DEFINE_WAIT_OVERRIDE_MAP(put_task_map, LD_WAIT_SLEEP);
+
+ lock_map_acquire_try(&put_task_map);
+ __put_task_struct(t);
+ lock_map_release(&put_task_map);
+ return;
+ }
+
/*
* Under PREEMPT_RT, we can't call __put_task_struct
* in atomic context because it will indirectly
@@ -137,10 +150,6 @@ static inline void put_task_struct(struct task_struct *t)
* current process has a mutex enqueued (blocked on
* a PI chain).
*
- * In !RT, it is always safe to call __put_task_struct().
- * Though, in order to simplify the code, resort to the
- * deferred call too.
- *
* call_rcu() will schedule __put_task_struct_rcu_cb()
* to be called in process context.
*
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2025-08-01 12:24 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-01 12:24 sched: restore the behavior of put_task_struct() for non-rt Luis Claudio R. Goncalves
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).