On Tue, May 05, 2015 at 11:02 -0700, Philip Guenther wrote:
> On Tue, May 5, 2015 at 9:35 AM, Mike Belopuhov <[email protected]> wrote:
> ...
> > Here's a diff to remedy this.  This is the same chunk as in the
> > tsleep, except it uses semantics of msleep.  IPL dance is there
> > to negate the IPL changing effect of mtx_enter/mtx_leave so that
> > splx(safepri) operation is actually changing IPL level from HIGH
> > to "safepri" and then back to the mutex IPL level.
> ...
> > +               spl = MUTEX_OLDIPL(mtx);
> > +               MUTEX_OLDIPL(mtx) = splhigh();
> > +               mtx_leave(mtx);
> > +
> > +               splx(safepri);
> 
> Hmm, since mtx_leave() effectively ends with
> "splx(MUTEX_OLDIPL(mtx));", can't we just say:
> 
>               spl = MUTEX_OLDIPL(mtx);
>               MUTEX_OLDIPL(mtx) = safepri;
>               mtx_leave(mtx);
> 
> (The tsleep() version needs splhigh() because that's the only safe way
> to get the current spl level so that it can be restored before
> returning.  Here in msleep() the mutex's MUTEX_OLDIPL() already has
> the value we need.)
> 
> 
> Philip Guenther

Good call.  This will also eliminate double spllower on mtx_leave an splx.
I'll do some tests tomorrow to try to make sure that it doesn't suddenly
introduce regressions.

Reply via email to