seqlock: PREEMPT_RT: Do not starve seqlock_t writers
authorAhmed S. Darwish <a.darwish@linutronix.de>
Fri, 4 Sep 2020 15:32:31 +0000 (17:32 +0200)
committerPeter Zijlstra <peterz@infradead.org>
Thu, 10 Sep 2020 09:19:31 +0000 (11:19 +0200)
commit1909760f5fc3f123e47b4e24e0ccdc0fc8f3f106
tree1f7dad932b8d63072722041e21c1b4a3315a7a4f
parent8117ab508f9c476e0a10b9db7f4818f784cf3176
seqlock: PREEMPT_RT: Do not starve seqlock_t writers

On PREEMPT_RT, seqlock_t is transformed to a sleeping lock that do not
disable preemption. A seqlock_t reader can thus preempt its write side
section and spin for the enter scheduler tick. If that reader belongs to
a real-time scheduling class, it can spin forever and the kernel will
livelock.

To break this livelock possibility on PREEMPT_RT, implement seqlock_t in
terms of "seqcount_spinlock_t" instead of plain "seqcount_t".

Beside its pure annotational value, this will leverage the existing
seqcount_LOCKNAME_T PREEMPT_RT anti-livelock mechanisms, without adding
any extra code.

Signed-off-by: Ahmed S. Darwish <a.darwish@linutronix.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20200904153231.11994-6-a.darwish@linutronix.de
include/linux/seqlock.h