diff options
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/sched.c | 145 | ||||
-rw-r--r-- | kernel/sched_debug.c | 103 | ||||
-rw-r--r-- | kernel/sched_fair.c | 189 | ||||
-rw-r--r-- | kernel/sched_features.h | 55 | ||||
-rw-r--r-- | kernel/sched_rt.c | 2 | ||||
-rw-r--r-- | kernel/time/tick-sched.c | 3 | ||||
-rw-r--r-- | kernel/user.c | 2 |
7 files changed, 141 insertions, 358 deletions
diff --git a/kernel/sched.c b/kernel/sched.c index 49d2fa7b687a..52b7efd27416 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
@@ -492,8 +492,11 @@ struct rq { | |||
492 | #define CPU_LOAD_IDX_MAX 5 | 492 | #define CPU_LOAD_IDX_MAX 5 |
493 | unsigned long cpu_load[CPU_LOAD_IDX_MAX]; | 493 | unsigned long cpu_load[CPU_LOAD_IDX_MAX]; |
494 | #ifdef CONFIG_NO_HZ | 494 | #ifdef CONFIG_NO_HZ |
495 | u64 nohz_stamp; | ||
495 | unsigned char in_nohz_recently; | 496 | unsigned char in_nohz_recently; |
496 | #endif | 497 | #endif |
498 | unsigned int skip_clock_update; | ||
499 | |||
497 | /* capture load from *all* tasks on this cpu: */ | 500 | /* capture load from *all* tasks on this cpu: */ |
498 | struct load_weight load; | 501 | struct load_weight load; |
499 | unsigned long nr_load_updates; | 502 | unsigned long nr_load_updates; |
@@ -591,6 +594,13 @@ static inline | |||
591 | void check_preempt_curr(struct rq *rq, struct task_struct *p, int flags) | 594 | void check_preempt_curr(struct rq *rq, struct task_struct *p, int flags) |
592 | { | 595 | { |
593 | rq->curr->sched_class->check_preempt_curr(rq, p, flags); | 596 | rq->curr->sched_class->check_preempt_curr(rq, p, flags); |
597 | |||
598 | /* | ||
599 | * A queue event has occurred, and we're going to schedule. In | ||
600 | * this case, we can save a useless back to back clock update. | ||
601 | */ | ||
602 | if (test_tsk_need_resched(p)) | ||
603 | rq->skip_clock_update = 1; | ||
594 | } | 604 | } |
595 | 605 | ||
596 | static inline int cpu_of(struct rq *rq) | 606 | static inline int cpu_of(struct rq *rq) |
@@ -625,7 +635,8 @@ static inline int cpu_of(struct rq *rq) | |||
625 | 635 | ||
626 | inline void update_rq_clock(struct rq *rq) | 636 | inline void update_rq_clock(struct rq *rq) |
627 | { | 637 | { |
628 | rq->clock = sched_clock_cpu(cpu_of(rq)); | 638 | if (!rq->skip_clock_update) |
639 | rq->clock = sched_clock_cpu(cpu_of(rq)); | ||
629 | } | 640 | } |
630 | 641 | ||
631 | /* | 642 | /* |
@@ -1228,6 +1239,17 @@ void wake_up_idle_cpu(int cpu) | |||
1228 | if (!tsk_is_polling(rq->idle)) | 1239 | if (!tsk_is_polling(rq->idle)) |
1229 | smp_send_reschedule(cpu); | 1240 | smp_send_reschedule(cpu); |
1230 | } | 1241 | } |
1242 | |||
1243 | int nohz_ratelimit(int cpu) | ||
1244 | { | ||
1245 | struct rq *rq = cpu_rq(cpu); | ||
1246 | u64 diff = rq->clock - rq->nohz_stamp; | ||
1247 | |||
1248 | rq->nohz_stamp = rq->clock; | ||
1249 | |||
1250 | return diff < (NSEC_PER_SEC / HZ) >> 1; | ||
1251 | } | ||
1252 | |||
1231 | #endif /* CONFIG_NO_HZ */ | 1253 | #endif /* CONFIG_NO_HZ */ |
1232 | 1254 | ||
1233 | static u64 sched_avg_period(void) | 1255 | static u64 sched_avg_period(void) |
@@ -1770,8 +1792,6 @@ static void double_rq_lock(struct rq *rq1, struct rq *rq2) | |||
1770 | raw_spin_lock_nested(&rq1->lock, SINGLE_DEPTH_NESTING); | 1792 | raw_spin_lock_nested(&rq1->lock, SINGLE_DEPTH_NESTING); |
1771 | } | 1793 | } |
1772 | } | 1794 | } |
1773 | update_rq_clock(rq1); | ||
1774 | update_rq_clock(rq2); | ||
1775 | } | 1795 | } |
1776 | 1796 | ||
1777 | /* | 1797 | /* |
@@ -1868,9 +1888,7 @@ static void update_avg(u64 *avg, u64 sample) | |||
1868 | static void | 1888 | static void |
1869 | enqueue_task(struct rq *rq, struct task_struct *p, int wakeup, bool head) | 1889 | enqueue_task(struct rq *rq, struct task_struct *p, int wakeup, bool head) |
1870 | { | 1890 | { |
1871 | if (wakeup) | 1891 | update_rq_clock(rq); |
1872 | p->se.start_runtime = p->se.sum_exec_runtime; | ||
1873 | |||
1874 | sched_info_queued(p); | 1892 | sched_info_queued(p); |
1875 | p->sched_class->enqueue_task(rq, p, wakeup, head); | 1893 | p->sched_class->enqueue_task(rq, p, wakeup, head); |
1876 | p->se.on_rq = 1; | 1894 | p->se.on_rq = 1; |
@@ -1878,17 +1896,7 @@ enqueue_task(struct rq *rq, struct task_struct *p, int wakeup, bool head) | |||
1878 | 1896 | ||
1879 | static void dequeue_task(struct rq *rq, struct task_struct *p, int sleep) | 1897 | static void dequeue_task(struct rq *rq, struct task_struct *p, int sleep) |
1880 | { | 1898 | { |
1881 | if (sleep) { | 1899 | update_rq_clock(rq); |
1882 | if (p->se.last_wakeup) { | ||
1883 | update_avg(&p->se.avg_overlap, | ||
1884 | p->se.sum_exec_runtime - p->se.last_wakeup); | ||
1885 | p->se.last_wakeup = 0; | ||
1886 | } else { | ||
1887 | update_avg(&p->se.avg_wakeup, | ||
1888 | sysctl_sched_wakeup_granularity); | ||
1889 | } | ||
1890 | } | ||
1891 | |||
1892 | sched_info_dequeued(p); | 1900 | sched_info_dequeued(p); |
1893 | p->sched_class->dequeue_task(rq, p, sleep); | 1901 | p->sched_class->dequeue_task(rq, p, sleep); |
1894 | p->se.on_rq = 0; | 1902 | p->se.on_rq = 0; |
@@ -2361,14 +2369,10 @@ static int try_to_wake_up(struct task_struct *p, unsigned int state, | |||
2361 | unsigned long flags; | 2369 | unsigned long flags; |
2362 | struct rq *rq; | 2370 | struct rq *rq; |
2363 | 2371 | ||
2364 | if (!sched_feat(SYNC_WAKEUPS)) | ||
2365 | wake_flags &= ~WF_SYNC; | ||
2366 | |||
2367 | this_cpu = get_cpu(); | 2372 | this_cpu = get_cpu(); |
2368 | 2373 | ||
2369 | smp_wmb(); | 2374 | smp_wmb(); |
2370 | rq = task_rq_lock(p, &flags); | 2375 | rq = task_rq_lock(p, &flags); |
2371 | update_rq_clock(rq); | ||
2372 | if (!(p->state & state)) | 2376 | if (!(p->state & state)) |
2373 | goto out; | 2377 | goto out; |
2374 | 2378 | ||
@@ -2409,7 +2413,6 @@ static int try_to_wake_up(struct task_struct *p, unsigned int state, | |||
2409 | 2413 | ||
2410 | rq = cpu_rq(cpu); | 2414 | rq = cpu_rq(cpu); |
2411 | raw_spin_lock(&rq->lock); | 2415 | raw_spin_lock(&rq->lock); |
2412 | update_rq_clock(rq); | ||
2413 | 2416 | ||
2414 | /* | 2417 | /* |
2415 | * We migrated the task without holding either rq->lock, however | 2418 | * We migrated the task without holding either rq->lock, however |
@@ -2437,34 +2440,18 @@ static int try_to_wake_up(struct task_struct *p, unsigned int state, | |||
2437 | 2440 | ||
2438 | out_activate: | 2441 | out_activate: |
2439 | #endif /* CONFIG_SMP */ | 2442 | #endif /* CONFIG_SMP */ |
2440 | schedstat_inc(p, se.nr_wakeups); | 2443 | schedstat_inc(p, se.statistics.nr_wakeups); |
2441 | if (wake_flags & WF_SYNC) | 2444 | if (wake_flags & WF_SYNC) |
2442 | schedstat_inc(p, se.nr_wakeups_sync); | 2445 | schedstat_inc(p, se.statistics.nr_wakeups_sync); |
2443 | if (orig_cpu != cpu) | 2446 | if (orig_cpu != cpu) |
2444 | schedstat_inc(p, se.nr_wakeups_migrate); | 2447 | schedstat_inc(p, se.statistics.nr_wakeups_migrate); |
2445 | if (cpu == this_cpu) | 2448 | if (cpu == this_cpu) |
2446 | schedstat_inc(p, se.nr_wakeups_local); | 2449 | schedstat_inc(p, se.statistics.nr_wakeups_local); |
2447 | else | 2450 | else |
2448 | schedstat_inc(p, se.nr_wakeups_remote); | 2451 | schedstat_inc(p, se.statistics.nr_wakeups_remote); |
2449 | activate_task(rq, p, 1); | 2452 | activate_task(rq, p, 1); |
2450 | success = 1; | 2453 | success = 1; |
2451 | 2454 | ||
2452 | /* | ||
2453 | * Only attribute actual wakeups done by this task. | ||
2454 | */ | ||
2455 | if (!in_interrupt()) { | ||
2456 | struct sched_entity *se = ¤t->se; | ||
2457 | u64 sample = se->sum_exec_runtime; | ||
2458 | |||
2459 | if (se->last_wakeup) | ||
2460 | sample -= se->last_wakeup; | ||
2461 | else | ||
2462 | sample -= se->start_runtime; | ||
2463 | update_avg(&se->avg_wakeup, sample); | ||
2464 | |||
2465 | se->last_wakeup = se->sum_exec_runtime; | ||
2466 | } | ||
2467 | |||
2468 | out_running: | 2455 | out_running: |
2469 | trace_sched_wakeup(rq, p, success); | 2456 | trace_sched_wakeup(rq, p, success); |
2470 | check_preempt_curr(rq, p, wake_flags); | 2457 | check_preempt_curr(rq, p, wake_flags); |
@@ -2526,42 +2513,9 @@ static void __sched_fork(struct task_struct *p) | |||
2526 | p->se.sum_exec_runtime = 0; | 2513 | p->se.sum_exec_runtime = 0; |
2527 | p->se.prev_sum_exec_runtime = 0; | 2514 | p->se.prev_sum_exec_runtime = 0; |
2528 | p->se.nr_migrations = 0; | 2515 | p->se.nr_migrations = 0; |
2529 | p->se.last_wakeup = 0; | ||
2530 | p->se.avg_overlap = 0; | ||
2531 | p->se.start_runtime = 0; | ||
2532 | p->se.avg_wakeup = sysctl_sched_wakeup_granularity; | ||
2533 | 2516 | ||
2534 | #ifdef CONFIG_SCHEDSTATS | 2517 | #ifdef CONFIG_SCHEDSTATS |
2535 | p->se.wait_start = 0; | 2518 | memset(&p->se.statistics, 0, sizeof(p->se.statistics)); |
2536 | p->se.wait_max = 0; | ||
2537 | p->se.wait_count = 0; | ||
2538 | p->se.wait_sum = 0; | ||
2539 | |||
2540 | p->se.sleep_start = 0; | ||
2541 | p->se.sleep_max = 0; | ||
2542 | p->se.sum_sleep_runtime = 0; | ||
2543 | |||
2544 | p->se.block_start = 0; | ||
2545 | p->se.block_max = 0; | ||
2546 | p->se.exec_max = 0; | ||
2547 | p->se.slice_max = 0; | ||
2548 | |||
2549 | p->se.nr_migrations_cold = 0; | ||
2550 | p->se.nr_failed_migrations_affine = 0; | ||
2551 | p->se.nr_failed_migrations_running = 0; | ||
2552 | p->se.nr_failed_migrations_hot = 0; | ||
2553 | p->se.nr_forced_migrations = 0; | ||
2554 | |||
2555 | p->se.nr_wakeups = 0; | ||
2556 | p->se.nr_wakeups_sync = 0; | ||
2557 | p->se.nr_wakeups_migrate = 0; | ||
2558 | p->se.nr_wakeups_local = 0; | ||
2559 | p->se.nr_wakeups_remote = 0; | ||
2560 | p->se.nr_wakeups_affine = 0; | ||
2561 | p->se.nr_wakeups_affine_attempts = 0; | ||
2562 | p->se.nr_wakeups_passive = 0; | ||
2563 | p->se.nr_wakeups_idle = 0; | ||
2564 | |||
2565 | #endif | 2519 | #endif |
2566 | 2520 | ||
2567 | INIT_LIST_HEAD(&p->rt.run_list); | 2521 | INIT_LIST_HEAD(&p->rt.run_list); |
@@ -2675,7 +2629,6 @@ void wake_up_new_task(struct task_struct *p, unsigned long clone_flags) | |||
2675 | 2629 | ||
2676 | BUG_ON(p->state != TASK_WAKING); | 2630 | BUG_ON(p->state != TASK_WAKING); |
2677 | p->state = TASK_RUNNING; | 2631 | p->state = TASK_RUNNING; |
2678 | update_rq_clock(rq); | ||
2679 | activate_task(rq, p, 0); | 2632 | activate_task(rq, p, 0); |
2680 | trace_sched_wakeup_new(rq, p, 1); | 2633 | trace_sched_wakeup_new(rq, p, 1); |
2681 | check_preempt_curr(rq, p, WF_FORK); | 2634 | check_preempt_curr(rq, p, WF_FORK); |
@@ -3629,23 +3582,9 @@ static inline void schedule_debug(struct task_struct *prev) | |||
3629 | 3582 | ||
3630 | static void put_prev_task(struct rq *rq, struct task_struct *prev) | 3583 | static void put_prev_task(struct rq *rq, struct task_struct *prev) |
3631 | { | 3584 | { |
3632 | if (prev->state == TASK_RUNNING) { | 3585 | if (prev->se.on_rq) |
3633 | u64 runtime = prev->se.sum_exec_runtime; | 3586 | update_rq_clock(rq); |
3634 | 3587 | rq->skip_clock_update = 0; | |
3635 | runtime -= prev->se.prev_sum_exec_runtime; | ||
3636 | runtime = min_t(u64, runtime, 2*sysctl_sched_migration_cost); | ||
3637 | |||
3638 | /* | ||
3639 | * In order to avoid avg_overlap growing stale when we are | ||
3640 | * indeed overlapping and hence not getting put to sleep, grow | ||
3641 | * the avg_overlap on preemption. | ||
3642 | * | ||
3643 | * We use the average preemption runtime because that | ||
3644 | * correlates to the amount of cache footprint a task can | ||
3645 | * build up. | ||
3646 | */ | ||
3647 | update_avg(&prev->se.avg_overlap, runtime); | ||
3648 | } | ||
3649 | prev->sched_class->put_prev_task(rq, prev); | 3588 | prev->sched_class->put_prev_task(rq, prev); |
3650 | } | 3589 | } |
3651 | 3590 | ||
@@ -3708,7 +3647,6 @@ need_resched_nonpreemptible: | |||
3708 | hrtick_clear(rq); | 3647 | hrtick_clear(rq); |
3709 | 3648 | ||
3710 | raw_spin_lock_irq(&rq->lock); | 3649 | raw_spin_lock_irq(&rq->lock); |
3711 | update_rq_clock(rq); | ||
3712 | clear_tsk_need_resched(prev); | 3650 | clear_tsk_need_resched(prev); |
3713 | 3651 | ||
3714 | if (prev->state && !(preempt_count() & PREEMPT_ACTIVE)) { | 3652 | if (prev->state && !(preempt_count() & PREEMPT_ACTIVE)) { |
@@ -4265,7 +4203,6 @@ void rt_mutex_setprio(struct task_struct *p, int prio) | |||
4265 | BUG_ON(prio < 0 || prio > MAX_PRIO); | 4203 | BUG_ON(prio < 0 || prio > MAX_PRIO); |
4266 | 4204 | ||
4267 | rq = task_rq_lock(p, &flags); | 4205 | rq = task_rq_lock(p, &flags); |
4268 | update_rq_clock(rq); | ||
4269 | 4206 | ||
4270 | oldprio = p->prio; | 4207 | oldprio = p->prio; |
4271 | prev_class = p->sched_class; | 4208 | prev_class = p->sched_class; |
@@ -4308,7 +4245,6 @@ void set_user_nice(struct task_struct *p, long nice) | |||
4308 | * the task might be in the middle of scheduling on another CPU. | 4245 | * the task might be in the middle of scheduling on another CPU. |
4309 | */ | 4246 | */ |
4310 | rq = task_rq_lock(p, &flags); | 4247 | rq = task_rq_lock(p, &flags); |
4311 | update_rq_clock(rq); | ||
4312 | /* | 4248 | /* |
4313 | * The RT priorities are set via sched_setscheduler(), but we still | 4249 | * The RT priorities are set via sched_setscheduler(), but we still |
4314 | * allow the 'normal' nice value to be set - but as expected | 4250 | * allow the 'normal' nice value to be set - but as expected |
@@ -4591,7 +4527,6 @@ recheck: | |||
4591 | raw_spin_unlock_irqrestore(&p->pi_lock, flags); | 4527 | raw_spin_unlock_irqrestore(&p->pi_lock, flags); |
4592 | goto recheck; | 4528 | goto recheck; |
4593 | } | 4529 | } |
4594 | update_rq_clock(rq); | ||
4595 | on_rq = p->se.on_rq; | 4530 | on_rq = p->se.on_rq; |
4596 | running = task_current(rq, p); | 4531 | running = task_current(rq, p); |
4597 | if (on_rq) | 4532 | if (on_rq) |
@@ -5602,7 +5537,6 @@ void sched_idle_next(void) | |||
5602 | 5537 | ||
5603 | __setscheduler(rq, p, SCHED_FIFO, MAX_RT_PRIO-1); | 5538 | __setscheduler(rq, p, SCHED_FIFO, MAX_RT_PRIO-1); |
5604 | 5539 | ||
5605 | update_rq_clock(rq); | ||
5606 | activate_task(rq, p, 0); | 5540 | activate_task(rq, p, 0); |
5607 | 5541 | ||
5608 | raw_spin_unlock_irqrestore(&rq->lock, flags); | 5542 | raw_spin_unlock_irqrestore(&rq->lock, flags); |
@@ -5657,7 +5591,6 @@ static void migrate_dead_tasks(unsigned int dead_cpu) | |||
5657 | for ( ; ; ) { | 5591 | for ( ; ; ) { |
5658 | if (!rq->nr_running) | 5592 | if (!rq->nr_running) |
5659 | break; | 5593 | break; |
5660 | update_rq_clock(rq); | ||
5661 | next = pick_next_task(rq); | 5594 | next = pick_next_task(rq); |
5662 | if (!next) | 5595 | if (!next) |
5663 | break; | 5596 | break; |
@@ -5941,7 +5874,6 @@ migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu) | |||
5941 | rq->migration_thread = NULL; | 5874 | rq->migration_thread = NULL; |
5942 | /* Idle task back to normal (off runqueue, low prio) */ | 5875 | /* Idle task back to normal (off runqueue, low prio) */ |
5943 | raw_spin_lock_irq(&rq->lock); | 5876 | raw_spin_lock_irq(&rq->lock); |
5944 | update_rq_clock(rq); | ||
5945 | deactivate_task(rq, rq->idle, 0); | 5877 | deactivate_task(rq, rq->idle, 0); |
5946 | __setscheduler(rq, rq->idle, SCHED_NORMAL, 0); | 5878 | __setscheduler(rq, rq->idle, SCHED_NORMAL, 0); |
5947 | rq->idle->sched_class = &idle_sched_class; | 5879 | rq->idle->sched_class = &idle_sched_class; |
@@ -7891,7 +7823,6 @@ static void normalize_task(struct rq *rq, struct task_struct *p) | |||
7891 | { | 7823 | { |
7892 | int on_rq; | 7824 | int on_rq; |
7893 | 7825 | ||
7894 | update_rq_clock(rq); | ||
7895 | on_rq = p->se.on_rq; | 7826 | on_rq = p->se.on_rq; |
7896 | if (on_rq) | 7827 | if (on_rq) |
7897 | deactivate_task(rq, p, 0); | 7828 | deactivate_task(rq, p, 0); |
@@ -7918,9 +7849,9 @@ void normalize_rt_tasks(void) | |||
7918 | 7849 | ||
7919 | p->se.exec_start = 0; | 7850 | p->se.exec_start = 0; |
7920 | #ifdef CONFIG_SCHEDSTATS | 7851 | #ifdef CONFIG_SCHEDSTATS |
7921 | p->se.wait_start = 0; | 7852 | p->se.statistics.wait_start = 0; |
7922 | p->se.sleep_start = 0; | 7853 | p->se.statistics.sleep_start = 0; |
7923 | p->se.block_start = 0; | 7854 | p->se.statistics.block_start = 0; |
7924 | #endif | 7855 | #endif |
7925 | 7856 | ||
7926 | if (!rt_task(p)) { | 7857 | if (!rt_task(p)) { |
@@ -8253,8 +8184,6 @@ void sched_move_task(struct task_struct *tsk) | |||
8253 | 8184 | ||
8254 | rq = task_rq_lock(tsk, &flags); | 8185 | rq = task_rq_lock(tsk, &flags); |
8255 | 8186 | ||
8256 | update_rq_clock(rq); | ||
8257 | |||
8258 | running = task_current(rq, tsk); | 8187 | running = task_current(rq, tsk); |
8259 | on_rq = tsk->se.on_rq; | 8188 | on_rq = tsk->se.on_rq; |
8260 | 8189 | ||
diff --git a/kernel/sched_debug.c b/kernel/sched_debug.c index 67f95aada4b9..8a46a719f367 100644 --- a/kernel/sched_debug.c +++ b/kernel/sched_debug.c | |||
@@ -70,16 +70,16 @@ static void print_cfs_group_stats(struct seq_file *m, int cpu, | |||
70 | PN(se->vruntime); | 70 | PN(se->vruntime); |
71 | PN(se->sum_exec_runtime); | 71 | PN(se->sum_exec_runtime); |
72 | #ifdef CONFIG_SCHEDSTATS | 72 | #ifdef CONFIG_SCHEDSTATS |
73 | PN(se->wait_start); | 73 | PN(se->statistics.wait_start); |
74 | PN(se->sleep_start); | 74 | PN(se->statistics.sleep_start); |
75 | PN(se->block_start); | 75 | PN(se->statistics.block_start); |
76 | PN(se->sleep_max); | 76 | PN(se->statistics.sleep_max); |
77 | PN(se->block_max); | 77 | PN(se->statistics.block_max); |
78 | PN(se->exec_max); | 78 | PN(se->statistics.exec_max); |
79 | PN(se->slice_max); | 79 | PN(se->statistics.slice_max); |
80 | PN(se->wait_max); | 80 | PN(se->statistics.wait_max); |
81 | PN(se->wait_sum); | 81 | PN(se->statistics.wait_sum); |
82 | P(se->wait_count); | 82 | P(se->statistics.wait_count); |
83 | #endif | 83 | #endif |
84 | P(se->load.weight); | 84 | P(se->load.weight); |
85 | #undef PN | 85 | #undef PN |
@@ -104,7 +104,7 @@ print_task(struct seq_file *m, struct rq *rq, struct task_struct *p) | |||
104 | SEQ_printf(m, "%9Ld.%06ld %9Ld.%06ld %9Ld.%06ld", | 104 | SEQ_printf(m, "%9Ld.%06ld %9Ld.%06ld %9Ld.%06ld", |
105 | SPLIT_NS(p->se.vruntime), | 105 | SPLIT_NS(p->se.vruntime), |
106 | SPLIT_NS(p->se.sum_exec_runtime), | 106 | SPLIT_NS(p->se.sum_exec_runtime), |
107 | SPLIT_NS(p->se.sum_sleep_runtime)); | 107 | SPLIT_NS(p->se.statistics.sum_sleep_runtime)); |
108 | #else | 108 | #else |
109 | SEQ_printf(m, "%15Ld %15Ld %15Ld.%06ld %15Ld.%06ld %15Ld.%06ld", | 109 | SEQ_printf(m, "%15Ld %15Ld %15Ld.%06ld %15Ld.%06ld %15Ld.%06ld", |
110 | 0LL, 0LL, 0LL, 0L, 0LL, 0L, 0LL, 0L); | 110 | 0LL, 0LL, 0LL, 0L, 0LL, 0L, 0LL, 0L); |
@@ -407,40 +407,38 @@ void proc_sched_show_task(struct task_struct *p, struct seq_file *m) | |||
407 | PN(se.exec_start); | 407 | PN(se.exec_start); |
408 | PN(se.vruntime); | 408 | PN(se.vruntime); |
409 | PN(se.sum_exec_runtime); | 409 | PN(se.sum_exec_runtime); |
410 | PN(se.avg_overlap); | ||
411 | PN(se.avg_wakeup); | ||
412 | 410 | ||
413 | nr_switches = p->nvcsw + p->nivcsw; | 411 | nr_switches = p->nvcsw + p->nivcsw; |
414 | 412 | ||
415 | #ifdef CONFIG_SCHEDSTATS | 413 | #ifdef CONFIG_SCHEDSTATS |
416 | PN(se.wait_start); | 414 | PN(se.statistics.wait_start); |
417 | PN(se.sleep_start); | 415 | PN(se.statistics.sleep_start); |
418 | PN(se.block_start); | 416 | PN(se.statistics.block_start); |
419 | PN(se.sleep_max); | 417 | PN(se.statistics.sleep_max); |
420 | PN(se.block_max); | 418 | PN(se.statistics.block_max); |
421 | PN(se.exec_max); | 419 | PN(se.statistics.exec_max); |
422 | PN(se.slice_max); | 420 | PN(se.statistics.slice_max); |
423 | PN(se.wait_max); | 421 | PN(se.statistics.wait_max); |
424 | PN(se.wait_sum); | 422 | PN(se.statistics.wait_sum); |
425 | P(se.wait_count); | 423 | P(se.statistics.wait_count); |
426 | PN(se.iowait_sum); | 424 | PN(se.statistics.iowait_sum); |
427 | P(se.iowait_count); | 425 | P(se.statistics.iowait_count); |
428 | P(sched_info.bkl_count); | 426 | P(sched_info.bkl_count); |
429 | P(se.nr_migrations); | 427 | P(se.nr_migrations); |
430 | P(se.nr_migrations_cold); | 428 | P(se.statistics.nr_migrations_cold); |
431 | P(se.nr_failed_migrations_affine); | 429 | P(se.statistics.nr_failed_migrations_affine); |
432 | P(se.nr_failed_migrations_running); | 430 | P(se.statistics.nr_failed_migrations_running); |
433 | P(se.nr_failed_migrations_hot); | 431 | P(se.statistics.nr_failed_migrations_hot); |
434 | P(se.nr_forced_migrations); | 432 | P(se.statistics.nr_forced_migrations); |
435 | P(se.nr_wakeups); | 433 | P(se.statistics.nr_wakeups); |
436 | P(se.nr_wakeups_sync); | 434 | P(se.statistics.nr_wakeups_sync); |
437 | P(se.nr_wakeups_migrate); | 435 | P(se.statistics.nr_wakeups_migrate); |
438 | P(se.nr_wakeups_local); | 436 | P(se.statistics.nr_wakeups_local); |
439 | P(se.nr_wakeups_remote); | 437 | P(se.statistics.nr_wakeups_remote); |
440 | P(se.nr_wakeups_affine); | 438 | P(se.statistics.nr_wakeups_affine); |
441 | P(se.nr_wakeups_affine_attempts); | 439 | P(se.statistics.nr_wakeups_affine_attempts); |
442 | P(se.nr_wakeups_passive); | 440 | P(se.statistics.nr_wakeups_passive); |
443 | P(se.nr_wakeups_idle); | 441 | P(se.statistics.nr_wakeups_idle); |
444 | 442 | ||
445 | { | 443 | { |
446 | u64 avg_atom, avg_per_cpu; | 444 | u64 avg_atom, avg_per_cpu; |
@@ -491,32 +489,7 @@ void proc_sched_show_task(struct task_struct *p, struct seq_file *m) | |||
491 | void proc_sched_set_task(struct task_struct *p) | 489 | void proc_sched_set_task(struct task_struct *p) |
492 | { | 490 | { |
493 | #ifdef CONFIG_SCHEDSTATS | 491 | #ifdef CONFIG_SCHEDSTATS |
494 | p->se.wait_max = 0; | 492 | memset(&p->se.statistics, 0, sizeof(p->se.statistics)); |
495 | p->se.wait_sum = 0; | ||
496 | p->se.wait_count = 0; | ||
497 | p->se.iowait_sum = 0; | ||
498 | p->se.iowait_count = 0; | ||
499 | p->se.sleep_max = 0; | ||
500 | p->se.sum_sleep_runtime = 0; | ||
501 | p->se.block_max = 0; | ||
502 | p->se.exec_max = 0; | ||
503 | p->se.slice_max = 0; | ||
504 | p->se.nr_migrations = 0; | ||
505 | p->se.nr_migrations_cold = 0; | ||
506 | p->se.nr_failed_migrations_affine = 0; | ||
507 | p->se.nr_failed_migrations_running = 0; | ||
508 | p->se.nr_failed_migrations_hot = 0; | ||
509 | p->se.nr_forced_migrations = 0; | ||
510 | p->se.nr_wakeups = 0; | ||
511 | p->se.nr_wakeups_sync = 0; | ||
512 | p->se.nr_wakeups_migrate = 0; | ||
513 | p->se.nr_wakeups_local = 0; | ||
514 | p->se.nr_wakeups_remote = 0; | ||
515 | p->se.nr_wakeups_affine = 0; | ||
516 | p->se.nr_wakeups_affine_attempts = 0; | ||
517 | p->se.nr_wakeups_passive = 0; | ||
518 | p->se.nr_wakeups_idle = 0; | ||
519 | p->sched_info.bkl_count = 0; | ||
520 | #endif | 493 | #endif |
521 | p->se.sum_exec_runtime = 0; | 494 | p->se.sum_exec_runtime = 0; |
522 | p->se.prev_sum_exec_runtime = 0; | 495 | p->se.prev_sum_exec_runtime = 0; |
diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c index 5a5ea2cd924f..49ad99378f82 100644 --- a/kernel/sched_fair.c +++ b/kernel/sched_fair.c | |||
@@ -35,8 +35,8 @@ | |||
35 | * (to see the precise effective timeslice length of your workload, | 35 | * (to see the precise effective timeslice length of your workload, |
36 | * run vmstat and monitor the context-switches (cs) field) | 36 | * run vmstat and monitor the context-switches (cs) field) |
37 | */ | 37 | */ |
38 | unsigned int sysctl_sched_latency = 5000000ULL; | 38 | unsigned int sysctl_sched_latency = 6000000ULL; |
39 | unsigned int normalized_sysctl_sched_latency = 5000000ULL; | 39 | unsigned int normalized_sysctl_sched_latency = 6000000ULL; |
40 | 40 | ||
41 | /* | 41 | /* |
42 | * The initial- and re-scaling of tunables is configurable | 42 | * The initial- and re-scaling of tunables is configurable |
@@ -52,15 +52,15 @@ enum sched_tunable_scaling sysctl_sched_tunable_scaling | |||
52 | 52 | ||
53 | /* | 53 | /* |
54 | * Minimal preemption granularity for CPU-bound tasks: | 54 | * Minimal preemption granularity for CPU-bound tasks: |
55 | * (default: 1 msec * (1 + ilog(ncpus)), units: nanoseconds) | 55 | * (default: 2 msec * (1 + ilog(ncpus)), units: nanoseconds) |
56 | */ | 56 | */ |
57 | unsigned int sysctl_sched_min_granularity = 1000000ULL; | 57 | unsigned int sysctl_sched_min_granularity = 2000000ULL; |
58 | unsigned int normalized_sysctl_sched_min_granularity = 1000000ULL; | 58 | unsigned int normalized_sysctl_sched_min_granularity = 2000000ULL; |
59 | 59 | ||
60 | /* | 60 | /* |
61 | * is kept at sysctl_sched_latency / sysctl_sched_min_granularity | 61 | * is kept at sysctl_sched_latency / sysctl_sched_min_granularity |
62 | */ | 62 | */ |
63 | static unsigned int sched_nr_latency = 5; | 63 | static unsigned int sched_nr_latency = 3; |
64 | 64 | ||
65 | /* | 65 | /* |
66 | * After fork, child runs first. If set to 0 (default) then | 66 | * After fork, child runs first. If set to 0 (default) then |
@@ -505,7 +505,8 @@ __update_curr(struct cfs_rq *cfs_rq, struct sched_entity *curr, | |||
505 | { | 505 | { |
506 | unsigned long delta_exec_weighted; | 506 | unsigned long delta_exec_weighted; |
507 | 507 | ||
508 | schedstat_set(curr->exec_max, max((u64)delta_exec, curr->exec_max)); | 508 | schedstat_set(curr->statistics.exec_max, |
509 | max((u64)delta_exec, curr->statistics.exec_max)); | ||
509 | 510 | ||
510 | curr->sum_exec_runtime += delta_exec; | 511 | curr->sum_exec_runtime += delta_exec; |
511 | schedstat_add(cfs_rq, exec_clock, delta_exec); | 512 | schedstat_add(cfs_rq, exec_clock, delta_exec); |
@@ -548,7 +549,7 @@ static void update_curr(struct cfs_rq *cfs_rq) | |||
548 | static inline void | 549 | static inline void |
549 | update_stats_wait_start(struct cfs_rq *cfs_rq, struct sched_entity *se) | 550 | update_stats_wait_start(struct cfs_rq *cfs_rq, struct sched_entity *se) |
550 | { | 551 | { |
551 | schedstat_set(se->wait_start, rq_of(cfs_rq)->clock); | 552 | schedstat_set(se->statistics.wait_start, rq_of(cfs_rq)->clock); |
552 | } | 553 | } |
553 | 554 | ||
554 | /* | 555 | /* |
@@ -567,18 +568,18 @@ static void update_stats_enqueue(struct cfs_rq *cfs_rq, struct sched_entity *se) | |||
567 | static void | 568 | static void |
568 | update_stats_wait_end(struct cfs_rq *cfs_rq, struct sched_entity *se) | 569 | update_stats_wait_end(struct cfs_rq *cfs_rq, struct sched_entity *se) |
569 | { | 570 | { |
570 | schedstat_set(se->wait_max, max(se->wait_max, | 571 | schedstat_set(se->statistics.wait_max, max(se->statistics.wait_max, |
571 | rq_of(cfs_rq)->clock - se->wait_start)); | 572 | rq_of(cfs_rq)->clock - se->statistics.wait_start)); |
572 | schedstat_set(se->wait_count, se->wait_count + 1); | 573 | schedstat_set(se->statistics.wait_count, se->statistics.wait_count + 1); |
573 | schedstat_set(se->wait_sum, se->wait_sum + | 574 | schedstat_set(se->statistics.wait_sum, se->statistics.wait_sum + |
574 | rq_of(cfs_rq)->clock - se->wait_start); | 575 | rq_of(cfs_rq)->clock - se->statistics.wait_start); |
575 | #ifdef CONFIG_SCHEDSTATS | 576 | #ifdef CONFIG_SCHEDSTATS |
576 | if (entity_is_task(se)) { | 577 | if (entity_is_task(se)) { |
577 | trace_sched_stat_wait(task_of(se), | 578 | trace_sched_stat_wait(task_of(se), |
578 | rq_of(cfs_rq)->clock - se->wait_start); | 579 | rq_of(cfs_rq)->clock - se->statistics.wait_start); |
579 | } | 580 | } |
580 | #endif | 581 | #endif |
581 | schedstat_set(se->wait_start, 0); | 582 | schedstat_set(se->statistics.wait_start, 0); |
582 | } | 583 | } |
583 | 584 | ||
584 | static inline void | 585 | static inline void |
@@ -657,39 +658,39 @@ static void enqueue_sleeper(struct cfs_rq *cfs_rq, struct sched_entity *se) | |||
657 | if (entity_is_task(se)) | 658 | if (entity_is_task(se)) |
658 | tsk = task_of(se); | 659 | tsk = task_of(se); |
659 | 660 | ||
660 | if (se->sleep_start) { | 661 | if (se->statistics.sleep_start) { |
661 | u64 delta = rq_of(cfs_rq)->clock - se->sleep_start; | 662 | u64 delta = rq_of(cfs_rq)->clock - se->statistics.sleep_start; |
662 | 663 | ||
663 | if ((s64)delta < 0) | 664 | if ((s64)delta < 0) |
664 | delta = 0; | 665 | delta = 0; |
665 | 666 | ||
666 | if (unlikely(delta > se->sleep_max)) | 667 | if (unlikely(delta > se->statistics.sleep_max)) |
667 | se->sleep_max = delta; | 668 | se->statistics.sleep_max = delta; |
668 | 669 | ||
669 | se->sleep_start = 0; | 670 | se->statistics.sleep_start = 0; |
670 | se->sum_sleep_runtime += delta; | 671 | se->statistics.sum_sleep_runtime += delta; |
671 | 672 | ||
672 | if (tsk) { | 673 | if (tsk) { |
673 | account_scheduler_latency(tsk, delta >> 10, 1); | 674 | account_scheduler_latency(tsk, delta >> 10, 1); |
674 | trace_sched_stat_sleep(tsk, delta); | 675 | trace_sched_stat_sleep(tsk, delta); |
675 | } | 676 | } |
676 | } | 677 | } |
677 | if (se->block_start) { | 678 | if (se->statistics.block_start) { |
678 | u64 delta = rq_of(cfs_rq)->clock - se->block_start; | 679 | u64 delta = rq_of(cfs_rq)->clock - se->statistics.block_start; |
679 | 680 | ||
680 | if ((s64)delta < 0) | 681 | if ((s64)delta < 0) |
681 | delta = 0; | 682 | delta = 0; |
682 | 683 | ||
683 | if (unlikely(delta > se->block_max)) | 684 | if (unlikely(delta > se->statistics.block_max)) |
684 | se->block_max = delta; | 685 | se->statistics.block_max = delta; |
685 | 686 | ||
686 | se->block_start = 0; | 687 | se->statistics.block_start = 0; |
687 | se->sum_sleep_runtime += delta; | 688 | se->statistics.sum_sleep_runtime += delta; |
688 | 689 | ||
689 | if (tsk) { | 690 | if (tsk) { |
690 | if (tsk->in_iowait) { | 691 | if (tsk->in_iowait) { |
691 | se->iowait_sum += delta; | 692 | se->statistics.iowait_sum += delta; |
692 | se->iowait_count++; | 693 | se->statistics.iowait_count++; |
693 | trace_sched_stat_iowait(tsk, delta); | 694 | trace_sched_stat_iowait(tsk, delta); |
694 | } | 695 | } |
695 | 696 | ||
@@ -737,20 +738,10 @@ place_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int initial) | |||
737 | vruntime += sched_vslice(cfs_rq, se); | 738 | vruntime += sched_vslice(cfs_rq, se); |
738 | 739 | ||
739 | /* sleeps up to a single latency don't count. */ | 740 | /* sleeps up to a single latency don't count. */ |
740 | if (!initial && sched_feat(FAIR_SLEEPERS)) { | 741 | if (!initial) { |
741 | unsigned long thresh = sysctl_sched_latency; | 742 | unsigned long thresh = sysctl_sched_latency; |
742 | 743 | ||
743 | /* | 744 | /* |
744 | * Convert the sleeper threshold into virtual time. | ||
745 | * SCHED_IDLE is a special sub-class. We care about | ||
746 | * fairness only relative to other SCHED_IDLE tasks, | ||
747 | * all of which have the same weight. | ||
748 | */ | ||
749 | if (sched_feat(NORMALIZED_SLEEPER) && (!entity_is_task(se) || | ||
750 | task_of(se)->policy != SCHED_IDLE)) | ||
751 | thresh = calc_delta_fair(thresh, se); | ||
752 | |||
753 | /* | ||
754 | * Halve their sleep time's effect, to allow | 745 | * Halve their sleep time's effect, to allow |
755 | * for a gentler effect of sleepers: | 746 | * for a gentler effect of sleepers: |
756 | */ | 747 | */ |
@@ -826,9 +817,9 @@ dequeue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int sleep) | |||
826 | struct task_struct *tsk = task_of(se); | 817 | struct task_struct *tsk = task_of(se); |
827 | 818 | ||
828 | if (tsk->state & TASK_INTERRUPTIBLE) | 819 | if (tsk->state & TASK_INTERRUPTIBLE) |
829 | se->sleep_start = rq_of(cfs_rq)->clock; | 820 | se->statistics.sleep_start = rq_of(cfs_rq)->clock; |
830 | if (tsk->state & TASK_UNINTERRUPTIBLE) | 821 | if (tsk->state & TASK_UNINTERRUPTIBLE) |
831 | se->block_start = rq_of(cfs_rq)->clock; | 822 | se->statistics.block_start = rq_of(cfs_rq)->clock; |
832 | } | 823 | } |
833 | #endif | 824 | #endif |
834 | } | 825 | } |
@@ -912,7 +903,7 @@ set_next_entity(struct cfs_rq *cfs_rq, struct sched_entity *se) | |||
912 | * when there are only lesser-weight tasks around): | 903 | * when there are only lesser-weight tasks around): |
913 | */ | 904 | */ |
914 | if (rq_of(cfs_rq)->load.weight >= 2*se->load.weight) { | 905 | if (rq_of(cfs_rq)->load.weight >= 2*se->load.weight) { |
915 | se->slice_max = max(se->slice_max, | 906 | se->statistics.slice_max = max(se->statistics.slice_max, |
916 | se->sum_exec_runtime - se->prev_sum_exec_runtime); | 907 | se->sum_exec_runtime - se->prev_sum_exec_runtime); |
917 | } | 908 | } |
918 | #endif | 909 | #endif |
@@ -1240,7 +1231,6 @@ static inline unsigned long effective_load(struct task_group *tg, int cpu, | |||
1240 | 1231 | ||
1241 | static int wake_affine(struct sched_domain *sd, struct task_struct *p, int sync) | 1232 | static int wake_affine(struct sched_domain *sd, struct task_struct *p, int sync) |
1242 | { | 1233 | { |
1243 | struct task_struct *curr = current; | ||
1244 | unsigned long this_load, load; | 1234 | unsigned long this_load, load; |
1245 | int idx, this_cpu, prev_cpu; | 1235 | int idx, this_cpu, prev_cpu; |
1246 | unsigned long tl_per_task; | 1236 | unsigned long tl_per_task; |
@@ -1255,18 +1245,6 @@ static int wake_affine(struct sched_domain *sd, struct task_struct *p, int sync) | |||
1255 | load = source_load(prev_cpu, idx); | 1245 | load = source_load(prev_cpu, idx); |
1256 | this_load = target_load(this_cpu, idx); | 1246 | this_load = target_load(this_cpu, idx); |
1257 | 1247 | ||
1258 | if (sync) { | ||
1259 | if (sched_feat(SYNC_LESS) && | ||
1260 | (curr->se.avg_overlap > sysctl_sched_migration_cost || | ||
1261 | p->se.avg_overlap > sysctl_sched_migration_cost)) | ||
1262 | sync = 0; | ||
1263 | } else { | ||
1264 | if (sched_feat(SYNC_MORE) && | ||
1265 | (curr->se.avg_overlap < sysctl_sched_migration_cost && | ||
1266 | p->se.avg_overlap < sysctl_sched_migration_cost)) | ||
1267 | sync = 1; | ||
1268 | } | ||
1269 | |||
1270 | /* | 1248 | /* |
1271 | * If sync wakeup then subtract the (maximum possible) | 1249 | * If sync wakeup then subtract the (maximum possible) |
1272 | * effect of the currently running task from the load | 1250 | * effect of the currently running task from the load |
@@ -1306,7 +1284,7 @@ static int wake_affine(struct sched_domain *sd, struct task_struct *p, int sync) | |||
1306 | if (sync && balanced) | 1284 | if (sync && balanced) |
1307 | return 1; | 1285 | return 1; |
1308 | 1286 | ||
1309 | schedstat_inc(p, se.nr_wakeups_affine_attempts); | 1287 | schedstat_inc(p, se.statistics.nr_wakeups_affine_attempts); |
1310 | tl_per_task = cpu_avg_load_per_task(this_cpu); | 1288 | tl_per_task = cpu_avg_load_per_task(this_cpu); |
1311 | 1289 | ||
1312 | if (balanced || | 1290 | if (balanced || |
@@ -1318,7 +1296,7 @@ static int wake_affine(struct sched_domain *sd, struct task_struct *p, int sync) | |||
1318 | * there is no bad imbalance. | 1296 | * there is no bad imbalance. |
1319 | */ | 1297 | */ |
1320 | schedstat_inc(sd, ttwu_move_affine); | 1298 | schedstat_inc(sd, ttwu_move_affine); |
1321 | schedstat_inc(p, se.nr_wakeups_affine); | 1299 | schedstat_inc(p, se.statistics.nr_wakeups_affine); |
1322 | 1300 | ||
1323 | return 1; | 1301 | return 1; |
1324 | } | 1302 | } |
@@ -1451,13 +1429,12 @@ static int select_task_rq_fair(struct task_struct *p, int sd_flag, int wake_flag | |||
1451 | int cpu = smp_processor_id(); | 1429 | int cpu = smp_processor_id(); |
1452 | int prev_cpu = task_cpu(p); | 1430 | int prev_cpu = task_cpu(p); |
1453 | int new_cpu = cpu; | 1431 | int new_cpu = cpu; |
1454 | int want_affine = 0; | 1432 | int want_affine = 0, cpu_idle = !current->pid; |
1455 | int want_sd = 1; | 1433 | int want_sd = 1; |
1456 | int sync = wake_flags & WF_SYNC; | 1434 | int sync = wake_flags & WF_SYNC; |
1457 | 1435 | ||
1458 | if (sd_flag & SD_BALANCE_WAKE) { | 1436 | if (sd_flag & SD_BALANCE_WAKE) { |
1459 | if (sched_feat(AFFINE_WAKEUPS) && | 1437 | if (cpumask_test_cpu(cpu, &p->cpus_allowed)) |
1460 | cpumask_test_cpu(cpu, &p->cpus_allowed)) | ||
1461 | want_affine = 1; | 1438 | want_affine = 1; |
1462 | new_cpu = prev_cpu; | 1439 | new_cpu = prev_cpu; |
1463 | } | 1440 | } |
@@ -1509,13 +1486,15 @@ static int select_task_rq_fair(struct task_struct *p, int sd_flag, int wake_flag | |||
1509 | * If there's an idle sibling in this domain, make that | 1486 | * If there's an idle sibling in this domain, make that |
1510 | * the wake_affine target instead of the current cpu. | 1487 | * the wake_affine target instead of the current cpu. |
1511 | */ | 1488 | */ |
1512 | if (tmp->flags & SD_SHARE_PKG_RESOURCES) | 1489 | if (!cpu_idle && tmp->flags & SD_SHARE_PKG_RESOURCES) |
1513 | target = select_idle_sibling(p, tmp, target); | 1490 | target = select_idle_sibling(p, tmp, target); |
1514 | 1491 | ||
1515 | if (target >= 0) { | 1492 | if (target >= 0) { |
1516 | if (tmp->flags & SD_WAKE_AFFINE) { | 1493 | if (tmp->flags & SD_WAKE_AFFINE) { |
1517 | affine_sd = tmp; | 1494 | affine_sd = tmp; |
1518 | want_affine = 0; | 1495 | want_affine = 0; |
1496 | if (target != cpu) | ||
1497 | cpu_idle = 1; | ||
1519 | } | 1498 | } |
1520 | cpu = target; | 1499 | cpu = target; |
1521 | } | 1500 | } |
@@ -1531,6 +1510,7 @@ static int select_task_rq_fair(struct task_struct *p, int sd_flag, int wake_flag | |||
1531 | sd = tmp; | 1510 | sd = tmp; |
1532 | } | 1511 | } |
1533 | 1512 | ||
1513 | #ifdef CONFIG_FAIR_GROUP_SCHED | ||
1534 | if (sched_feat(LB_SHARES_UPDATE)) { | 1514 | if (sched_feat(LB_SHARES_UPDATE)) { |
1535 | /* | 1515 | /* |
1536 | * Pick the largest domain to update shares over | 1516 | * Pick the largest domain to update shares over |
@@ -1544,9 +1524,12 @@ static int select_task_rq_fair(struct task_struct *p, int sd_flag, int wake_flag | |||
1544 | if (tmp) | 1524 | if (tmp) |
1545 | update_shares(tmp); | 1525 | update_shares(tmp); |
1546 | } | 1526 | } |
1527 | #endif | ||
1547 | 1528 | ||
1548 | if (affine_sd && wake_affine(affine_sd, p, sync)) | 1529 | if (affine_sd) { |
1549 | return cpu; | 1530 | if (cpu_idle || cpu == prev_cpu || wake_affine(affine_sd, p, sync)) |
1531 | return cpu; | ||
1532 | } | ||
1550 | 1533 | ||
1551 | while (sd) { | 1534 | while (sd) { |
1552 | int load_idx = sd->forkexec_idx; | 1535 | int load_idx = sd->forkexec_idx; |
@@ -1591,63 +1574,26 @@ static int select_task_rq_fair(struct task_struct *p, int sd_flag, int wake_flag | |||
1591 | } | 1574 | } |
1592 | #endif /* CONFIG_SMP */ | 1575 | #endif /* CONFIG_SMP */ |
1593 | 1576 | ||
1594 | /* | ||
1595 | * Adaptive granularity | ||
1596 | * | ||
1597 | * se->avg_wakeup gives the average time a task runs until it does a wakeup, | ||
1598 | * with the limit of wakeup_gran -- when it never does a wakeup. | ||
1599 | * | ||
1600 | * So the smaller avg_wakeup is the faster we want this task to preempt, | ||
1601 | * but we don't want to treat the preemptee unfairly and therefore allow it | ||
1602 | * to run for at least the amount of time we'd like to run. | ||
1603 | * | ||
1604 | * NOTE: we use 2*avg_wakeup to increase the probability of actually doing one | ||
1605 | * | ||
1606 | * NOTE: we use *nr_running to scale with load, this nicely matches the | ||
1607 | * degrading latency on load. | ||
1608 | */ | ||
1609 | static unsigned long | ||
1610 | adaptive_gran(struct sched_entity *curr, struct sched_entity *se) | ||
1611 | { | ||
1612 | u64 this_run = curr->sum_exec_runtime - curr->prev_sum_exec_runtime; | ||
1613 | u64 expected_wakeup = 2*se->avg_wakeup * cfs_rq_of(se)->nr_running; | ||
1614 | u64 gran = 0; | ||
1615 | |||
1616 | if (this_run < expected_wakeup) | ||
1617 | gran = expected_wakeup - this_run; | ||
1618 | |||
1619 | return min_t(s64, gran, sysctl_sched_wakeup_granularity); | ||
1620 | } | ||
1621 | |||
1622 | static unsigned long | 1577 | static unsigned long |
1623 | wakeup_gran(struct sched_entity *curr, struct sched_entity *se) | 1578 | wakeup_gran(struct sched_entity *curr, struct sched_entity *se) |
1624 | { | 1579 | { |
1625 | unsigned long gran = sysctl_sched_wakeup_granularity; | 1580 | unsigned long gran = sysctl_sched_wakeup_granularity; |
1626 | 1581 | ||
1627 | if (cfs_rq_of(curr)->curr && sched_feat(ADAPTIVE_GRAN)) | ||
1628 | gran = adaptive_gran(curr, se); | ||
1629 | |||
1630 | /* | 1582 | /* |
1631 | * Since its curr running now, convert the gran from real-time | 1583 | * Since its curr running now, convert the gran from real-time |
1632 | * to virtual-time in his units. | 1584 | * to virtual-time in his units. |
1585 | * | ||
1586 | * By using 'se' instead of 'curr' we penalize light tasks, so | ||
1587 | * they get preempted easier. That is, if 'se' < 'curr' then | ||
1588 | * the resulting gran will be larger, therefore penalizing the | ||
1589 | * lighter, if otoh 'se' > 'curr' then the resulting gran will | ||
1590 | * be smaller, again penalizing the lighter task. | ||
1591 | * | ||
1592 | * This is especially important for buddies when the leftmost | ||
1593 | * task is higher priority than the buddy. | ||
1633 | */ | 1594 | */ |
1634 | if (sched_feat(ASYM_GRAN)) { | 1595 | if (unlikely(se->load.weight != NICE_0_LOAD)) |
1635 | /* | 1596 | gran = calc_delta_fair(gran, se); |
1636 | * By using 'se' instead of 'curr' we penalize light tasks, so | ||
1637 | * they get preempted easier. That is, if 'se' < 'curr' then | ||
1638 | * the resulting gran will be larger, therefore penalizing the | ||
1639 | * lighter, if otoh 'se' > 'curr' then the resulting gran will | ||
1640 | * be smaller, again penalizing the lighter task. | ||
1641 | * | ||
1642 | * This is especially important for buddies when the leftmost | ||
1643 | * task is higher priority than the buddy. | ||
1644 | */ | ||
1645 | if (unlikely(se->load.weight != NICE_0_LOAD)) | ||
1646 | gran = calc_delta_fair(gran, se); | ||
1647 | } else { | ||
1648 | if (unlikely(curr->load.weight != NICE_0_LOAD)) | ||
1649 | gran = calc_delta_fair(gran, curr); | ||
1650 | } | ||
1651 | 1597 | ||
1652 | return gran; | 1598 | return gran; |
1653 | } | 1599 | } |
@@ -1705,7 +1651,6 @@ static void check_preempt_wakeup(struct rq *rq, struct task_struct *p, int wake_ | |||
1705 | struct task_struct *curr = rq->curr; | 1651 | struct task_struct *curr = rq->curr; |
1706 | struct sched_entity *se = &curr->se, *pse = &p->se; | 1652 | struct sched_entity *se = &curr->se, *pse = &p->se; |
1707 | struct cfs_rq *cfs_rq = task_cfs_rq(curr); | 1653 | struct cfs_rq *cfs_rq = task_cfs_rq(curr); |
1708 | int sync = wake_flags & WF_SYNC; | ||
1709 | int scale = cfs_rq->nr_running >= sched_nr_latency; | 1654 | int scale = cfs_rq->nr_running >= sched_nr_latency; |
1710 | 1655 | ||
1711 | if (unlikely(rt_prio(p->prio))) | 1656 | if (unlikely(rt_prio(p->prio))) |
@@ -1738,14 +1683,6 @@ static void check_preempt_wakeup(struct rq *rq, struct task_struct *p, int wake_ | |||
1738 | if (unlikely(curr->policy == SCHED_IDLE)) | 1683 | if (unlikely(curr->policy == SCHED_IDLE)) |
1739 | goto preempt; | 1684 | goto preempt; |
1740 | 1685 | ||
1741 | if (sched_feat(WAKEUP_SYNC) && sync) | ||
1742 | goto preempt; | ||
1743 | |||
1744 | if (sched_feat(WAKEUP_OVERLAP) && | ||
1745 | se->avg_overlap < sysctl_sched_migration_cost && | ||
1746 | pse->avg_overlap < sysctl_sched_migration_cost) | ||
1747 | goto preempt; | ||
1748 | |||
1749 | if (!sched_feat(WAKEUP_PREEMPT)) | 1686 | if (!sched_feat(WAKEUP_PREEMPT)) |
1750 | return; | 1687 | return; |
1751 | 1688 | ||
@@ -1844,13 +1781,13 @@ int can_migrate_task(struct task_struct *p, struct rq *rq, int this_cpu, | |||
1844 | * 3) are cache-hot on their current CPU. | 1781 | * 3) are cache-hot on their current CPU. |
1845 | */ | 1782 | */ |
1846 | if (!cpumask_test_cpu(this_cpu, &p->cpus_allowed)) { | 1783 | if (!cpumask_test_cpu(this_cpu, &p->cpus_allowed)) { |
1847 | schedstat_inc(p, se.nr_failed_migrations_affine); | 1784 | schedstat_inc(p, se.statistics.nr_failed_migrations_affine); |
1848 | return 0; | 1785 | return 0; |
1849 | } | 1786 | } |
1850 | *all_pinned = 0; | 1787 | *all_pinned = 0; |
1851 | 1788 | ||
1852 | if (task_running(rq, p)) { | 1789 | if (task_running(rq, p)) { |
1853 | schedstat_inc(p, se.nr_failed_migrations_running); | 1790 | schedstat_inc(p, se.statistics.nr_failed_migrations_running); |
1854 | return 0; | 1791 | return 0; |
1855 | } | 1792 | } |
1856 | 1793 | ||
@@ -1866,14 +1803,14 @@ int can_migrate_task(struct task_struct *p, struct rq *rq, int this_cpu, | |||
1866 | #ifdef CONFIG_SCHEDSTATS | 1803 | #ifdef CONFIG_SCHEDSTATS |
1867 | if (tsk_cache_hot) { | 1804 | if (tsk_cache_hot) { |
1868 | schedstat_inc(sd, lb_hot_gained[idle]); | 1805 | schedstat_inc(sd, lb_hot_gained[idle]); |
1869 | schedstat_inc(p, se.nr_forced_migrations); | 1806 | schedstat_inc(p, se.statistics.nr_forced_migrations); |
1870 | } | 1807 | } |
1871 | #endif | 1808 | #endif |
1872 | return 1; | 1809 | return 1; |
1873 | } | 1810 | } |
1874 | 1811 | ||
1875 | if (tsk_cache_hot) { | 1812 | if (tsk_cache_hot) { |
1876 | schedstat_inc(p, se.nr_failed_migrations_hot); | 1813 | schedstat_inc(p, se.statistics.nr_failed_migrations_hot); |
1877 | return 0; | 1814 | return 0; |
1878 | } | 1815 | } |
1879 | return 1; | 1816 | return 1; |
@@ -3112,8 +3049,6 @@ static void active_load_balance(struct rq *busiest_rq, int busiest_cpu) | |||
3112 | 3049 | ||
3113 | /* move a task from busiest_rq to target_rq */ | 3050 | /* move a task from busiest_rq to target_rq */ |
3114 | double_lock_balance(busiest_rq, target_rq); | 3051 | double_lock_balance(busiest_rq, target_rq); |
3115 | update_rq_clock(busiest_rq); | ||
3116 | update_rq_clock(target_rq); | ||
3117 | 3052 | ||
3118 | /* Search for an sd spanning us and the target CPU. */ | 3053 | /* Search for an sd spanning us and the target CPU. */ |
3119 | for_each_domain(target_cpu, sd) { | 3054 | for_each_domain(target_cpu, sd) { |
diff --git a/kernel/sched_features.h b/kernel/sched_features.h index d5059fd761d9..83c66e8ad3ee 100644 --- a/kernel/sched_features.h +++ b/kernel/sched_features.h | |||
@@ -1,11 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * Disregards a certain amount of sleep time (sched_latency_ns) and | ||
3 | * considers the task to be running during that period. This gives it | ||
4 | * a service deficit on wakeup, allowing it to run sooner. | ||
5 | */ | ||
6 | SCHED_FEAT(FAIR_SLEEPERS, 1) | ||
7 | |||
8 | /* | ||
9 | * Only give sleepers 50% of their service deficit. This allows | 2 | * Only give sleepers 50% of their service deficit. This allows |
10 | * them to run sooner, but does not allow tons of sleepers to | 3 | * them to run sooner, but does not allow tons of sleepers to |
11 | * rip the spread apart. | 4 | * rip the spread apart. |
@@ -13,13 +6,6 @@ SCHED_FEAT(FAIR_SLEEPERS, 1) | |||
13 | SCHED_FEAT(GENTLE_FAIR_SLEEPERS, 1) | 6 | SCHED_FEAT(GENTLE_FAIR_SLEEPERS, 1) |
14 | 7 | ||
15 | /* | 8 | /* |
16 | * By not normalizing the sleep time, heavy tasks get an effective | ||
17 | * longer period, and lighter task an effective shorter period they | ||
18 | * are considered running. | ||
19 | */ | ||
20 | SCHED_FEAT(NORMALIZED_SLEEPER, 0) | ||
21 | |||
22 | /* | ||
23 | * Place new tasks ahead so that they do not starve already running | 9 | * Place new tasks ahead so that they do not starve already running |
24 | * tasks | 10 | * tasks |
25 | */ | 11 | */ |
@@ -31,37 +17,6 @@ SCHED_FEAT(START_DEBIT, 1) | |||
31 | SCHED_FEAT(WAKEUP_PREEMPT, 1) | 17 | SCHED_FEAT(WAKEUP_PREEMPT, 1) |
32 | 18 | ||
33 | /* | 19 | /* |
34 | * Compute wakeup_gran based on task behaviour, clipped to | ||
35 | * [0, sched_wakeup_gran_ns] | ||
36 | */ | ||
37 | SCHED_FEAT(ADAPTIVE_GRAN, 1) | ||
38 | |||
39 | /* | ||
40 | * When converting the wakeup granularity to virtual time, do it such | ||
41 | * that heavier tasks preempting a lighter task have an edge. | ||
42 | */ | ||
43 | SCHED_FEAT(ASYM_GRAN, 1) | ||
44 | |||
45 | /* | ||
46 | * Always wakeup-preempt SYNC wakeups, see SYNC_WAKEUPS. | ||
47 | */ | ||
48 | SCHED_FEAT(WAKEUP_SYNC, 0) | ||
49 | |||
50 | /* | ||
51 | * Wakeup preempt based on task behaviour. Tasks that do not overlap | ||
52 | * don't get preempted. | ||
53 | */ | ||
54 | SCHED_FEAT(WAKEUP_OVERLAP, 0) | ||
55 | |||
56 | /* | ||
57 | * Use the SYNC wakeup hint, pipes and the likes use this to indicate | ||
58 | * the remote end is likely to consume the data we just wrote, and | ||
59 | * therefore has cache benefit from being placed on the same cpu, see | ||
60 | * also AFFINE_WAKEUPS. | ||
61 | */ | ||
62 | SCHED_FEAT(SYNC_WAKEUPS, 1) | ||
63 | |||
64 | /* | ||
65 | * Based on load and program behaviour, see if it makes sense to place | 20 | * Based on load and program behaviour, see if it makes sense to place |
66 | * a newly woken task on the same cpu as the task that woke it -- | 21 | * a newly woken task on the same cpu as the task that woke it -- |
67 | * improve cache locality. Typically used with SYNC wakeups as | 22 | * improve cache locality. Typically used with SYNC wakeups as |
@@ -70,16 +25,6 @@ SCHED_FEAT(SYNC_WAKEUPS, 1) | |||
70 | SCHED_FEAT(AFFINE_WAKEUPS, 1) | 25 | SCHED_FEAT(AFFINE_WAKEUPS, 1) |
71 | 26 | ||
72 | /* | 27 | /* |
73 | * Weaken SYNC hint based on overlap | ||
74 | */ | ||
75 | SCHED_FEAT(SYNC_LESS, 1) | ||
76 | |||
77 | /* | ||
78 | * Add SYNC hint based on overlap | ||
79 | */ | ||
80 | SCHED_FEAT(SYNC_MORE, 0) | ||
81 | |||
82 | /* | ||
83 | * Prefer to schedule the task we woke last (assuming it failed | 28 | * Prefer to schedule the task we woke last (assuming it failed |
84 | * wakeup-preemption), since its likely going to consume data we | 29 | * wakeup-preemption), since its likely going to consume data we |
85 | * touched, increases cache locality. | 30 | * touched, increases cache locality. |
diff --git a/kernel/sched_rt.c b/kernel/sched_rt.c index b5b920ae2ea7..012d69bb67c7 100644 --- a/kernel/sched_rt.c +++ b/kernel/sched_rt.c | |||
@@ -613,7 +613,7 @@ static void update_curr_rt(struct rq *rq) | |||
613 | if (unlikely((s64)delta_exec < 0)) | 613 | if (unlikely((s64)delta_exec < 0)) |
614 | delta_exec = 0; | 614 | delta_exec = 0; |
615 | 615 | ||
616 | schedstat_set(curr->se.exec_max, max(curr->se.exec_max, delta_exec)); | 616 | schedstat_set(curr->se.statistics.exec_max, max(curr->se.statistics.exec_max, delta_exec)); |
617 | 617 | ||
618 | curr->se.sum_exec_runtime += delta_exec; | 618 | curr->se.sum_exec_runtime += delta_exec; |
619 | account_group_exec_runtime(curr, delta_exec); | 619 | account_group_exec_runtime(curr, delta_exec); |
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index f992762d7f51..f25735a767af 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c | |||
@@ -262,6 +262,9 @@ void tick_nohz_stop_sched_tick(int inidle) | |||
262 | goto end; | 262 | goto end; |
263 | } | 263 | } |
264 | 264 | ||
265 | if (nohz_ratelimit(cpu)) | ||
266 | goto end; | ||
267 | |||
265 | ts->idle_calls++; | 268 | ts->idle_calls++; |
266 | /* Read jiffies and the time when jiffies were updated last */ | 269 | /* Read jiffies and the time when jiffies were updated last */ |
267 | do { | 270 | do { |
diff --git a/kernel/user.c b/kernel/user.c index 766467b3bcb7..ec3b2229893b 100644 --- a/kernel/user.c +++ b/kernel/user.c | |||
@@ -178,8 +178,6 @@ struct user_struct *alloc_uid(struct user_namespace *ns, uid_t uid) | |||
178 | 178 | ||
179 | return up; | 179 | return up; |
180 | 180 | ||
181 | put_user_ns(new->user_ns); | ||
182 | kmem_cache_free(uid_cachep, new); | ||
183 | out_unlock: | 181 | out_unlock: |
184 | return NULL; | 182 | return NULL; |
185 | } | 183 | } |