Re: [PATCH] sched: Update unlikely to now likely in sched_move_task()

From: Peter Zijlstra
Date: Sat Feb 04 2017 - 06:07:13 EST


On Fri, Feb 03, 2017 at 03:30:19PM -0500, Steven Rostedt (VMware) wrote:
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index c56fb57..669f23d 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -7989,14 +7989,14 @@ void sched_move_task(struct task_struct *tsk)
>
> if (queued)
> dequeue_task(rq, tsk, DEQUEUE_SAVE | DEQUEUE_MOVE);
> - if (unlikely(running))
> + if (likely(running))
> put_prev_task(rq, tsk);
>
> sched_change_group(tsk, TASK_MOVE_GROUP);
>
> if (queued)
> enqueue_task(rq, tsk, ENQUEUE_RESTORE | ENQUEUE_MOVE);
> - if (unlikely(running))
> + if (likely(running))
> set_curr_task(rq, tsk);
>
> task_rq_unlock(rq, tsk, &rf);


I prefer to simply remove the hint entirely and match all the other
instances of this pattern.

Now if only C wouldn't stink and have a sensible way to express this
pattern without having to copy/paste it all over :/