]> git.baikalelectronics.ru Git - kernel.git/commit
sched: Make cond_resched_lock() variants RT aware
authorThomas Gleixner <tglx@linutronix.de>
Thu, 23 Sep 2021 16:54:44 +0000 (18:54 +0200)
committerPeter Zijlstra <peterz@infradead.org>
Fri, 1 Oct 2021 11:57:51 +0000 (13:57 +0200)
commitf7933d68b5e0ab39920d42ab4d512b77c059daac
tree71b840a99263940d42c5d3fbe357f42817e83813
parent4cad14a782c6490918dfd5a67e14e5d8f0224f57
sched: Make cond_resched_lock() variants RT aware

The __might_resched() checks in the cond_resched_lock() variants use
PREEMPT_LOCK_OFFSET for preempt count offset checking which takes the
preemption disable by the spin_lock() which is still held at that point
into account.

On PREEMPT_RT enabled kernels spin/rw_lock held sections stay preemptible
which means PREEMPT_LOCK_OFFSET is 0, but that still triggers the
__might_resched() check because that takes RCU read side nesting into
account.

On RT enabled kernels spin/read/write_lock() issue rcu_read_lock() to
resemble the !RT semantics, which means in cond_resched_lock() the might
resched check will see preempt_count() == 0 and rcu_preempt_depth() == 1.

Introduce PREEMPT_LOCK_SCHED_OFFSET for those might resched checks and map
them depending on CONFIG_PREEMPT_RT.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20210923165358.305969211@linutronix.de
include/linux/preempt.h
include/linux/sched.h