Re: [PATCH -v2 1/9] rtmutex: Deboost before waking up the top waiter
From: Steven Rostedt
Date: Mon Sep 26 2016 - 11:35:21 EST
On Mon, 26 Sep 2016 17:22:28 +0200
Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
> > > + /*
> > > + * We should deboost before waking the top waiter task such that
> > > + * we don't run two tasks with the 'same' priority. This however
> > > + * can lead to prio-inversion if we would get preempted after
> > > + * the deboost but before waking our high-prio task, hence the
> > > + * preempt_disable before unlock. Pairs with preempt_enable() in
> > > + * rt_mutex_postunlock();
> >
> > There's a preempt_enable() in rt_mutex_postunlock()? Does
> > wake_futex_pi() know that?
> >
>
> Not sure I see your point. rt_mutex_futex_unlock() calls
> rt_mutex_slowunlock() which does the preempt_disable(), we then pass the
> return of that into deboost, which we pass into rt_mutex_postunlock()
> and everything should be balanced.
Can we please add more comments explaining this. Having side effects of
functions disabling preemption, passing a bool saying that it did, and
needing to call another function (somewhat seemingly unrelated) to
re-enable preemption, just seems a bit of a stretch for maintainable
code.
Especially now that the code after the spin_unlock(&hb->lock) is now a
critical section (preemption is disable). There's nothing obvious in
futex.c that says it is.
Just think about looking at this code in another 5 years. Are you going
to remember all this?
-- Steve