Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1573428 > unrolled thread

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

Started by"Steven Rostedt (VMware)" <rostedt@goodmis.org>
First post2017-02-03 21:40 +0100
Last post2017-02-04 20:30 +0100
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] sched: Update unlikely to now likely in sched_move_task() "Steven Rostedt (VMware)" <rostedt@goodmis.org> - 2017-02-03 21:40 +0100
    Re: [PATCH] sched: Update unlikely to now likely in sched_move_task() Peter Zijlstra <peterz@infradead.org> - 2017-02-04 12:10 +0100
      Re: [PATCH] sched: Update unlikely to now likely in  sched_move_task() Steven Rostedt <rostedt@goodmis.org> - 2017-02-04 20:30 +0100

#1573428 — [PATCH] sched: Update unlikely to now likely in sched_move_task()

From"Steven Rostedt (VMware)" <rostedt@goodmis.org>
Date2017-02-03 21:40 +0100
Subject[PATCH] sched: Update unlikely to now likely in sched_move_task()
Message-ID<t6SOe-6J7-19@gated-at.bofh.it>
From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

The check for running in sched_move_task() has an unlikely() around it. That
is, it is unlikely that the task being moved is running. That use to be
true. But with a couple of recent updates, it is now likely that the task
will be running.

The first change came from ea86cb4b7621 ("sched/cgroup: Fix
cpu_cgroup_fork() handling") that moved around the use case of
sched_move_task() in do_fork() where the call is now done after the task is
woken (hence it is running).

The second change came from 8e5bfa8c1f84 ("sched/autogroup: Do not use
autogroup->tg in zombie threads") where sched_move_task() is called by the
exit path, by the task that is exiting. Hence it too is running.

Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Vincent Guittot <vincent.guittot@linaro.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 kernel/sched/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

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);
-- 
2.9.3

[toc] | [next] | [standalone]


#1573653

FromPeter Zijlstra <peterz@infradead.org>
Date2017-02-04 12:10 +0100
Message-ID<t76oa-82L-9@gated-at.bofh.it>
In reply to#1573428
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 :/

[toc] | [prev] | [next] | [standalone]


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

FromSteven Rostedt <rostedt@goodmis.org>
Date2017-02-04 20:30 +0100
SubjectRe: [PATCH] sched: Update unlikely to now likely in sched_move_task()
Message-ID<t7ec1-529-5@gated-at.bofh.it>
In reply to#1573653
On Sat, 4 Feb 2017 12:06:45 +0100
Peter Zijlstra <peterz@infradead.org> wrote:

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

Perhaps just remove the hint then. I'll update the patch.

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

Well, as we have seen with the update in code around it. The pattern
may require something different in other locations.

-- Steve

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web