[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20230904090351.IGC2BcN0@linutronix.de>
Date: Mon, 4 Sep 2023 11:03:51 +0200
From: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
To: Sultan Alsawaf <sultan@...neltoast.com>
Cc: Peter Zijlstra <peterz@...radead.org>,
linux-kernel@...r.kernel.org, tglx@...utronix.de,
boqun.feng@...il.com, bristot@...hat.com, bsegall@...gle.com,
dietmar.eggemann@....com, jstultz@...gle.com,
juri.lelli@...hat.com, longman@...hat.com, mgorman@...e.de,
mingo@...hat.com, rostedt@...dmis.org, swood@...hat.com,
vincent.guittot@...aro.org, vschneid@...hat.com, will@...nel.org
Subject: Re: [PATCH v2 5/6] locking/rtmutex: Use rt_mutex specific scheduler
helpers
On 2023-09-03 11:54:41 [-0700], Sultan Alsawaf wrote:
> On Fri, Aug 25, 2023 at 08:10:32PM +0200, Sebastian Andrzej Siewior wrote:
> > --- a/kernel/locking/rwbase_rt.c
> > +++ b/kernel/locking/rwbase_rt.c
> > @@ -71,6 +71,7 @@ static int __sched __rwbase_read_lock(struct rwbase_rt *rwb,
> > struct rt_mutex_base *rtm = &rwb->rtmutex;
> > int ret;
> >
> > + rwbase_pre_schedule();
> > raw_spin_lock_irq(&rtm->wait_lock);
> >
> > /*
> > @@ -125,6 +126,7 @@ static int __sched __rwbase_read_lock(struct rwbase_rt *rwb,
> > rwbase_rtmutex_unlock(rtm);
> >
> > trace_contention_end(rwb, ret);
> > + rwbase_post_schedule();
> > return ret;
> > }
> >
> > @@ -237,6 +239,8 @@ static int __sched rwbase_write_lock(struct rwbase_rt *rwb,
> > /* Force readers into slow path */
> > atomic_sub(READER_BIAS, &rwb->readers);
> >
> > + rt_mutex_pre_schedule();
> > +
> > raw_spin_lock_irqsave(&rtm->wait_lock, flags);
> > if (__rwbase_write_trylock(rwb))
> > goto out_unlock;
> > @@ -248,6 +252,7 @@ static int __sched rwbase_write_lock(struct rwbase_rt *rwb,
> > if (rwbase_signal_pending_state(state, current)) {
> > rwbase_restore_current_state();
> > __rwbase_write_unlock(rwb, 0, flags);
> > + rt_mutex_post_schedule();
> > trace_contention_end(rwb, -EINTR);
> > return -EINTR;
> > }
> > @@ -266,6 +271,7 @@ static int __sched rwbase_write_lock(struct rwbase_rt *rwb,
> >
> > out_unlock:
> > raw_spin_unlock_irqrestore(&rtm->wait_lock, flags);
> > + rt_mutex_post_schedule();
> > return 0;
> > }
>
> Shouldn't rwbase_write_lock() use rwbase_{pre|post}_schedule()?
>
> With this change as-is, I observe deadlocks due to lock recursion from
> write_lock() specifically, because write_lock() ends up flushing block requests.
You are right, it should have been rwbase_{pre|post}_schedule() because
write_lock() is a spinning lock and should not flush the block requests.
Thanks for spotting this.
> Sultan
Sebastian
Powered by blists - more mailing lists