Skip to content

Commit 1aabbc5

Browse files
Sebastian Andrzej SiewiorKAGA-KOKO
Sebastian Andrzej Siewior
authored andcommitted
signal: Don't disable preemption in ptrace_stop() on PREEMPT_RT
On PREEMPT_RT keeping preemption disabled during the invocation of cgroup_enter_frozen() is a problem because the function acquires css_set_lock which is a sleeping lock on PREEMPT_RT and must not be acquired with disabled preemption. The preempt-disabled section is only for performance optimisation reasons and can be avoided. Extend the comment and don't disable preemption before scheduling on PREEMPT_RT. Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: Oleg Nesterov <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent a20d6f6 commit 1aabbc5

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

kernel/signal.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2345,11 +2345,22 @@ static int ptrace_stop(int exit_code, int why, unsigned long message,
23452345
* will be no preemption between unlock and schedule() and so
23462346
* improving the performance since the ptracer will observe that
23472347
* the tracee is scheduled out once it gets on the CPU.
2348+
*
2349+
* On PREEMPT_RT locking tasklist_lock does not disable preemption.
2350+
* Therefore the task can be preempted after do_notify_parent_cldstop()
2351+
* before unlocking tasklist_lock so there is no benefit in doing this.
2352+
*
2353+
* In fact disabling preemption is harmful on PREEMPT_RT because
2354+
* the spinlock_t in cgroup_enter_frozen() must not be acquired
2355+
* with preemption disabled due to the 'sleeping' spinlock
2356+
* substitution of RT.
23482357
*/
2349-
preempt_disable();
2358+
if (!IS_ENABLED(CONFIG_PREEMPT_RT))
2359+
preempt_disable();
23502360
read_unlock(&tasklist_lock);
23512361
cgroup_enter_frozen();
2352-
preempt_enable_no_resched();
2362+
if (!IS_ENABLED(CONFIG_PREEMPT_RT))
2363+
preempt_enable_no_resched();
23532364
schedule();
23542365
cgroup_leave_frozen(true);
23552366

0 commit comments

Comments
 (0)