Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1731525
| Path | csiph.com!aioe.org!bofh.it!news.nic.it!robomod |
|---|---|
| From | "Uladzislau Rezki (Sony)" <urezki@gmail.com> |
| Newsgroups | linux.kernel |
| Subject | [RFC PATCH v2] sched/fair: search a task from the tail of the queue |
| Date | Wed, 13 Sep 2017 12:30:02 +0200 |
| Message-ID | <upd5E-677-7@gated-at.bofh.it> (permalink) |
| References | <upd5E-677-9@gated-at.bofh.it> |
| Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=QmPgp1FdMKIrtd4QQWRKPzRidmLDDLMf+vw/AkTnpn4=; b=CjoMmreRkiHF+jgyTaWLdwaNCdHtfFtMKFfbIHCiOQZ/UbaSMR4GFfqERrnICV7oWo 3wI1/QX0ATK+JXrPwfjg6XJL3Gq8C7/0fzyIfbimnWc9KlwzYyQRgBrizrqxMXpAeQ2G qJsNPYVHMpaWaqFuf8icbwq8/0B9on/pvzZ417MDj35uLRO93SDxNi13z4FD3qUDIshO RrTHgVNeLiuGZqcfJOcBTi1s7EOr+9X17Gwd05k7MmOSNchuEpi9V00UORqclfJLIytd t73WMUOn5hJBjhuFJKVrJOGA8SDfPn14uxPRUrXo4DOGzPLVyFTDE7n7JzBOKGGSrATz TXEA== |
| X-Google-Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=QmPgp1FdMKIrtd4QQWRKPzRidmLDDLMf+vw/AkTnpn4=; b=hLWVj0dlmxmTt2Mc/XXGuOReuqWuSj3DBwJLuo0ZcVLvRoSnOYHe/LyP36E9wV+jHz KwL6ZQlufOdR/iLNJrpLuuvt9/kZRRydsIKPMxVI1Y4PbiiYQ/LKRvxUT7xvm9Y2JSMK NwlmTlfmLcQKLUWIkL9aQqEIGVeI3Rx0x/h8eKbrnAt2aoihg3HVfYe+LQ04dGsFQTsz HxYnR6N/vnsASHRkTN1Bv79rd4jdm2ubl+rGNnxsxxWD7qIL1BeyqN3ZdGAHHRrJ1YJZ dm3sr49cxbwWDUNAvxGsT1jhlDOuu06YRHZBwGu9u7dACS76lCpKK7Mu6HgkH5JpMo6i ze+g== |
| X-Gm-Message-State | AHPjjUgUDgRkyuOGC40SA6wNygKyxjHvi8ReXsZehCowTcl4KiD7gC/b lEFJRJY98weDoA== |
| X-Google-SMTP-Source | AOwi7QAtAErxr890wDkKDfFUsQ44ezg/yBDhfpj2pO5+LxWG4rWSFu1NiJqUR+kxJQJhv3xta/kxtQ== |
| X-Received | by 10.25.16.231 with SMTP id 100mr7223118lfq.17.1505298287994; Wed, 13 Sep 2017 03:24:47 -0700 (PDT) |
| X-Mailer | git-send-email 2.11.0 |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 98 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | LKML <linux-kernel@vger.kernel.org>, Ingo Molnar <mingo@redhat.com>, Mike Galbraith <efault@gmx.de>, Oleksiy Avramchenko <oleksiy.avramchenko@sonymobile.com>, Paul Turner <pjt@google.com>, Oleg Nesterov <oleg@redhat.com>, Steven Rostedt <rostedt@goodmis.org>, Mike Galbraith <umgwanakikbuti@gmail.com>, Kirill Tkhai <tkhai@yandex.ru>, Tim Chen <tim.c.chen@linux.intel.com>, Nicolas Pitre <nicolas.pitre@linaro.org>, Uladzislau Rezki <urezki@gmail.com> |
| X-Original-Date | Wed, 13 Sep 2017 12:24:30 +0200 |
| X-Original-Message-ID | <20170913102430.8985-2-urezki@gmail.com> |
| X-Original-References | <20170913102430.8985-1-urezki@gmail.com> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1731525 |
Show key headers only | View raw
From: Uladzislau Rezki <urezki@gmail.com>
As a first step this patch makes cfs_tasks list as MRU one.
It means, that when a next task is picked to run on physical
CPU it is moved to the front of the list.
Therefore, the cfs_tasks list is more or less sorted (except
woken tasks) starting from recently given CPU time tasks toward
tasks with max wait time in a run-queue, i.e. MRU list.
Second, as part of the load balance operation, this approach
starts detach_tasks()/detach_one_task() from the tail of the
queue instead of the head, giving some advantages:
- tends to pick a task with highest wait time;
- tasks located in the tail are less likely cache-hot,
therefore the can_migrate_task() decision is higher.
hackbench illustrates slightly better performance. For example
doing 1000 samples and 40 groups on i5-3320M CPU, it shows below
figures:
default: 0.657 avg
patched: 0.646 avg
Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
---
kernel/sched/fair.c | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index c77e4b1d51c0..b598907e5236 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -6354,10 +6354,7 @@ pick_next_task_fair(struct rq *rq, struct task_struct *prev, struct rq_flags *rf
set_next_entity(cfs_rq, se);
}
- if (hrtick_enabled(rq))
- hrtick_start_fair(rq, p);
-
- return p;
+ goto done;
simple:
cfs_rq = &rq->cfs;
#endif
@@ -6375,6 +6372,16 @@ pick_next_task_fair(struct rq *rq, struct task_struct *prev, struct rq_flags *rf
p = task_of(se);
+done: __maybe_unused
+#ifdef CONFIG_SMP
+ /*
+ * Move the next running task to the front of
+ * the list, so our cfs_tasks list becomes MRU
+ * one.
+ */
+ list_move(&p->se.group_node, &rq->cfs_tasks);
+#endif
+
if (hrtick_enabled(rq))
hrtick_start_fair(rq, p);
@@ -6806,11 +6813,12 @@ static void detach_task(struct task_struct *p, struct lb_env *env)
*/
static struct task_struct *detach_one_task(struct lb_env *env)
{
- struct task_struct *p, *n;
+ struct task_struct *p;
lockdep_assert_held(&env->src_rq->lock);
- list_for_each_entry_safe(p, n, &env->src_rq->cfs_tasks, se.group_node) {
+ list_for_each_entry_reverse(p,
+ &env->src_rq->cfs_tasks, se.group_node) {
if (!can_migrate_task(p, env))
continue;
@@ -6856,7 +6864,7 @@ static int detach_tasks(struct lb_env *env)
if (env->idle != CPU_NOT_IDLE && env->src_rq->nr_running <= 1)
break;
- p = list_first_entry(tasks, struct task_struct, se.group_node);
+ p = list_last_entry(tasks, struct task_struct, se.group_node);
env->loop++;
/* We've more or less seen every task there is, call it quits */
@@ -6906,7 +6914,7 @@ static int detach_tasks(struct lb_env *env)
continue;
next:
- list_move_tail(&p->se.group_node, tasks);
+ list_move(&p->se.group_node, tasks);
}
/*
--
2.11.0
Back to linux.kernel | Previous | Next | Find similar | Unroll thread
[RFC PATCH v2] sched/fair: search a task from the tail of the queue "Uladzislau Rezki (Sony)" <urezki@gmail.com> - 2017-09-13 12:30 +0200
csiph-web