diff options
Diffstat (limited to 'kernel/sched')
-rw-r--r-- | kernel/sched/core.c | 75 | ||||
-rw-r--r-- | kernel/sched/cpudeadline.c | 28 | ||||
-rw-r--r-- | kernel/sched/cpudeadline.h | 2 | ||||
-rw-r--r-- | kernel/sched/deadline.c | 5 | ||||
-rw-r--r-- | kernel/sched/debug.c | 1 | ||||
-rw-r--r-- | kernel/sched/fair.c | 7 | ||||
-rw-r--r-- | kernel/sched/idle.c | 3 | ||||
-rw-r--r-- | kernel/sched/rt.c | 26 | ||||
-rw-r--r-- | kernel/sched/sched.h | 22 |
9 files changed, 118 insertions, 51 deletions
diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 9e838095beb8..50a5352f6205 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c | |||
@@ -119,7 +119,9 @@ void update_rq_clock(struct rq *rq) | |||
119 | { | 119 | { |
120 | s64 delta; | 120 | s64 delta; |
121 | 121 | ||
122 | if (rq->skip_clock_update > 0) | 122 | lockdep_assert_held(&rq->lock); |
123 | |||
124 | if (rq->clock_skip_update & RQCF_ACT_SKIP) | ||
123 | return; | 125 | return; |
124 | 126 | ||
125 | delta = sched_clock_cpu(cpu_of(rq)) - rq->clock; | 127 | delta = sched_clock_cpu(cpu_of(rq)) - rq->clock; |
@@ -1046,7 +1048,7 @@ void check_preempt_curr(struct rq *rq, struct task_struct *p, int flags) | |||
1046 | * this case, we can save a useless back to back clock update. | 1048 | * this case, we can save a useless back to back clock update. |
1047 | */ | 1049 | */ |
1048 | if (task_on_rq_queued(rq->curr) && test_tsk_need_resched(rq->curr)) | 1050 | if (task_on_rq_queued(rq->curr) && test_tsk_need_resched(rq->curr)) |
1049 | rq->skip_clock_update = 1; | 1051 | rq_clock_skip_update(rq, true); |
1050 | } | 1052 | } |
1051 | 1053 | ||
1052 | #ifdef CONFIG_SMP | 1054 | #ifdef CONFIG_SMP |
@@ -1836,6 +1838,9 @@ static void __sched_fork(unsigned long clone_flags, struct task_struct *p) | |||
1836 | p->se.prev_sum_exec_runtime = 0; | 1838 | p->se.prev_sum_exec_runtime = 0; |
1837 | p->se.nr_migrations = 0; | 1839 | p->se.nr_migrations = 0; |
1838 | p->se.vruntime = 0; | 1840 | p->se.vruntime = 0; |
1841 | #ifdef CONFIG_SMP | ||
1842 | p->se.avg.decay_count = 0; | ||
1843 | #endif | ||
1839 | INIT_LIST_HEAD(&p->se.group_node); | 1844 | INIT_LIST_HEAD(&p->se.group_node); |
1840 | 1845 | ||
1841 | #ifdef CONFIG_SCHEDSTATS | 1846 | #ifdef CONFIG_SCHEDSTATS |
@@ -2783,6 +2788,8 @@ need_resched: | |||
2783 | smp_mb__before_spinlock(); | 2788 | smp_mb__before_spinlock(); |
2784 | raw_spin_lock_irq(&rq->lock); | 2789 | raw_spin_lock_irq(&rq->lock); |
2785 | 2790 | ||
2791 | rq->clock_skip_update <<= 1; /* promote REQ to ACT */ | ||
2792 | |||
2786 | switch_count = &prev->nivcsw; | 2793 | switch_count = &prev->nivcsw; |
2787 | if (prev->state && !(preempt_count() & PREEMPT_ACTIVE)) { | 2794 | if (prev->state && !(preempt_count() & PREEMPT_ACTIVE)) { |
2788 | if (unlikely(signal_pending_state(prev->state, prev))) { | 2795 | if (unlikely(signal_pending_state(prev->state, prev))) { |
@@ -2807,13 +2814,13 @@ need_resched: | |||
2807 | switch_count = &prev->nvcsw; | 2814 | switch_count = &prev->nvcsw; |
2808 | } | 2815 | } |
2809 | 2816 | ||
2810 | if (task_on_rq_queued(prev) || rq->skip_clock_update < 0) | 2817 | if (task_on_rq_queued(prev)) |
2811 | update_rq_clock(rq); | 2818 | update_rq_clock(rq); |
2812 | 2819 | ||
2813 | next = pick_next_task(rq, prev); | 2820 | next = pick_next_task(rq, prev); |
2814 | clear_tsk_need_resched(prev); | 2821 | clear_tsk_need_resched(prev); |
2815 | clear_preempt_need_resched(); | 2822 | clear_preempt_need_resched(); |
2816 | rq->skip_clock_update = 0; | 2823 | rq->clock_skip_update = 0; |
2817 | 2824 | ||
2818 | if (likely(prev != next)) { | 2825 | if (likely(prev != next)) { |
2819 | rq->nr_switches++; | 2826 | rq->nr_switches++; |
@@ -2884,6 +2891,21 @@ void __sched schedule_preempt_disabled(void) | |||
2884 | preempt_disable(); | 2891 | preempt_disable(); |
2885 | } | 2892 | } |
2886 | 2893 | ||
2894 | static void preempt_schedule_common(void) | ||
2895 | { | ||
2896 | do { | ||
2897 | __preempt_count_add(PREEMPT_ACTIVE); | ||
2898 | __schedule(); | ||
2899 | __preempt_count_sub(PREEMPT_ACTIVE); | ||
2900 | |||
2901 | /* | ||
2902 | * Check again in case we missed a preemption opportunity | ||
2903 | * between schedule and now. | ||
2904 | */ | ||
2905 | barrier(); | ||
2906 | } while (need_resched()); | ||
2907 | } | ||
2908 | |||
2887 | #ifdef CONFIG_PREEMPT | 2909 | #ifdef CONFIG_PREEMPT |
2888 | /* | 2910 | /* |
2889 | * this is the entry point to schedule() from in-kernel preemption | 2911 | * this is the entry point to schedule() from in-kernel preemption |
@@ -2899,17 +2921,7 @@ asmlinkage __visible void __sched notrace preempt_schedule(void) | |||
2899 | if (likely(!preemptible())) | 2921 | if (likely(!preemptible())) |
2900 | return; | 2922 | return; |
2901 | 2923 | ||
2902 | do { | 2924 | preempt_schedule_common(); |
2903 | __preempt_count_add(PREEMPT_ACTIVE); | ||
2904 | __schedule(); | ||
2905 | __preempt_count_sub(PREEMPT_ACTIVE); | ||
2906 | |||
2907 | /* | ||
2908 | * Check again in case we missed a preemption opportunity | ||
2909 | * between schedule and now. | ||
2910 | */ | ||
2911 | barrier(); | ||
2912 | } while (need_resched()); | ||
2913 | } | 2925 | } |
2914 | NOKPROBE_SYMBOL(preempt_schedule); | 2926 | NOKPROBE_SYMBOL(preempt_schedule); |
2915 | EXPORT_SYMBOL(preempt_schedule); | 2927 | EXPORT_SYMBOL(preempt_schedule); |
@@ -4225,17 +4237,10 @@ SYSCALL_DEFINE0(sched_yield) | |||
4225 | return 0; | 4237 | return 0; |
4226 | } | 4238 | } |
4227 | 4239 | ||
4228 | static void __cond_resched(void) | ||
4229 | { | ||
4230 | __preempt_count_add(PREEMPT_ACTIVE); | ||
4231 | __schedule(); | ||
4232 | __preempt_count_sub(PREEMPT_ACTIVE); | ||
4233 | } | ||
4234 | |||
4235 | int __sched _cond_resched(void) | 4240 | int __sched _cond_resched(void) |
4236 | { | 4241 | { |
4237 | if (should_resched()) { | 4242 | if (should_resched()) { |
4238 | __cond_resched(); | 4243 | preempt_schedule_common(); |
4239 | return 1; | 4244 | return 1; |
4240 | } | 4245 | } |
4241 | return 0; | 4246 | return 0; |
@@ -4260,7 +4265,7 @@ int __cond_resched_lock(spinlock_t *lock) | |||
4260 | if (spin_needbreak(lock) || resched) { | 4265 | if (spin_needbreak(lock) || resched) { |
4261 | spin_unlock(lock); | 4266 | spin_unlock(lock); |
4262 | if (resched) | 4267 | if (resched) |
4263 | __cond_resched(); | 4268 | preempt_schedule_common(); |
4264 | else | 4269 | else |
4265 | cpu_relax(); | 4270 | cpu_relax(); |
4266 | ret = 1; | 4271 | ret = 1; |
@@ -4276,7 +4281,7 @@ int __sched __cond_resched_softirq(void) | |||
4276 | 4281 | ||
4277 | if (should_resched()) { | 4282 | if (should_resched()) { |
4278 | local_bh_enable(); | 4283 | local_bh_enable(); |
4279 | __cond_resched(); | 4284 | preempt_schedule_common(); |
4280 | local_bh_disable(); | 4285 | local_bh_disable(); |
4281 | return 1; | 4286 | return 1; |
4282 | } | 4287 | } |
@@ -4531,9 +4536,10 @@ void sched_show_task(struct task_struct *p) | |||
4531 | { | 4536 | { |
4532 | unsigned long free = 0; | 4537 | unsigned long free = 0; |
4533 | int ppid; | 4538 | int ppid; |
4534 | unsigned state; | 4539 | unsigned long state = p->state; |
4535 | 4540 | ||
4536 | state = p->state ? __ffs(p->state) + 1 : 0; | 4541 | if (state) |
4542 | state = __ffs(state) + 1; | ||
4537 | printk(KERN_INFO "%-15.15s %c", p->comm, | 4543 | printk(KERN_INFO "%-15.15s %c", p->comm, |
4538 | state < sizeof(stat_nam) - 1 ? stat_nam[state] : '?'); | 4544 | state < sizeof(stat_nam) - 1 ? stat_nam[state] : '?'); |
4539 | #if BITS_PER_LONG == 32 | 4545 | #if BITS_PER_LONG == 32 |
@@ -4766,7 +4772,7 @@ static struct rq *move_queued_task(struct task_struct *p, int new_cpu) | |||
4766 | 4772 | ||
4767 | void do_set_cpus_allowed(struct task_struct *p, const struct cpumask *new_mask) | 4773 | void do_set_cpus_allowed(struct task_struct *p, const struct cpumask *new_mask) |
4768 | { | 4774 | { |
4769 | if (p->sched_class && p->sched_class->set_cpus_allowed) | 4775 | if (p->sched_class->set_cpus_allowed) |
4770 | p->sched_class->set_cpus_allowed(p, new_mask); | 4776 | p->sched_class->set_cpus_allowed(p, new_mask); |
4771 | 4777 | ||
4772 | cpumask_copy(&p->cpus_allowed, new_mask); | 4778 | cpumask_copy(&p->cpus_allowed, new_mask); |
@@ -7276,6 +7282,11 @@ void __init sched_init(void) | |||
7276 | enter_lazy_tlb(&init_mm, current); | 7282 | enter_lazy_tlb(&init_mm, current); |
7277 | 7283 | ||
7278 | /* | 7284 | /* |
7285 | * During early bootup we pretend to be a normal task: | ||
7286 | */ | ||
7287 | current->sched_class = &fair_sched_class; | ||
7288 | |||
7289 | /* | ||
7279 | * Make us the idle thread. Technically, schedule() should not be | 7290 | * Make us the idle thread. Technically, schedule() should not be |
7280 | * called from this thread, however somewhere below it might be, | 7291 | * called from this thread, however somewhere below it might be, |
7281 | * but because we are the idle thread, we just pick up running again | 7292 | * but because we are the idle thread, we just pick up running again |
@@ -7285,11 +7296,6 @@ void __init sched_init(void) | |||
7285 | 7296 | ||
7286 | calc_load_update = jiffies + LOAD_FREQ; | 7297 | calc_load_update = jiffies + LOAD_FREQ; |
7287 | 7298 | ||
7288 | /* | ||
7289 | * During early bootup we pretend to be a normal task: | ||
7290 | */ | ||
7291 | current->sched_class = &fair_sched_class; | ||
7292 | |||
7293 | #ifdef CONFIG_SMP | 7299 | #ifdef CONFIG_SMP |
7294 | zalloc_cpumask_var(&sched_domains_tmpmask, GFP_NOWAIT); | 7300 | zalloc_cpumask_var(&sched_domains_tmpmask, GFP_NOWAIT); |
7295 | /* May be allocated at isolcpus cmdline parse time */ | 7301 | /* May be allocated at isolcpus cmdline parse time */ |
@@ -7351,6 +7357,9 @@ void ___might_sleep(const char *file, int line, int preempt_offset) | |||
7351 | in_atomic(), irqs_disabled(), | 7357 | in_atomic(), irqs_disabled(), |
7352 | current->pid, current->comm); | 7358 | current->pid, current->comm); |
7353 | 7359 | ||
7360 | if (task_stack_end_corrupted(current)) | ||
7361 | printk(KERN_EMERG "Thread overran stack, or stack corrupted\n"); | ||
7362 | |||
7354 | debug_show_held_locks(current); | 7363 | debug_show_held_locks(current); |
7355 | if (irqs_disabled()) | 7364 | if (irqs_disabled()) |
7356 | print_irqtrace_events(current); | 7365 | print_irqtrace_events(current); |
diff --git a/kernel/sched/cpudeadline.c b/kernel/sched/cpudeadline.c index 539ca3ce071b..fd9d3fb49d0d 100644 --- a/kernel/sched/cpudeadline.c +++ b/kernel/sched/cpudeadline.c | |||
@@ -107,7 +107,9 @@ int cpudl_find(struct cpudl *cp, struct task_struct *p, | |||
107 | int best_cpu = -1; | 107 | int best_cpu = -1; |
108 | const struct sched_dl_entity *dl_se = &p->dl; | 108 | const struct sched_dl_entity *dl_se = &p->dl; |
109 | 109 | ||
110 | if (later_mask && cpumask_and(later_mask, later_mask, cp->free_cpus)) { | 110 | if (later_mask && |
111 | cpumask_and(later_mask, cp->free_cpus, &p->cpus_allowed) && | ||
112 | cpumask_and(later_mask, later_mask, cpu_active_mask)) { | ||
111 | best_cpu = cpumask_any(later_mask); | 113 | best_cpu = cpumask_any(later_mask); |
112 | goto out; | 114 | goto out; |
113 | } else if (cpumask_test_cpu(cpudl_maximum(cp), &p->cpus_allowed) && | 115 | } else if (cpumask_test_cpu(cpudl_maximum(cp), &p->cpus_allowed) && |
@@ -186,6 +188,26 @@ out: | |||
186 | } | 188 | } |
187 | 189 | ||
188 | /* | 190 | /* |
191 | * cpudl_set_freecpu - Set the cpudl.free_cpus | ||
192 | * @cp: the cpudl max-heap context | ||
193 | * @cpu: rd attached cpu | ||
194 | */ | ||
195 | void cpudl_set_freecpu(struct cpudl *cp, int cpu) | ||
196 | { | ||
197 | cpumask_set_cpu(cpu, cp->free_cpus); | ||
198 | } | ||
199 | |||
200 | /* | ||
201 | * cpudl_clear_freecpu - Clear the cpudl.free_cpus | ||
202 | * @cp: the cpudl max-heap context | ||
203 | * @cpu: rd attached cpu | ||
204 | */ | ||
205 | void cpudl_clear_freecpu(struct cpudl *cp, int cpu) | ||
206 | { | ||
207 | cpumask_clear_cpu(cpu, cp->free_cpus); | ||
208 | } | ||
209 | |||
210 | /* | ||
189 | * cpudl_init - initialize the cpudl structure | 211 | * cpudl_init - initialize the cpudl structure |
190 | * @cp: the cpudl max-heap context | 212 | * @cp: the cpudl max-heap context |
191 | */ | 213 | */ |
@@ -203,7 +225,7 @@ int cpudl_init(struct cpudl *cp) | |||
203 | if (!cp->elements) | 225 | if (!cp->elements) |
204 | return -ENOMEM; | 226 | return -ENOMEM; |
205 | 227 | ||
206 | if (!alloc_cpumask_var(&cp->free_cpus, GFP_KERNEL)) { | 228 | if (!zalloc_cpumask_var(&cp->free_cpus, GFP_KERNEL)) { |
207 | kfree(cp->elements); | 229 | kfree(cp->elements); |
208 | return -ENOMEM; | 230 | return -ENOMEM; |
209 | } | 231 | } |
@@ -211,8 +233,6 @@ int cpudl_init(struct cpudl *cp) | |||
211 | for_each_possible_cpu(i) | 233 | for_each_possible_cpu(i) |
212 | cp->elements[i].idx = IDX_INVALID; | 234 | cp->elements[i].idx = IDX_INVALID; |
213 | 235 | ||
214 | cpumask_setall(cp->free_cpus); | ||
215 | |||
216 | return 0; | 236 | return 0; |
217 | } | 237 | } |
218 | 238 | ||
diff --git a/kernel/sched/cpudeadline.h b/kernel/sched/cpudeadline.h index 020039bd1326..1a0a6ef2fbe1 100644 --- a/kernel/sched/cpudeadline.h +++ b/kernel/sched/cpudeadline.h | |||
@@ -24,6 +24,8 @@ int cpudl_find(struct cpudl *cp, struct task_struct *p, | |||
24 | struct cpumask *later_mask); | 24 | struct cpumask *later_mask); |
25 | void cpudl_set(struct cpudl *cp, int cpu, u64 dl, int is_valid); | 25 | void cpudl_set(struct cpudl *cp, int cpu, u64 dl, int is_valid); |
26 | int cpudl_init(struct cpudl *cp); | 26 | int cpudl_init(struct cpudl *cp); |
27 | void cpudl_set_freecpu(struct cpudl *cp, int cpu); | ||
28 | void cpudl_clear_freecpu(struct cpudl *cp, int cpu); | ||
27 | void cpudl_cleanup(struct cpudl *cp); | 29 | void cpudl_cleanup(struct cpudl *cp); |
28 | #endif /* CONFIG_SMP */ | 30 | #endif /* CONFIG_SMP */ |
29 | 31 | ||
diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 726470d47f87..e0e9c2986976 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c | |||
@@ -1166,9 +1166,6 @@ static int find_later_rq(struct task_struct *task) | |||
1166 | * We have to consider system topology and task affinity | 1166 | * We have to consider system topology and task affinity |
1167 | * first, then we can look for a suitable cpu. | 1167 | * first, then we can look for a suitable cpu. |
1168 | */ | 1168 | */ |
1169 | cpumask_copy(later_mask, task_rq(task)->rd->span); | ||
1170 | cpumask_and(later_mask, later_mask, cpu_active_mask); | ||
1171 | cpumask_and(later_mask, later_mask, &task->cpus_allowed); | ||
1172 | best_cpu = cpudl_find(&task_rq(task)->rd->cpudl, | 1169 | best_cpu = cpudl_find(&task_rq(task)->rd->cpudl, |
1173 | task, later_mask); | 1170 | task, later_mask); |
1174 | if (best_cpu == -1) | 1171 | if (best_cpu == -1) |
@@ -1563,6 +1560,7 @@ static void rq_online_dl(struct rq *rq) | |||
1563 | if (rq->dl.overloaded) | 1560 | if (rq->dl.overloaded) |
1564 | dl_set_overload(rq); | 1561 | dl_set_overload(rq); |
1565 | 1562 | ||
1563 | cpudl_set_freecpu(&rq->rd->cpudl, rq->cpu); | ||
1566 | if (rq->dl.dl_nr_running > 0) | 1564 | if (rq->dl.dl_nr_running > 0) |
1567 | cpudl_set(&rq->rd->cpudl, rq->cpu, rq->dl.earliest_dl.curr, 1); | 1565 | cpudl_set(&rq->rd->cpudl, rq->cpu, rq->dl.earliest_dl.curr, 1); |
1568 | } | 1566 | } |
@@ -1574,6 +1572,7 @@ static void rq_offline_dl(struct rq *rq) | |||
1574 | dl_clear_overload(rq); | 1572 | dl_clear_overload(rq); |
1575 | 1573 | ||
1576 | cpudl_set(&rq->rd->cpudl, rq->cpu, 0, 0); | 1574 | cpudl_set(&rq->rd->cpudl, rq->cpu, 0, 0); |
1575 | cpudl_clear_freecpu(&rq->rd->cpudl, rq->cpu); | ||
1577 | } | 1576 | } |
1578 | 1577 | ||
1579 | void init_sched_dl_class(void) | 1578 | void init_sched_dl_class(void) |
diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c index 92cc52001e74..8baaf858d25c 100644 --- a/kernel/sched/debug.c +++ b/kernel/sched/debug.c | |||
@@ -305,6 +305,7 @@ do { \ | |||
305 | PN(next_balance); | 305 | PN(next_balance); |
306 | SEQ_printf(m, " .%-30s: %ld\n", "curr->pid", (long)(task_pid_nr(rq->curr))); | 306 | SEQ_printf(m, " .%-30s: %ld\n", "curr->pid", (long)(task_pid_nr(rq->curr))); |
307 | PN(clock); | 307 | PN(clock); |
308 | PN(clock_task); | ||
308 | P(cpu_load[0]); | 309 | P(cpu_load[0]); |
309 | P(cpu_load[1]); | 310 | P(cpu_load[1]); |
310 | P(cpu_load[2]); | 311 | P(cpu_load[2]); |
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index fe331fc391f5..7ce18f3c097a 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c | |||
@@ -676,7 +676,6 @@ void init_task_runnable_average(struct task_struct *p) | |||
676 | { | 676 | { |
677 | u32 slice; | 677 | u32 slice; |
678 | 678 | ||
679 | p->se.avg.decay_count = 0; | ||
680 | slice = sched_slice(task_cfs_rq(p), &p->se) >> 10; | 679 | slice = sched_slice(task_cfs_rq(p), &p->se) >> 10; |
681 | p->se.avg.runnable_avg_sum = slice; | 680 | p->se.avg.runnable_avg_sum = slice; |
682 | p->se.avg.runnable_avg_period = slice; | 681 | p->se.avg.runnable_avg_period = slice; |
@@ -2574,11 +2573,11 @@ static inline u64 __synchronize_entity_decay(struct sched_entity *se) | |||
2574 | u64 decays = atomic64_read(&cfs_rq->decay_counter); | 2573 | u64 decays = atomic64_read(&cfs_rq->decay_counter); |
2575 | 2574 | ||
2576 | decays -= se->avg.decay_count; | 2575 | decays -= se->avg.decay_count; |
2576 | se->avg.decay_count = 0; | ||
2577 | if (!decays) | 2577 | if (!decays) |
2578 | return 0; | 2578 | return 0; |
2579 | 2579 | ||
2580 | se->avg.load_avg_contrib = decay_load(se->avg.load_avg_contrib, decays); | 2580 | se->avg.load_avg_contrib = decay_load(se->avg.load_avg_contrib, decays); |
2581 | se->avg.decay_count = 0; | ||
2582 | 2581 | ||
2583 | return decays; | 2582 | return decays; |
2584 | } | 2583 | } |
@@ -5157,7 +5156,7 @@ static void yield_task_fair(struct rq *rq) | |||
5157 | * so we don't do microscopic update in schedule() | 5156 | * so we don't do microscopic update in schedule() |
5158 | * and double the fastpath cost. | 5157 | * and double the fastpath cost. |
5159 | */ | 5158 | */ |
5160 | rq->skip_clock_update = 1; | 5159 | rq_clock_skip_update(rq, true); |
5161 | } | 5160 | } |
5162 | 5161 | ||
5163 | set_skip_buddy(se); | 5162 | set_skip_buddy(se); |
@@ -5949,8 +5948,8 @@ static unsigned long scale_rt_capacity(int cpu) | |||
5949 | */ | 5948 | */ |
5950 | age_stamp = ACCESS_ONCE(rq->age_stamp); | 5949 | age_stamp = ACCESS_ONCE(rq->age_stamp); |
5951 | avg = ACCESS_ONCE(rq->rt_avg); | 5950 | avg = ACCESS_ONCE(rq->rt_avg); |
5951 | delta = __rq_clock_broken(rq) - age_stamp; | ||
5952 | 5952 | ||
5953 | delta = rq_clock(rq) - age_stamp; | ||
5954 | if (unlikely(delta < 0)) | 5953 | if (unlikely(delta < 0)) |
5955 | delta = 0; | 5954 | delta = 0; |
5956 | 5955 | ||
diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c index c47fce75e666..aaf1c1d5cf5d 100644 --- a/kernel/sched/idle.c +++ b/kernel/sched/idle.c | |||
@@ -47,7 +47,8 @@ static inline int cpu_idle_poll(void) | |||
47 | rcu_idle_enter(); | 47 | rcu_idle_enter(); |
48 | trace_cpu_idle_rcuidle(0, smp_processor_id()); | 48 | trace_cpu_idle_rcuidle(0, smp_processor_id()); |
49 | local_irq_enable(); | 49 | local_irq_enable(); |
50 | while (!tif_need_resched()) | 50 | while (!tif_need_resched() && |
51 | (cpu_idle_force_poll || tick_check_broadcast_expired())) | ||
51 | cpu_relax(); | 52 | cpu_relax(); |
52 | trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id()); | 53 | trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id()); |
53 | rcu_idle_exit(); | 54 | rcu_idle_exit(); |
diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index ee15f5a0d1c1..f4d4b077eba0 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c | |||
@@ -831,11 +831,14 @@ static int do_sched_rt_period_timer(struct rt_bandwidth *rt_b, int overrun) | |||
831 | enqueue = 1; | 831 | enqueue = 1; |
832 | 832 | ||
833 | /* | 833 | /* |
834 | * Force a clock update if the CPU was idle, | 834 | * When we're idle and a woken (rt) task is |
835 | * lest wakeup -> unthrottle time accumulate. | 835 | * throttled check_preempt_curr() will set |
836 | * skip_update and the time between the wakeup | ||
837 | * and this unthrottle will get accounted as | ||
838 | * 'runtime'. | ||
836 | */ | 839 | */ |
837 | if (rt_rq->rt_nr_running && rq->curr == rq->idle) | 840 | if (rt_rq->rt_nr_running && rq->curr == rq->idle) |
838 | rq->skip_clock_update = -1; | 841 | rq_clock_skip_update(rq, false); |
839 | } | 842 | } |
840 | if (rt_rq->rt_time || rt_rq->rt_nr_running) | 843 | if (rt_rq->rt_time || rt_rq->rt_nr_running) |
841 | idle = 0; | 844 | idle = 0; |
@@ -1337,7 +1340,12 @@ select_task_rq_rt(struct task_struct *p, int cpu, int sd_flag, int flags) | |||
1337 | curr->prio <= p->prio)) { | 1340 | curr->prio <= p->prio)) { |
1338 | int target = find_lowest_rq(p); | 1341 | int target = find_lowest_rq(p); |
1339 | 1342 | ||
1340 | if (target != -1) | 1343 | /* |
1344 | * Don't bother moving it if the destination CPU is | ||
1345 | * not running a lower priority task. | ||
1346 | */ | ||
1347 | if (target != -1 && | ||
1348 | p->prio < cpu_rq(target)->rt.highest_prio.curr) | ||
1341 | cpu = target; | 1349 | cpu = target; |
1342 | } | 1350 | } |
1343 | rcu_read_unlock(); | 1351 | rcu_read_unlock(); |
@@ -1614,6 +1622,16 @@ static struct rq *find_lock_lowest_rq(struct task_struct *task, struct rq *rq) | |||
1614 | 1622 | ||
1615 | lowest_rq = cpu_rq(cpu); | 1623 | lowest_rq = cpu_rq(cpu); |
1616 | 1624 | ||
1625 | if (lowest_rq->rt.highest_prio.curr <= task->prio) { | ||
1626 | /* | ||
1627 | * Target rq has tasks of equal or higher priority, | ||
1628 | * retrying does not release any lock and is unlikely | ||
1629 | * to yield a different result. | ||
1630 | */ | ||
1631 | lowest_rq = NULL; | ||
1632 | break; | ||
1633 | } | ||
1634 | |||
1617 | /* if the prio of this runqueue changed, try again */ | 1635 | /* if the prio of this runqueue changed, try again */ |
1618 | if (double_lock_balance(rq, lowest_rq)) { | 1636 | if (double_lock_balance(rq, lowest_rq)) { |
1619 | /* | 1637 | /* |
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 9a2a45c970e7..0870db23d79c 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h | |||
@@ -558,8 +558,6 @@ struct rq { | |||
558 | #ifdef CONFIG_NO_HZ_FULL | 558 | #ifdef CONFIG_NO_HZ_FULL |
559 | unsigned long last_sched_tick; | 559 | unsigned long last_sched_tick; |
560 | #endif | 560 | #endif |
561 | int skip_clock_update; | ||
562 | |||
563 | /* capture load from *all* tasks on this cpu: */ | 561 | /* capture load from *all* tasks on this cpu: */ |
564 | struct load_weight load; | 562 | struct load_weight load; |
565 | unsigned long nr_load_updates; | 563 | unsigned long nr_load_updates; |
@@ -588,6 +586,7 @@ struct rq { | |||
588 | unsigned long next_balance; | 586 | unsigned long next_balance; |
589 | struct mm_struct *prev_mm; | 587 | struct mm_struct *prev_mm; |
590 | 588 | ||
589 | unsigned int clock_skip_update; | ||
591 | u64 clock; | 590 | u64 clock; |
592 | u64 clock_task; | 591 | u64 clock_task; |
593 | 592 | ||
@@ -687,16 +686,35 @@ DECLARE_PER_CPU_SHARED_ALIGNED(struct rq, runqueues); | |||
687 | #define cpu_curr(cpu) (cpu_rq(cpu)->curr) | 686 | #define cpu_curr(cpu) (cpu_rq(cpu)->curr) |
688 | #define raw_rq() raw_cpu_ptr(&runqueues) | 687 | #define raw_rq() raw_cpu_ptr(&runqueues) |
689 | 688 | ||
689 | static inline u64 __rq_clock_broken(struct rq *rq) | ||
690 | { | ||
691 | return ACCESS_ONCE(rq->clock); | ||
692 | } | ||
693 | |||
690 | static inline u64 rq_clock(struct rq *rq) | 694 | static inline u64 rq_clock(struct rq *rq) |
691 | { | 695 | { |
696 | lockdep_assert_held(&rq->lock); | ||
692 | return rq->clock; | 697 | return rq->clock; |
693 | } | 698 | } |
694 | 699 | ||
695 | static inline u64 rq_clock_task(struct rq *rq) | 700 | static inline u64 rq_clock_task(struct rq *rq) |
696 | { | 701 | { |
702 | lockdep_assert_held(&rq->lock); | ||
697 | return rq->clock_task; | 703 | return rq->clock_task; |
698 | } | 704 | } |
699 | 705 | ||
706 | #define RQCF_REQ_SKIP 0x01 | ||
707 | #define RQCF_ACT_SKIP 0x02 | ||
708 | |||
709 | static inline void rq_clock_skip_update(struct rq *rq, bool skip) | ||
710 | { | ||
711 | lockdep_assert_held(&rq->lock); | ||
712 | if (skip) | ||
713 | rq->clock_skip_update |= RQCF_REQ_SKIP; | ||
714 | else | ||
715 | rq->clock_skip_update &= ~RQCF_REQ_SKIP; | ||
716 | } | ||
717 | |||
700 | #ifdef CONFIG_NUMA | 718 | #ifdef CONFIG_NUMA |
701 | enum numa_topology_type { | 719 | enum numa_topology_type { |
702 | NUMA_DIRECT, | 720 | NUMA_DIRECT, |