From: "Uladzislau Rezki (Sony)" <urezki@gmail.com>
To: Peter Zijlstra <peterz@infradead.org>
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>
Subject: [RFC][PATCH]: sched/fair: search a task from the tail of the queue
Date: Thu, 24 Aug 2017 12:44:45 +0200 [thread overview]
Message-ID: <20170824104445.16827-2-urezki@gmail.com> (raw)
In-Reply-To: <20170824104445.16827-1-urezki@gmail.com>
From: Uladzislau Rezki <urezki@gmail.com>
When a task is enqueued back from a physical CPU to the running
list it is placed in the beginning of the queue. Thus, 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.
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.672 avg / 0.674 median
patched: 0.665 avg / 0.667 median
Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
---
kernel/sched/fair.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index c77e4b1d51c0..028f5e8bc830 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -6806,11 +6806,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 +6857,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 +6907,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
next prev parent reply other threads:[~2017-08-24 10:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-24 10:44 [RFC][PATCH]: sched/fair: search a task from the tail of the queue Uladzislau Rezki (Sony)
2017-08-24 10:44 ` Uladzislau Rezki (Sony) [this message]
2017-08-24 17:46 ` Peter Zijlstra
2017-08-24 22:19 ` Uladzislau Rezki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170824104445.16827-2-urezki@gmail.com \
--to=urezki@gmail.com \
--cc=efault@gmx.de \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=nicolas.pitre@linaro.org \
--cc=oleg@redhat.com \
--cc=oleksiy.avramchenko@sonymobile.com \
--cc=peterz@infradead.org \
--cc=pjt@google.com \
--cc=rostedt@goodmis.org \
--cc=tim.c.chen@linux.intel.com \
--cc=tkhai@yandex.ru \
--cc=umgwanakikbuti@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox