arm64: futex: Bound number of LDXR/STXR loops in FUTEX_WAKE_OP
authorWill Deacon <will.deacon@arm.com>
Sun, 28 Mar 2021 20:42:51 +0000 (22:42 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 30 Mar 2021 12:41:42 +0000 (14:41 +0200)
commitbd3ec28fb6d985ee377efe018e2ff8cf7dfce902
treec7e2300ab294dcf44e6af647b3d5334189c5ce3a
parent8682c2e2cc82b3ee5938a5384ddc04baab4c0fff
arm64: futex: Bound number of LDXR/STXR loops in FUTEX_WAKE_OP

commit 03110a5cb2161690ae5ac04994d47ed0cd6cef75 upstream.

Our futex implementation makes use of LDXR/STXR loops to perform atomic
updates to user memory from atomic context. This can lead to latency
problems if we end up spinning around the LL/SC sequence at the expense
of doing something useful.

Rework our futex atomic operations so that we return -EAGAIN if we fail
to update the futex word after 128 attempts. The core futex code will
reschedule if necessary and we'll try again later.

Fixes: 6170a97460db ("arm64: Atomic operations")
Signed-off-by: Will Deacon <will.deacon@arm.com>
[bwh: Backported to 4.9: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/arm64/include/asm/futex.h