arm64/sve: Eliminate data races on sve_default_vl
authorDave Martin <Dave.Martin@arm.com>
Wed, 10 Jun 2020 17:03:10 +0000 (18:03 +0100)
committerWill Deacon <will@kernel.org>
Mon, 15 Jun 2020 15:57:42 +0000 (16:57 +0100)
commit1e570f512cbdc5e9e401ba640d9827985c1bea1e
treee099a494e37b2b046c57be93dd524590df456ff2
parent9ba6a9efa4a4c721d0115089bf422f82b8a59e45
arm64/sve: Eliminate data races on sve_default_vl

sve_default_vl can be modified via the /proc/sys/abi/sve_default_vl
sysctl concurrently with use, and modified concurrently by multiple
threads.

Adding a lock for this seems overkill, and I don't want to think any
more than necessary, so just define wrappers using READ_ONCE()/
WRITE_ONCE().

This will avoid the possibility of torn accesses and repeated loads
and stores.

There's no evidence yet that this is going wrong in practice: this
is just hygiene.  For generic sysctl users, it would be better to
build this kind of thing into the sysctl common code somehow.

Reported-by: Will Deacon <will@kernel.org>
Signed-off-by: Dave Martin <Dave.Martin@arm.com>
Link: https://lore.kernel.org/r/1591808590-20210-3-git-send-email-Dave.Martin@arm.com
[will: move set_sve_default_vl() inside #ifdef to squash allnoconfig warning]
Signed-off-by: Will Deacon <will@kernel.org>
arch/arm64/kernel/fpsimd.c