From: Peter Zijlstra <peterz@infradead.org>
To: mingo@kernel.org, linux-kernel@vger.kernel.org
Cc: peterz@infradead.org, Pavan Kondeti <pkondeti@codeaurora.org>,
Ben Segall <bsegall@google.com>,
Matt Fleming <matt@codeblueprint.co.uk>,
Mike Galbraith <umgwanakikbuti@gmail.com>,
Morten Rasmussen <morten.rasmussen@arm.com>,
Paul Turner <pjt@google.com>,
Thomas Gleixner <tglx@linutronix.de>,
byungchul.park@lge.com, Andrew Hunter <ahh@google.com>
Subject: [PATCH 1/3] sched,fair: Move record_wakee()
Date: Tue, 10 May 2016 19:43:15 +0200 [thread overview]
Message-ID: <20160510174613.821444209@infradead.org> (raw)
In-Reply-To: <20160510174314.355953085@infradead.org>
[-- Attachment #1: peterz-sched-frob-record-wakee.patch --]
[-- Type: text/plain, Size: 3982 bytes --]
Since I want to make ->task_woken() conditional on the task getting
migrated, we cannot use it to call record_wakee().
Move it to select_task_rq_fair(), which gets called in almost all the
same conditions. The only exception is if the woken task (@p) is
cpu-bound (as per the nr_cpus_allowed test in select_task_rq()).
Cc: Pavan Kondeti <pkondeti@codeaurora.org>
Cc: Ben Segall <bsegall@google.com>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Mike Galbraith <umgwanakikbuti@gmail.com>
Cc: Morten Rasmussen <morten.rasmussen@arm.com>
Cc: Paul Turner <pjt@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: byungchul.park@lge.com
Cc: Andrew Hunter <ahh@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
kernel/sched/fair.c | 61 ++++++++++++++++++++++++++++------------------------
1 file changed, 33 insertions(+), 28 deletions(-)
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -4811,24 +4811,6 @@ static unsigned long cpu_avg_load_per_ta
return 0;
}
-static void record_wakee(struct task_struct *p)
-{
- /*
- * Rough decay (wiping) for cost saving, don't worry
- * about the boundary, really active task won't care
- * about the loss.
- */
- if (time_after(jiffies, current->wakee_flip_decay_ts + HZ)) {
- current->wakee_flips >>= 1;
- current->wakee_flip_decay_ts = jiffies;
- }
-
- if (current->last_wakee != p) {
- current->last_wakee = p;
- current->wakee_flips++;
- }
-}
-
static void task_waking_fair(struct task_struct *p)
{
struct sched_entity *se = &p->se;
@@ -4848,7 +4830,6 @@ static void task_waking_fair(struct task
#endif
se->vruntime -= min_vruntime;
- record_wakee(p);
}
#ifdef CONFIG_FAIR_GROUP_SCHED
@@ -4966,17 +4947,39 @@ static long effective_load(struct task_g
#endif
+static void record_wakee(struct task_struct *p)
+{
+ /*
+ * Only decay a single time; tasks that have less then 1 wakeup per
+ * jiffy will not have built up many flips.
+ */
+ if (time_after(jiffies, current->wakee_flip_decay_ts + HZ)) {
+ current->wakee_flips >>= 1;
+ current->wakee_flip_decay_ts = jiffies;
+ }
+
+ if (current->last_wakee != p) {
+ current->last_wakee = p;
+ current->wakee_flips++;
+ }
+}
+
/*
* Detect M:N waker/wakee relationships via a switching-frequency heuristic.
+ *
* A waker of many should wake a different task than the one last awakened
- * at a frequency roughly N times higher than one of its wakees. In order
- * to determine whether we should let the load spread vs consolodating to
- * shared cache, we look for a minimum 'flip' frequency of llc_size in one
- * partner, and a factor of lls_size higher frequency in the other. With
- * both conditions met, we can be relatively sure that the relationship is
- * non-monogamous, with partner count exceeding socket size. Waker/wakee
- * being client/server, worker/dispatcher, interrupt source or whatever is
- * irrelevant, spread criteria is apparent partner count exceeds socket size.
+ * at a frequency roughly N times higher than one of its wakees.
+ *
+ * In order to determine whether we should let the load spread vs consolidating
+ * to shared cache, we look for a minimum 'flip' frequency of llc_size in one
+ * partner, and a factor of lls_size higher frequency in the other.
+ *
+ * With both conditions met, we can be relatively sure that the relationship is
+ * non-monogamous, with partner count exceeding socket size.
+ *
+ * Waker/wakee being client/server, worker/dispatcher, interrupt source or
+ * whatever is irrelevant, spread criteria is apparent partner count exceeds
+ * socket size.
*/
static int wake_wide(struct task_struct *p)
{
@@ -5281,8 +5284,10 @@ select_task_rq_fair(struct task_struct *
int want_affine = 0;
int sync = wake_flags & WF_SYNC;
- if (sd_flag & SD_BALANCE_WAKE)
+ if (sd_flag & SD_BALANCE_WAKE) {
+ record_wakee(p);
want_affine = !wake_wide(p) && cpumask_test_cpu(cpu, tsk_cpus_allowed(p));
+ }
rcu_read_lock();
for_each_domain(cpu, tmp) {
next prev parent reply other threads:[~2016-05-10 17:49 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-10 17:43 [PATCH 0/3] sched: Fix wakeup preemption regression Peter Zijlstra
2016-05-10 17:43 ` Peter Zijlstra [this message]
2016-05-12 10:27 ` [PATCH 1/3] sched,fair: Move record_wakee() Matt Fleming
2016-05-12 10:31 ` Peter Zijlstra
2016-05-10 17:43 ` [PATCH 2/3] sched,fair: Fix local starvation Peter Zijlstra
2016-05-10 20:21 ` Ingo Molnar
2016-05-10 22:23 ` Peter Zijlstra
2016-05-20 21:24 ` Matt Fleming
2016-05-21 14:04 ` Mike Galbraith
2016-05-21 19:00 ` Mike Galbraith
2016-05-22 7:00 ` [patch] sched/fair: Move se->vruntime normalization state into struct sched_entity Mike Galbraith
2016-05-22 9:36 ` Peter Zijlstra
2016-05-22 9:52 ` Mike Galbraith
2016-05-22 10:33 ` Peter Zijlstra
2016-05-23 9:19 ` Peter Zijlstra
2016-05-23 9:40 ` Mike Galbraith
2016-05-23 10:13 ` Wanpeng Li
2016-05-23 10:26 ` Mike Galbraith
2016-05-23 12:28 ` Peter Zijlstra
2016-05-25 7:12 ` [tip:sched/urgent] sched/core: Fix remote wakeups tip-bot for Peter Zijlstra
2016-05-22 6:50 ` [PATCH 2/3] sched,fair: Fix local starvation Wanpeng Li
2016-05-22 7:15 ` Mike Galbraith
2016-05-22 7:27 ` Wanpeng Li
2016-05-22 7:32 ` Mike Galbraith
2016-05-22 7:42 ` Wanpeng Li
2016-05-22 8:04 ` Mike Galbraith
2016-05-22 8:24 ` Wanpeng Li
2016-05-22 8:39 ` Mike Galbraith
2016-05-22 8:50 ` Wanpeng Li
2016-05-10 17:43 ` [PATCH 3/3] sched: Kill sched_class::task_waking Peter Zijlstra
2016-05-11 5:55 ` [PATCH 0/3] sched: Fix wakeup preemption regression Mike Galbraith
2016-05-12 9:56 ` Pavan Kondeti
2016-05-12 10:52 ` Matt Fleming
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=20160510174613.821444209@infradead.org \
--to=peterz@infradead.org \
--cc=ahh@google.com \
--cc=bsegall@google.com \
--cc=byungchul.park@lge.com \
--cc=linux-kernel@vger.kernel.org \
--cc=matt@codeblueprint.co.uk \
--cc=mingo@kernel.org \
--cc=morten.rasmussen@arm.com \
--cc=pjt@google.com \
--cc=pkondeti@codeaurora.org \
--cc=tglx@linutronix.de \
--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
all inboxes | Powered by JetHome®