diff options
author | Peter Zijlstra <peterz@infradead.org> | 2016-05-10 12:24:37 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2016-05-12 03:55:31 -0400 |
commit | 59efa0bac9cf8b2ef8d08f7632826c6d90f6a9bb (patch) | |
tree | 45c0c2e9b71edeef0ea4aabc444a2f411ed04dc0 | |
parent | b5179ac70de85ef477cedf8b026a57913754cf1e (diff) |
sched/core: Kill sched_class::task_waking to clean up the migration logic
With sched_class::task_waking being called only when we do
set_task_cpu(), we can make sched_class::migrate_task_rq() do the work
and eliminate sched_class::task_waking entirely.
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>
-rw-r--r-- | kernel/sched/core.c | 9 | ||||
-rw-r--r-- | kernel/sched/fair.c | 58 | ||||
-rw-r--r-- | kernel/sched/sched.h | 7 |
3 files changed, 32 insertions, 42 deletions
diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 1f73e2554bc1..636c4b9cac38 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c | |||
@@ -1717,11 +1717,8 @@ ttwu_do_activate(struct rq *rq, struct task_struct *p, int wake_flags, | |||
1717 | if (p->sched_contributes_to_load) | 1717 | if (p->sched_contributes_to_load) |
1718 | rq->nr_uninterruptible--; | 1718 | rq->nr_uninterruptible--; |
1719 | 1719 | ||
1720 | /* | ||
1721 | * If we migrated; we must have called sched_class::task_waking(). | ||
1722 | */ | ||
1723 | if (wake_flags & WF_MIGRATED) | 1720 | if (wake_flags & WF_MIGRATED) |
1724 | en_flags |= ENQUEUE_WAKING; | 1721 | en_flags |= ENQUEUE_MIGRATED; |
1725 | #endif | 1722 | #endif |
1726 | 1723 | ||
1727 | ttwu_activate(rq, p, en_flags); | 1724 | ttwu_activate(rq, p, en_flags); |
@@ -2049,10 +2046,6 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags) | |||
2049 | cpu = select_task_rq(p, p->wake_cpu, SD_BALANCE_WAKE, wake_flags); | 2046 | cpu = select_task_rq(p, p->wake_cpu, SD_BALANCE_WAKE, wake_flags); |
2050 | if (task_cpu(p) != cpu) { | 2047 | if (task_cpu(p) != cpu) { |
2051 | wake_flags |= WF_MIGRATED; | 2048 | wake_flags |= WF_MIGRATED; |
2052 | |||
2053 | if (p->sched_class->task_waking) | ||
2054 | p->sched_class->task_waking(p); | ||
2055 | |||
2056 | set_task_cpu(p, cpu); | 2049 | set_task_cpu(p, cpu); |
2057 | } | 2050 | } |
2058 | #endif /* CONFIG_SMP */ | 2051 | #endif /* CONFIG_SMP */ |
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 445bcd2d7ee1..24ce01b73906 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c | |||
@@ -3273,7 +3273,7 @@ static inline void check_schedstat_required(void) | |||
3273 | * | 3273 | * |
3274 | * WAKEUP (remote) | 3274 | * WAKEUP (remote) |
3275 | * | 3275 | * |
3276 | * ->task_waking_fair() | 3276 | * ->migrate_task_rq_fair() (p->state == TASK_WAKING) |
3277 | * vruntime -= min_vruntime | 3277 | * vruntime -= min_vruntime |
3278 | * | 3278 | * |
3279 | * enqueue | 3279 | * enqueue |
@@ -3292,7 +3292,7 @@ enqueue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags) | |||
3292 | * Update the normalized vruntime before updating min_vruntime | 3292 | * Update the normalized vruntime before updating min_vruntime |
3293 | * through calling update_curr(). | 3293 | * through calling update_curr(). |
3294 | */ | 3294 | */ |
3295 | if (!(flags & ENQUEUE_WAKEUP) || (flags & ENQUEUE_WAKING)) | 3295 | if (!(flags & ENQUEUE_WAKEUP) || (flags & ENQUEUE_MIGRATED)) |
3296 | se->vruntime += cfs_rq->min_vruntime; | 3296 | se->vruntime += cfs_rq->min_vruntime; |
3297 | 3297 | ||
3298 | /* | 3298 | /* |
@@ -4841,33 +4841,6 @@ static unsigned long cpu_avg_load_per_task(int cpu) | |||
4841 | return 0; | 4841 | return 0; |
4842 | } | 4842 | } |
4843 | 4843 | ||
4844 | /* | ||
4845 | * Called to migrate a waking task; as blocked tasks retain absolute vruntime | ||
4846 | * the migration needs to deal with this by subtracting the old and adding the | ||
4847 | * new min_vruntime -- the latter is done by enqueue_entity() when placing | ||
4848 | * the task on the new runqueue. | ||
4849 | */ | ||
4850 | static void task_waking_fair(struct task_struct *p) | ||
4851 | { | ||
4852 | struct sched_entity *se = &p->se; | ||
4853 | struct cfs_rq *cfs_rq = cfs_rq_of(se); | ||
4854 | u64 min_vruntime; | ||
4855 | |||
4856 | #ifndef CONFIG_64BIT | ||
4857 | u64 min_vruntime_copy; | ||
4858 | |||
4859 | do { | ||
4860 | min_vruntime_copy = cfs_rq->min_vruntime_copy; | ||
4861 | smp_rmb(); | ||
4862 | min_vruntime = cfs_rq->min_vruntime; | ||
4863 | } while (min_vruntime != min_vruntime_copy); | ||
4864 | #else | ||
4865 | min_vruntime = cfs_rq->min_vruntime; | ||
4866 | #endif | ||
4867 | |||
4868 | se->vruntime -= min_vruntime; | ||
4869 | } | ||
4870 | |||
4871 | #ifdef CONFIG_FAIR_GROUP_SCHED | 4844 | #ifdef CONFIG_FAIR_GROUP_SCHED |
4872 | /* | 4845 | /* |
4873 | * effective_load() calculates the load change as seen from the root_task_group | 4846 | * effective_load() calculates the load change as seen from the root_task_group |
@@ -5403,6 +5376,32 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, int sd_flag, int wake_f | |||
5403 | static void migrate_task_rq_fair(struct task_struct *p) | 5376 | static void migrate_task_rq_fair(struct task_struct *p) |
5404 | { | 5377 | { |
5405 | /* | 5378 | /* |
5379 | * As blocked tasks retain absolute vruntime the migration needs to | ||
5380 | * deal with this by subtracting the old and adding the new | ||
5381 | * min_vruntime -- the latter is done by enqueue_entity() when placing | ||
5382 | * the task on the new runqueue. | ||
5383 | */ | ||
5384 | if (p->state == TASK_WAKING) { | ||
5385 | struct sched_entity *se = &p->se; | ||
5386 | struct cfs_rq *cfs_rq = cfs_rq_of(se); | ||
5387 | u64 min_vruntime; | ||
5388 | |||
5389 | #ifndef CONFIG_64BIT | ||
5390 | u64 min_vruntime_copy; | ||
5391 | |||
5392 | do { | ||
5393 | min_vruntime_copy = cfs_rq->min_vruntime_copy; | ||
5394 | smp_rmb(); | ||
5395 | min_vruntime = cfs_rq->min_vruntime; | ||
5396 | } while (min_vruntime != min_vruntime_copy); | ||
5397 | #else | ||
5398 | min_vruntime = cfs_rq->min_vruntime; | ||
5399 | #endif | ||
5400 | |||
5401 | se->vruntime -= min_vruntime; | ||
5402 | } | ||
5403 | |||
5404 | /* | ||
5406 | * We are supposed to update the task to "current" time, then its up to date | 5405 | * We are supposed to update the task to "current" time, then its up to date |
5407 | * and ready to go to new CPU/cfs_rq. But we have difficulty in getting | 5406 | * and ready to go to new CPU/cfs_rq. But we have difficulty in getting |
5408 | * what current time is, so simply throw away the out-of-date time. This | 5407 | * what current time is, so simply throw away the out-of-date time. This |
@@ -8672,7 +8671,6 @@ const struct sched_class fair_sched_class = { | |||
8672 | .rq_online = rq_online_fair, | 8671 | .rq_online = rq_online_fair, |
8673 | .rq_offline = rq_offline_fair, | 8672 | .rq_offline = rq_offline_fair, |
8674 | 8673 | ||
8675 | .task_waking = task_waking_fair, | ||
8676 | .task_dead = task_dead_fair, | 8674 | .task_dead = task_dead_fair, |
8677 | .set_cpus_allowed = set_cpus_allowed_common, | 8675 | .set_cpus_allowed = set_cpus_allowed_common, |
8678 | #endif | 8676 | #endif |
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index ab6adb159e23..e51145e76807 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h | |||
@@ -1168,7 +1168,7 @@ extern const u32 sched_prio_to_wmult[40]; | |||
1168 | * | 1168 | * |
1169 | * ENQUEUE_HEAD - place at front of runqueue (tail if not specified) | 1169 | * ENQUEUE_HEAD - place at front of runqueue (tail if not specified) |
1170 | * ENQUEUE_REPLENISH - CBS (replenish runtime and postpone deadline) | 1170 | * ENQUEUE_REPLENISH - CBS (replenish runtime and postpone deadline) |
1171 | * ENQUEUE_WAKING - sched_class::task_waking was called | 1171 | * ENQUEUE_MIGRATED - the task was migrated during wakeup |
1172 | * | 1172 | * |
1173 | */ | 1173 | */ |
1174 | 1174 | ||
@@ -1183,9 +1183,9 @@ extern const u32 sched_prio_to_wmult[40]; | |||
1183 | #define ENQUEUE_HEAD 0x08 | 1183 | #define ENQUEUE_HEAD 0x08 |
1184 | #define ENQUEUE_REPLENISH 0x10 | 1184 | #define ENQUEUE_REPLENISH 0x10 |
1185 | #ifdef CONFIG_SMP | 1185 | #ifdef CONFIG_SMP |
1186 | #define ENQUEUE_WAKING 0x20 | 1186 | #define ENQUEUE_MIGRATED 0x20 |
1187 | #else | 1187 | #else |
1188 | #define ENQUEUE_WAKING 0x00 | 1188 | #define ENQUEUE_MIGRATED 0x00 |
1189 | #endif | 1189 | #endif |
1190 | 1190 | ||
1191 | #define RETRY_TASK ((void *)-1UL) | 1191 | #define RETRY_TASK ((void *)-1UL) |
@@ -1217,7 +1217,6 @@ struct sched_class { | |||
1217 | int (*select_task_rq)(struct task_struct *p, int task_cpu, int sd_flag, int flags); | 1217 | int (*select_task_rq)(struct task_struct *p, int task_cpu, int sd_flag, int flags); |
1218 | void (*migrate_task_rq)(struct task_struct *p); | 1218 | void (*migrate_task_rq)(struct task_struct *p); |
1219 | 1219 | ||
1220 | void (*task_waking) (struct task_struct *task); | ||
1221 | void (*task_woken) (struct rq *this_rq, struct task_struct *task); | 1220 | void (*task_woken) (struct rq *this_rq, struct task_struct *task); |
1222 | 1221 | ||
1223 | void (*set_cpus_allowed)(struct task_struct *p, | 1222 | void (*set_cpus_allowed)(struct task_struct *p, |