[3.19.y-ckt stable] Patch "sched/fair: Prevent throttling in early pick_next_task_fair()" has been added to staging queue

Kamal Mostafa kamal at canonical.com
Thu Jul 16 01:07:11 UTC 2015


This is a note to let you know that I have just added a patch titled

    sched/fair: Prevent throttling in early pick_next_task_fair()

to the linux-3.19.y-queue branch of the 3.19.y-ckt extended stable tree 
which can be found at:

    http://kernel.ubuntu.com/git/ubuntu/linux.git/log/?h=linux-3.19.y-queue

This patch is scheduled to be released in version 3.19.y-ckt4.

If you, or anyone else, feels it should not be added to this tree, please 
reply to this email.

For more information about the 3.19.y-ckt tree, see
https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable

Thanks.
-Kamal

------

>From ecbf90d7b5b9044c785b75ecf7d45eb0aa94c1ea Mon Sep 17 00:00:00 2001
From: Ben Segall <bsegall at google.com>
Date: Mon, 6 Apr 2015 15:28:10 -0700
Subject: sched/fair: Prevent throttling in early pick_next_task_fair()

commit 54d27365cae88fbcc853b391dcd561e71acb81fa upstream.

The optimized task selection logic optimistically selects a new task
to run without first doing a full put_prev_task(). This is so that we
can avoid a put/set on the common ancestors of the old and new task.

Similarly, we should only call check_cfs_rq_runtime() to throttle
eligible groups if they're part of the common ancestry, otherwise it
is possible to end up with no eligible task in the simple task
selection.

Imagine:
		/root
	/prev		/next
	/A		/B

If our optimistic selection ends up throttling /next, we goto simple
and our put_prev_task() ends up throttling /prev, after which we're
going to bug out in set_next_entity() because there aren't any tasks
left.

Avoid this scenario by only throttling common ancestors.

Reported-by: Mohammed Naser <mnaser at vexxhost.com>
Reported-by: Konstantin Khlebnikov <khlebnikov at yandex-team.ru>
Signed-off-by: Ben Segall <bsegall at google.com>
[ munged Changelog ]
Signed-off-by: Peter Zijlstra (Intel) <peterz at infradead.org>
Cc: Andrew Morton <akpm at linux-foundation.org>
Cc: H. Peter Anvin <hpa at zytor.com>
Cc: Linus Torvalds <torvalds at linux-foundation.org>
Cc: Peter Zijlstra <peterz at infradead.org>
Cc: Roman Gushchin <klamm at yandex-team.ru>
Cc: Thomas Gleixner <tglx at linutronix.de>
Cc: pjt at google.com
Fixes: 678d5718d8d0 ("sched/fair: Optimize cgroup pick_next_task_fair()")
Link: http://lkml.kernel.org/r/xm26wq1oswoq.fsf@sword-of-the-dawn.mtv.corp.google.com
Signed-off-by: Ingo Molnar <mingo at kernel.org>

Signed-off-by: Kamal Mostafa <kamal at canonical.com>
---
 kernel/sched/fair.c | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 44cfeb3..9e78f9f 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -5028,18 +5028,21 @@ again:
 		 * entity, update_curr() will update its vruntime, otherwise
 		 * forget we've ever seen it.
 		 */
-		if (curr && curr->on_rq)
-			update_curr(cfs_rq);
-		else
-			curr = NULL;
+		if (curr) {
+			if (curr->on_rq)
+				update_curr(cfs_rq);
+			else
+				curr = NULL;

-		/*
-		 * This call to check_cfs_rq_runtime() will do the throttle and
-		 * dequeue its entity in the parent(s). Therefore the 'simple'
-		 * nr_running test will indeed be correct.
-		 */
-		if (unlikely(check_cfs_rq_runtime(cfs_rq)))
-			goto simple;
+			/*
+			 * This call to check_cfs_rq_runtime() will do the
+			 * throttle and dequeue its entity in the parent(s).
+			 * Therefore the 'simple' nr_running test will indeed
+			 * be correct.
+			 */
+			if (unlikely(check_cfs_rq_runtime(cfs_rq)))
+				goto simple;
+		}

 		se = pick_next_entity(cfs_rq, curr);
 		cfs_rq = group_cfs_rq(se);
--
1.9.1





More information about the kernel-team mailing list