All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] fs/dcache: avoid trylock loops
@ 2018-02-16 15:09 John Ogness
  2018-02-16 15:09 ` [PATCH 1/4] fs/dcache: Remove stale comment from dentry_kill() John Ogness
                   ` (3 more replies)
  0 siblings, 4 replies; 22+ messages in thread
From: John Ogness @ 2018-02-16 15:09 UTC (permalink / raw)
  To: linux-fsdevel
  Cc: Al Viro, Linus Torvalds, Christoph Hellwig, Thomas Gleixner,
	Peter Zijlstra, Sebastian Andrzej Siewior, linux-kernel

This patchset removes all trylock loops from within the dcache code.

Both d_delete() and dentry_kill() hold dentry->d_lock while needing
to acquire dentry->d_inode->i_lock. dentry_kill() also needs to
acquire dentry->d_parent->d_lock. This cannot be done directly with
spin_lock() operations because it is the reverse of the regular lock
order. To avoid ABBA deadlocks it is done using trylock loops.

Trylock loops are problematic in two scenarios:

  1) PREEMPT_RT converts spinlocks to 'sleeping' spinlocks, which are
     preemptible. As a consequence the i_lock holder can be preempted
     by a higher priority task. If that task executes the trylock
     loop it will do so forever and live lock.

  2) In virtual machines trylock loops are problematic as well. The
     VCPU on which the i_lock holder runs can be scheduled out and a
     task on a different VCPU can loop for a whole time slice. In the
     worst case this can lead to starvation. Commits 47be61845c77
     ("fs/dcache.c: avoid soft-lockup in dput()") and 046b961b45f9
     ("shrink_dentry_list(): take parent's d_lock earlier") are
     addressing exactly those symptoms.

The trylock loops can be avoided with functionality similar to
lock_parent(); temporarily dropping dentry->d_lock while holding
the rcu_read_lock so that the desired locks can be acquired in the
correct order. After the locks are acquired it is necessary to verify
that the relevant dentry members did not change while dentry->d_lock
was dropped. If they changed, the whole operation must be repeated.

John Ogness (4):
  fs/dcache: Remove stale comment from dentry_kill()
  fs/dcache: Move dentry_kill() below lock_parent()
  fs/dcache: Avoid the try_lock loop in d_delete()
  fs/dcache: Avoid the try_lock loops in dentry_kill()

 fs/dcache.c | 179 ++++++++++++++++++++++++++++++++++++++++++++++--------------
 1 file changed, 139 insertions(+), 40 deletions(-)

-- 
2.11.0

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2018-02-22  8:35 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-16 15:09 [PATCH 0/4] fs/dcache: avoid trylock loops John Ogness
2018-02-16 15:09 ` [PATCH 1/4] fs/dcache: Remove stale comment from dentry_kill() John Ogness
2018-02-16 15:09 ` [PATCH 2/4] fs/dcache: Move dentry_kill() below lock_parent() John Ogness
2018-02-16 15:09 ` [PATCH 3/4] fs/dcache: Avoid the try_lock loop in d_delete() John Ogness
2018-02-16 17:10   ` Peter Zijlstra
2018-02-16 17:30   ` Peter Zijlstra
2018-02-22  5:18   ` Al Viro
2018-02-22  8:35     ` John Ogness
2018-02-16 15:09 ` [PATCH 4/4] fs/dcache: Avoid the try_lock loops in dentry_kill() John Ogness
2018-02-16 18:03   ` Linus Torvalds
2018-02-16 22:32     ` John Ogness
2018-02-16 22:42       ` Linus Torvalds
2018-02-16 23:05         ` John Ogness
2018-02-16 23:31           ` Linus Torvalds
2018-02-16 23:49             ` John Ogness
2018-02-17  0:06               ` Linus Torvalds
2018-02-19 23:34                 ` John Ogness
2018-02-20  0:42                   ` Linus Torvalds
2018-02-20  8:39                   ` Peter Zijlstra
2018-02-20  8:43                     ` Peter Zijlstra
2018-02-22  5:29                   ` Al Viro
2018-02-22  5:40     ` Al Viro

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.