Re: [PATCH v2 2/2] sched/rt: Remove unnecessary condition in push_rt_task()
From: Steven Rostedt
Date: Wed Feb 15 2017 - 21:37:01 EST
On Thu, 16 Feb 2017 11:05:54 +0900
Byungchul Park <byungchul.park@xxxxxxx> wrote:
> Once pick_next_pushable_task(rq) returns a task, it guarantees that
> the task's cpu is rq->cpu, so task_cpu(next_task) is always rq->cpu if
> task == next_task. Remove the redundant condition and make code simpler.
>
> pick_next_pushable_task(rq) has BUG_ON(rq_cpu != task_cpu(task)) when
> it returns a task other than NULL, which means that task_cpu(task) must
> be rq->cpu. So if task == next_task, then task_cpu(next_task) must be
> rq->cpu as well.
>
> By this patch, unnecessary one branch and two LOAD operations in 'if'
> statement can be avoided.
>
> Signed-off-by: Byungchul Park <byungchul.park@xxxxxxx>
> ---
> kernel/sched/rt.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
> index 4101f9d..5abd9a52 100644
> --- a/kernel/sched/rt.c
> +++ b/kernel/sched/rt.c
> @@ -1820,7 +1820,7 @@ static int push_rt_task(struct rq *rq)
> * pushing.
> */
> task = pick_next_pushable_task(rq);
> - if (task_cpu(next_task) == rq->cpu && task == next_task) {
> + if (task == next_task) {
Reviewed-by: Steven Rostedt (VMware) <rostedt@xxxxxxxxxxx>
-- Steve
> /*
> * The task hasn't migrated, and is still the next
> * eligible task, but we failed to find a run-queue