Skip to content
Commit 8d1bab77 authored by Gokul krishna Krishnakumar's avatar Gokul krishna Krishnakumar Committed by Bruce Ashfield
Browse files

locking/rwsem: Disable preemption while trying for rwsem lock

commit 48dfb5d2

 upstream

Make the region inside the rwsem_write_trylock non preemptible.

We observe RT task is hogging CPU when trying to acquire rwsem lock
which was acquired by a kworker task but before the rwsem owner was set.

Here is the scenario:
1. CFS task (affined to a particular CPU) takes rwsem lock.

2. CFS task gets preempted by a RT task before setting owner.

3. RT task (FIFO) is trying to acquire the lock, but spinning until
RT throttling happens for the lock as the lock was taken by CFS task.

This patch attempts to fix the above issue by disabling preemption
until owner is set for the lock. While at it also fix the issues
at the places where rwsem_{set,clear}_owner() are called.

This also adds lockdep annotation of preemption disable in
rwsem_{set,clear}_owner() on Peter Z. suggestion.

Signed-off-by: default avatarGokul krishna Krishnakumar <quic_gokukris@quicinc.com>
Signed-off-by: default avatarMukesh Ojha <quic_mojha@quicinc.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: default avatarWaiman Long <longman@redhat.com>
Link: https://lore.kernel.org/r/1662661467-24203-1-git-send-email-quic_mojha@quicinc.com
Signed-off-by: default avatarBeniamin Sandu <beniamin.sandu@windriver.com>
Signed-off-by: default avatarLi Wang <li.wang@windriver.com>
Signed-off-by: default avatarBruce Ashfield <bruce.ashfield@gmail.com>
parent c38d1c10
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment