]> git.baikalelectronics.ru Git - kernel.git/commit
locking/percpu-rwsem: Use this_cpu_{inc,dec}() for read_count
authorHou Tao <houtao1@huawei.com>
Tue, 15 Sep 2020 14:07:50 +0000 (22:07 +0800)
committerPeter Zijlstra <peterz@infradead.org>
Wed, 16 Sep 2020 14:26:56 +0000 (16:26 +0200)
commitca5327a00c698ca3e0641016a2dd2512acc2b0b6
tree2175cb1bc02e8b795a2ebb5d3fe5263539e5cb4f
parentd91d33f1402c162477ae14fc2909141898e67abf
locking/percpu-rwsem: Use this_cpu_{inc,dec}() for read_count

The __this_cpu*() accessors are (in general) IRQ-unsafe which, given
that percpu-rwsem is a blocking primitive, should be just fine.

However, file_end_write() is used from IRQ context and will cause
load-store issues on architectures where the per-cpu accessors are not
natively irq-safe.

Fix it by using the IRQ-safe this_cpu_*() for operations on
read_count. This will generate more expensive code on a number of
platforms, which might cause a performance regression for some of the
other percpu-rwsem users.

If any such is reported, we can consider alternative solutions.

Fixes: 6c9601d8a768 ("aio: fix freeze protection of aio writes")
Signed-off-by: Hou Tao <houtao1@huawei.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Will Deacon <will@kernel.org>
Acked-by: Oleg Nesterov <oleg@redhat.com>
Link: https://lkml.kernel.org/r/20200915140750.137881-1-houtao1@huawei.com
include/linux/percpu-rwsem.h
kernel/locking/percpu-rwsem.c