[Devel] [PATCH v2 1/2] sched/core: Set task_struct::woken_while_running under rq lock

Kirill Tkhai ktkhai at virtuozzo.com
Fri Jan 15 08:56:35 PST 2016


Since it's set under pi_lock and cleared under rq->lock, these
both are not synchronized.

Put move "woken_while_running = 1" in ttwu_remote(), where rq lock
is held.

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 kernel/sched/core.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index c8ac8bd..f61a4d1 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -1616,6 +1616,7 @@ static int ttwu_remote(struct task_struct *p, int wake_flags)
 	rq = __task_rq_lock(p);
 	if (p->on_rq) {
 		ttwu_do_wakeup(rq, p, wake_flags);
+		p->woken_while_running = 1;
 		ret = 1;
 	}
 	__task_rq_unlock(rq);
@@ -1739,10 +1740,8 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)
 	success = 1; /* we're going to change ->state */
 	cpu = task_cpu(p);
 
-	if (p->on_rq && ttwu_remote(p, wake_flags)) {
-		p->woken_while_running = 1;
+	if (p->on_rq && ttwu_remote(p, wake_flags))
 		goto stat;
-	}
 
 #ifdef CONFIG_SMP
 	/*



More information about the Devel mailing list