Re: [PATCH 2/3] rwsem: Implement down_read_interruptible
From: Peter Zijlstra
Date: Tue Dec 08 2020 - 07:33:07 EST
On Tue, Dec 08, 2020 at 09:12:36AM +0000, David Laight wrote:
> From: Waiman Long
> > Sent: 07 December 2020 19:02
> ...
> > > How much more difficult would it be to also add a timeout option?
> > > I looked at adding one to the mutex code - and fell into a big pile
> > > of replicated code.
> > >
> > > ISTM that one the initial locked exchange (and spin) fails a few
> > > extra instructions when heading for the sleep don't really matter
> > >
> > Actually, I had tried that before. See
> >
> > https://lore.kernel.org/lkml/20190911150537.19527-1-longman@xxxxxxxxxx/
> >
> > That is for rwsem, but the same can be done for mutex. However, Peter
> > didn't seem to like the idea of a timeout parameter. Anyway, it is
> > certainly doable if there is a good use case for it.
>
> 'Unfortunately' my use-case if for an out-of-tree driver.
>
> The problem I was solving is a status call blocking because
> some other code is 'stuck' (probably an oops) with a mutex held.
Working around oopses is not a sane use-case. If you oops, you get to
keep all the pieces.