Re: [RFC][PATCH 1/8] rtmutex: Deboost before waking up the top waiter

From: Steven Rostedt
Date: Tue Jun 14 2016 - 14:23:06 EST


On Tue, 07 Jun 2016 21:56:36 +0200
Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:

> From: Xunlei Pang <xlpang@xxxxxxxxxx>
>
> We should deboost before waking the high-prio task, such that
> we don't run two tasks with the same "state"(priority, deadline,
> sched_class, etc) during the period between the end of wake_up_q()
> and the end of rt_mutex_adjust_prio().
>
> As "Peter Zijlstra" said:
> Its semantically icky to have the two tasks running off the same
> state and practically icky when you consider bandwidth inheritance --
> where the boosted task wants to explicitly modify the state of the
> booster. In that latter case you really want to unboost before you
> let the booster run again.
>
> But this however can lead to prio-inversion if current would get
> preempted after the deboost but before waking our high-prio task,
> hence we disable preemption before doing deboost, and enabling it
> after the wake up is over.
>
> The patch fixed the logic, and introduced rt_mutex_postunlock()
> to do some code refactor.
>
> Most importantly however; this change ensures pointer stability for
> the next patch, where we have rt_mutex_setprio() cache a pointer to
> the top-most waiter task. If we, as before this change, do the wakeup
> first and then deboost, this pointer might point into thin air.
>
> Cc: Steven Rostedt <rostedt@xxxxxxxxxxx>

Acked-by: Steven Rostedt <rostedt@xxxxxxxxxxx>

-- Steve

> Cc: Ingo Molnar <mingo@xxxxxxxxxx>
> Cc: Juri Lelli <juri.lelli@xxxxxxx>
> Suggested-by: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> [peterz: Changelog]
> Signed-off-by: Xunlei Pang <xlpang@xxxxxxxxxx>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
> Link: http://lkml.kernel.org/r/1461659449-19497-1-git-send-email-xlpang@xxxxxxxxxx
> ---