Commit 3f5ec3c3 authored by Waiman Long's avatar Waiman Long Committed by Greg Kroah-Hartman
Browse files

locking/rwsem: Disable preemption in all down_read*() and up_read() code paths



[ Upstream commit 3f524553 ]

Commit:

  91d2a812 ("locking/rwsem: Make handoff writer optimistically spin on owner")

... assumes that when the owner field is changed to NULL, the lock will
become free soon. But commit:

  48dfb5d2 ("locking/rwsem: Disable preemption while trying for rwsem lock")

... disabled preemption when acquiring rwsem for write.

However, preemption has not yet been disabled when acquiring a read lock
on a rwsem.  So a reader can add a RWSEM_READER_BIAS to count without
setting owner to signal a reader, got preempted out by a RT task which
then spins in the writer slowpath as owner remains NULL leading to live lock.

One easy way to fix this problem is to disable preemption at all the
down_read*() and up_read() code paths as implemented in this patch.

Fixes: 91d2a812 ("locking/rwsem: Make handoff writer optimistically spin on owner")
Reported-by: default avatarMukesh Ojha <quic_mojha@quicinc.com>
Suggested-by: default avatarPeter Zijlstra <peterz@infradead.org>
Signed-off-by: default avatarWaiman Long <longman@redhat.com>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20230126003628.365092-3-longman@redhat.com


Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent ab4d47a3
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment