]> git.baikalelectronics.ru Git - kernel.git/commit
fs/namespace: Boost the mount_lock.lock owner instead of spinning on PREEMPT_RT.
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>
Thu, 25 Nov 2021 12:07:11 +0000 (13:07 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Fri, 26 Nov 2021 11:09:09 +0000 (12:09 +0100)
commitf1296de6d4b0aecad63708166c77d7466105d35d
tree95089eb557bdf7a7e67a1396819052d074ae1ec5
parent183b8c70348e8991bc1bb81710777587b8549f2a
fs/namespace: Boost the mount_lock.lock owner instead of spinning on PREEMPT_RT.

The MNT_WRITE_HOLD flag is used to hold back any new writers while the
mount point is about to be made read-only. __mnt_want_write() then loops
with disabled preemption until this flag disappears. Callers of
mnt_hold_writers() (which sets the flag) hold the spinlock_t of
mount_lock (seqlock_t) which disables preemption on !PREEMPT_RT and
ensures the task is not scheduled away so that the spinning side spins
for a long time.

On PREEMPT_RT the spinlock_t does not disable preemption and so it is
possible that the task setting MNT_WRITE_HOLD is preempted by task with
higher priority which then spins infinitely waiting for MNT_WRITE_HOLD
to get removed.

Acquire mount_lock::lock which is held by setter of MNT_WRITE_HOLD. This
will PI-boost the owner and wait until the lock is dropped and which
means that MNT_WRITE_HOLD is cleared again.

Link: https://lore.kernel.org/r/20211025152218.opvcqfku2lhqvp4o@linutronix.de
Link: https://lore.kernel.org/r/20211125120711.dgbsienyrsxfzpoi@linutronix.de
Acked-by: Christian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
fs/namespace.c