Re: [PATCH v2] sched/core: Minor optimize ttwu_runnable()

From: Valentin Schneider
Date: Fri Nov 11 2022 - 13:02:55 EST



Hi,

some minor changelog nitpicks, otherwise this LGTM

On 09/11/22 00:24, Chengming Zhou wrote:
> ttwu_runnable() is used as a fast wakeup path when the wakee task
> is running on CPU or runnable on RQ, in both cases we can just
> set its state to TASK_RUNNING to prevent a sleep.
>
> If the wakee task is on_cpu running, we don't need to update_rq_clock()
> or check_preempt_curr().
>
> But if the wakee task is on_rq && !on_cpu (e.g. an IRQ hit before
> the task got to schedule() and the task been preempted), we should
> check_preempt_curr() to see if it can preempt the current running.
>
> This patch reorg ttwu_do_wakeup() and ttwu_do_activate() to make
> ttwu_do_wakeup() only mark the task runnable, so it can be used
> in ttwu_runnable() and try_to_wake_up() fast paths.
>
> As for p->sched_class->task_woken(), ttwu_do_wakeup() needn't it
> anymore, since p isn't a woken task in this case, so should not
> affect RT/DL push/pull.

I would rephrase that last paragraph into something like:
"""
This also removes the class->task_woken() callback from ttwu_runnable(),
which wasn't required per the RT/DL implementations: any required push
operation would have been queued during class->set_next_task() when p
got preempted.

ttwu_runnable() also loses the update to rq->idle_stamp, as by definition
the rq cannot be idle in this scenario.
"""

>
> Signed-off-by: Chengming Zhou <zhouchengming@xxxxxxxxxxxxx>
> Suggested-by: Valentin Schneider <vschneid@xxxxxxxxxx>
> Suggested-by: Peter Zijlstra <peterz@xxxxxxxxxxxxx>

With those changes:

Reviewed-by: Valentin Schneider <vschneid@xxxxxxxxxx>