diff options
author | Peter Zijlstra <peterz@infradead.org> | 2016-05-12 03:19:59 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2016-05-12 03:55:30 -0400 |
commit | c58d25f371f5e4b2dfbec3a7bd6f3c24dd79095b (patch) | |
tree | 98a98e577d9a07dfb8603407679c131f66577d0a /kernel/sched | |
parent | 4eb867651721228ee2eeae142c53378375303e8b (diff) |
sched/fair: Move record_wakee()
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()).
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Andrew Hunter <ahh@google.com>
Cc: Ben Segall <bsegall@google.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Mike Galbraith <umgwanakikbuti@gmail.com>
Cc: Morten Rasmussen <morten.rasmussen@arm.com>
Cc: Paul Turner <pjt@google.com>
Cc: Pavan Kondeti <pkondeti@codeaurora.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: byungchul.park@lge.com
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/sched')
-rw-r--r-- | kernel/sched/fair.c | 61 |
1 files changed, 33 insertions, 28 deletions
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 84e465ae7c63..48633a1c3b46 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c | |||
@@ -4810,24 +4810,6 @@ static unsigned long cpu_avg_load_per_task(int cpu) | |||
4810 | return 0; | 4810 | return 0; |
4811 | } | 4811 | } |
4812 | 4812 | ||
4813 | static void record_wakee(struct task_struct *p) | ||
4814 | { | ||
4815 | /* | ||
4816 | * Rough decay (wiping) for cost saving, don't worry | ||
4817 | * about the boundary, really active task won't care | ||
4818 | * about the loss. | ||
4819 | */ | ||
4820 | if (time_after(jiffies, current->wakee_flip_decay_ts + HZ)) { | ||
4821 | current->wakee_flips >>= 1; | ||
4822 | current->wakee_flip_decay_ts = jiffies; | ||
4823 | } | ||
4824 | |||
4825 | if (current->last_wakee != p) { | ||
4826 | current->last_wakee = p; | ||
4827 | current->wakee_flips++; | ||
4828 | } | ||
4829 | } | ||
4830 | |||
4831 | static void task_waking_fair(struct task_struct *p) | 4813 | static void task_waking_fair(struct task_struct *p) |
4832 | { | 4814 | { |
4833 | struct sched_entity *se = &p->se; | 4815 | struct sched_entity *se = &p->se; |
@@ -4847,7 +4829,6 @@ static void task_waking_fair(struct task_struct *p) | |||
4847 | #endif | 4829 | #endif |
4848 | 4830 | ||
4849 | se->vruntime -= min_vruntime; | 4831 | se->vruntime -= min_vruntime; |
4850 | record_wakee(p); | ||
4851 | } | 4832 | } |
4852 | 4833 | ||
4853 | #ifdef CONFIG_FAIR_GROUP_SCHED | 4834 | #ifdef CONFIG_FAIR_GROUP_SCHED |
@@ -4965,17 +4946,39 @@ static long effective_load(struct task_group *tg, int cpu, long wl, long wg) | |||
4965 | 4946 | ||
4966 | #endif | 4947 | #endif |
4967 | 4948 | ||
4949 | static void record_wakee(struct task_struct *p) | ||
4950 | { | ||
4951 | /* | ||
4952 | * Only decay a single time; tasks that have less then 1 wakeup per | ||
4953 | * jiffy will not have built up many flips. | ||
4954 | */ | ||
4955 | if (time_after(jiffies, current->wakee_flip_decay_ts + HZ)) { | ||
4956 | current->wakee_flips >>= 1; | ||
4957 | current->wakee_flip_decay_ts = jiffies; | ||
4958 | } | ||
4959 | |||
4960 | if (current->last_wakee != p) { | ||
4961 | current->last_wakee = p; | ||
4962 | current->wakee_flips++; | ||
4963 | } | ||
4964 | } | ||
4965 | |||
4968 | /* | 4966 | /* |
4969 | * Detect M:N waker/wakee relationships via a switching-frequency heuristic. | 4967 | * Detect M:N waker/wakee relationships via a switching-frequency heuristic. |
4968 | * | ||
4970 | * A waker of many should wake a different task than the one last awakened | 4969 | * A waker of many should wake a different task than the one last awakened |
4971 | * at a frequency roughly N times higher than one of its wakees. In order | 4970 | * at a frequency roughly N times higher than one of its wakees. |
4972 | * to determine whether we should let the load spread vs consolodating to | 4971 | * |
4973 | * shared cache, we look for a minimum 'flip' frequency of llc_size in one | 4972 | * In order to determine whether we should let the load spread vs consolidating |
4974 | * partner, and a factor of lls_size higher frequency in the other. With | 4973 | * to shared cache, we look for a minimum 'flip' frequency of llc_size in one |
4975 | * both conditions met, we can be relatively sure that the relationship is | 4974 | * partner, and a factor of lls_size higher frequency in the other. |
4976 | * non-monogamous, with partner count exceeding socket size. Waker/wakee | 4975 | * |
4977 | * being client/server, worker/dispatcher, interrupt source or whatever is | 4976 | * With both conditions met, we can be relatively sure that the relationship is |
4978 | * irrelevant, spread criteria is apparent partner count exceeds socket size. | 4977 | * non-monogamous, with partner count exceeding socket size. |
4978 | * | ||
4979 | * Waker/wakee being client/server, worker/dispatcher, interrupt source or | ||
4980 | * whatever is irrelevant, spread criteria is apparent partner count exceeds | ||
4981 | * socket size. | ||
4979 | */ | 4982 | */ |
4980 | static int wake_wide(struct task_struct *p) | 4983 | static int wake_wide(struct task_struct *p) |
4981 | { | 4984 | { |
@@ -5280,8 +5283,10 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, int sd_flag, int wake_f | |||
5280 | int want_affine = 0; | 5283 | int want_affine = 0; |
5281 | int sync = wake_flags & WF_SYNC; | 5284 | int sync = wake_flags & WF_SYNC; |
5282 | 5285 | ||
5283 | if (sd_flag & SD_BALANCE_WAKE) | 5286 | if (sd_flag & SD_BALANCE_WAKE) { |
5287 | record_wakee(p); | ||
5284 | want_affine = !wake_wide(p) && cpumask_test_cpu(cpu, tsk_cpus_allowed(p)); | 5288 | want_affine = !wake_wide(p) && cpumask_test_cpu(cpu, tsk_cpus_allowed(p)); |
5289 | } | ||
5285 | 5290 | ||
5286 | rcu_read_lock(); | 5291 | rcu_read_lock(); |
5287 | for_each_domain(cpu, tmp) { | 5292 | for_each_domain(cpu, tmp) { |