]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: Relax memory barrier in btrfs_tree_unlock
authorNikolay Borisov <nborisov@suse.com>
Wed, 14 Feb 2018 12:37:26 +0000 (14:37 +0200)
committerDavid Sterba <dsterba@suse.com>
Fri, 30 Mar 2018 23:26:51 +0000 (01:26 +0200)
commit89da1ff9a1a4b60478ed968c81e5c95e997fef64
treefdd5d24ad40034addd3bf1eb19c8a21e2d291e1e
parent75c24cb16dd47d2d5f2ac4334e8e1a5afc9bdd90
btrfs: Relax memory barrier in btrfs_tree_unlock

When performing an unlock on an extent buffer we'd like to order the
decrement of extent_buffer::blocking_writers with waking up any
waiters. In such situations it's sufficient to use smp_mb__after_atomic
rather than the heavy smp_mb. On architectures where atomic operations
are fully ordered (such as x86 or s390) unconditionally executing
a heavyweight smp_mb instruction causes a severe hit to performance
while bringin no improvements in terms of correctness.

The better thing is to use the appropriate smp_mb__after_atomic routine
which will do the correct thing (invoke a full smp_mb or in the case
of ordered atomics insert a compiler barrier). Put another way,
an RMW atomic op + smp_load__after_atomic equals, in terms of
semantics, to a full smp_mb. This ensures that none of the problems
described in the accompanying comment of waitqueue_active occur.
No functional changes.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/locking.c