Re: [PATCH] locking/rwsem: Disable preemption while trying for rwsem lock

From: Peter Zijlstra
Date: Thu Sep 08 2022 - 13:04:01 EST


On Thu, Sep 08, 2022 at 09:18:29PM +0530, Mukesh Ojha wrote:
> Hi Peter,
>
> Thanks for your time in reviewing this patch.
>
> On 9/8/2022 8:02 PM, Peter Zijlstra wrote:
> > On Thu, Sep 01, 2022 at 03:58:10PM +0530, Mukesh Ojha wrote:
> > > From: Gokul krishna Krishnakumar <quic_gokukris@xxxxxxxxxxx>
> > >
> > > 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 this issue
> > > at the place where owner being set/cleared.
> > >
> > > Signed-off-by: Gokul krishna Krishnakumar <quic_gokukris@xxxxxxxxxxx>
> > > Signed-off-by: Mukesh Ojha <quic_mojha@xxxxxxxxxxx>
> >
> > This is not a valid SoB chain.
>
> Since this patch of adding preempt disable() at rwsem_write_trylock() is
> originated from Gokul.
>
> Would be adding him in
> Original-patch-by: Gokul krishna Krishnakumar <quic_gokukris@xxxxxxxxxxx>
>
> Convert myself to the author/SoB.
>

Oh, my bad, I missed From is actually Gokul. So yeah, all good, ignore
that.