diff options
author | Tejun Heo <tj@kernel.org> | 2009-08-14 01:41:02 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2009-08-14 01:45:31 -0400 |
commit | 384be2b18a5f9475eab9ca2bdfa95cc1a04ef59c (patch) | |
tree | 04c93f391a1b65c8bf8d7ba8643c07d26c26590a /kernel/sched.c | |
parent | a76761b621bcd8336065c4fe3a74f046858bc34c (diff) | |
parent | 142d44b0dd6741a64a7bdbe029110e7c1dcf1d23 (diff) |
Merge branch 'percpu-for-linus' into percpu-for-next
Conflicts:
arch/sparc/kernel/smp_64.c
arch/x86/kernel/cpu/perf_counter.c
arch/x86/kernel/setup_percpu.c
drivers/cpufreq/cpufreq_ondemand.c
mm/percpu.c
Conflicts in core and arch percpu codes are mostly from commit
ed78e1e078dd44249f88b1dd8c76dafb39567161 which substituted many
num_possible_cpus() with nr_cpu_ids. As for-next branch has moved all
the first chunk allocators into mm/percpu.c, the changes are moved
from arch code to mm/percpu.c.
Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'kernel/sched.c')
-rw-r--r-- | kernel/sched.c | 61 |
1 files changed, 44 insertions, 17 deletions
diff --git a/kernel/sched.c b/kernel/sched.c index 34fd81d21784..d3d7e7694da6 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
@@ -493,6 +493,7 @@ struct rt_rq { | |||
493 | #endif | 493 | #endif |
494 | #ifdef CONFIG_SMP | 494 | #ifdef CONFIG_SMP |
495 | unsigned long rt_nr_migratory; | 495 | unsigned long rt_nr_migratory; |
496 | unsigned long rt_nr_total; | ||
496 | int overloaded; | 497 | int overloaded; |
497 | struct plist_head pushable_tasks; | 498 | struct plist_head pushable_tasks; |
498 | #endif | 499 | #endif |
@@ -2571,15 +2572,37 @@ static void __sched_fork(struct task_struct *p) | |||
2571 | p->se.avg_wakeup = sysctl_sched_wakeup_granularity; | 2572 | p->se.avg_wakeup = sysctl_sched_wakeup_granularity; |
2572 | 2573 | ||
2573 | #ifdef CONFIG_SCHEDSTATS | 2574 | #ifdef CONFIG_SCHEDSTATS |
2574 | p->se.wait_start = 0; | 2575 | p->se.wait_start = 0; |
2575 | p->se.sum_sleep_runtime = 0; | 2576 | p->se.wait_max = 0; |
2576 | p->se.sleep_start = 0; | 2577 | p->se.wait_count = 0; |
2577 | p->se.block_start = 0; | 2578 | p->se.wait_sum = 0; |
2578 | p->se.sleep_max = 0; | 2579 | |
2579 | p->se.block_max = 0; | 2580 | p->se.sleep_start = 0; |
2580 | p->se.exec_max = 0; | 2581 | p->se.sleep_max = 0; |
2581 | p->se.slice_max = 0; | 2582 | p->se.sum_sleep_runtime = 0; |
2582 | p->se.wait_max = 0; | 2583 | |
2584 | p->se.block_start = 0; | ||
2585 | p->se.block_max = 0; | ||
2586 | p->se.exec_max = 0; | ||
2587 | p->se.slice_max = 0; | ||
2588 | |||
2589 | p->se.nr_migrations_cold = 0; | ||
2590 | p->se.nr_failed_migrations_affine = 0; | ||
2591 | p->se.nr_failed_migrations_running = 0; | ||
2592 | p->se.nr_failed_migrations_hot = 0; | ||
2593 | p->se.nr_forced_migrations = 0; | ||
2594 | p->se.nr_forced2_migrations = 0; | ||
2595 | |||
2596 | p->se.nr_wakeups = 0; | ||
2597 | p->se.nr_wakeups_sync = 0; | ||
2598 | p->se.nr_wakeups_migrate = 0; | ||
2599 | p->se.nr_wakeups_local = 0; | ||
2600 | p->se.nr_wakeups_remote = 0; | ||
2601 | p->se.nr_wakeups_affine = 0; | ||
2602 | p->se.nr_wakeups_affine_attempts = 0; | ||
2603 | p->se.nr_wakeups_passive = 0; | ||
2604 | p->se.nr_wakeups_idle = 0; | ||
2605 | |||
2583 | #endif | 2606 | #endif |
2584 | 2607 | ||
2585 | INIT_LIST_HEAD(&p->rt.run_list); | 2608 | INIT_LIST_HEAD(&p->rt.run_list); |
@@ -6541,6 +6564,11 @@ SYSCALL_DEFINE0(sched_yield) | |||
6541 | return 0; | 6564 | return 0; |
6542 | } | 6565 | } |
6543 | 6566 | ||
6567 | static inline int should_resched(void) | ||
6568 | { | ||
6569 | return need_resched() && !(preempt_count() & PREEMPT_ACTIVE); | ||
6570 | } | ||
6571 | |||
6544 | static void __cond_resched(void) | 6572 | static void __cond_resched(void) |
6545 | { | 6573 | { |
6546 | #ifdef CONFIG_DEBUG_SPINLOCK_SLEEP | 6574 | #ifdef CONFIG_DEBUG_SPINLOCK_SLEEP |
@@ -6560,8 +6588,7 @@ static void __cond_resched(void) | |||
6560 | 6588 | ||
6561 | int __sched _cond_resched(void) | 6589 | int __sched _cond_resched(void) |
6562 | { | 6590 | { |
6563 | if (need_resched() && !(preempt_count() & PREEMPT_ACTIVE) && | 6591 | if (should_resched()) { |
6564 | system_state == SYSTEM_RUNNING) { | ||
6565 | __cond_resched(); | 6592 | __cond_resched(); |
6566 | return 1; | 6593 | return 1; |
6567 | } | 6594 | } |
@@ -6579,12 +6606,12 @@ EXPORT_SYMBOL(_cond_resched); | |||
6579 | */ | 6606 | */ |
6580 | int cond_resched_lock(spinlock_t *lock) | 6607 | int cond_resched_lock(spinlock_t *lock) |
6581 | { | 6608 | { |
6582 | int resched = need_resched() && system_state == SYSTEM_RUNNING; | 6609 | int resched = should_resched(); |
6583 | int ret = 0; | 6610 | int ret = 0; |
6584 | 6611 | ||
6585 | if (spin_needbreak(lock) || resched) { | 6612 | if (spin_needbreak(lock) || resched) { |
6586 | spin_unlock(lock); | 6613 | spin_unlock(lock); |
6587 | if (resched && need_resched()) | 6614 | if (resched) |
6588 | __cond_resched(); | 6615 | __cond_resched(); |
6589 | else | 6616 | else |
6590 | cpu_relax(); | 6617 | cpu_relax(); |
@@ -6599,7 +6626,7 @@ int __sched cond_resched_softirq(void) | |||
6599 | { | 6626 | { |
6600 | BUG_ON(!in_softirq()); | 6627 | BUG_ON(!in_softirq()); |
6601 | 6628 | ||
6602 | if (need_resched() && system_state == SYSTEM_RUNNING) { | 6629 | if (should_resched()) { |
6603 | local_bh_enable(); | 6630 | local_bh_enable(); |
6604 | __cond_resched(); | 6631 | __cond_resched(); |
6605 | local_bh_disable(); | 6632 | local_bh_disable(); |
@@ -7262,6 +7289,7 @@ static void migrate_dead_tasks(unsigned int dead_cpu) | |||
7262 | static void calc_global_load_remove(struct rq *rq) | 7289 | static void calc_global_load_remove(struct rq *rq) |
7263 | { | 7290 | { |
7264 | atomic_long_sub(rq->calc_load_active, &calc_load_tasks); | 7291 | atomic_long_sub(rq->calc_load_active, &calc_load_tasks); |
7292 | rq->calc_load_active = 0; | ||
7265 | } | 7293 | } |
7266 | #endif /* CONFIG_HOTPLUG_CPU */ | 7294 | #endif /* CONFIG_HOTPLUG_CPU */ |
7267 | 7295 | ||
@@ -7488,6 +7516,7 @@ migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu) | |||
7488 | task_rq_unlock(rq, &flags); | 7516 | task_rq_unlock(rq, &flags); |
7489 | get_task_struct(p); | 7517 | get_task_struct(p); |
7490 | cpu_rq(cpu)->migration_thread = p; | 7518 | cpu_rq(cpu)->migration_thread = p; |
7519 | rq->calc_load_update = calc_load_update; | ||
7491 | break; | 7520 | break; |
7492 | 7521 | ||
7493 | case CPU_ONLINE: | 7522 | case CPU_ONLINE: |
@@ -7498,8 +7527,6 @@ migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu) | |||
7498 | /* Update our root-domain */ | 7527 | /* Update our root-domain */ |
7499 | rq = cpu_rq(cpu); | 7528 | rq = cpu_rq(cpu); |
7500 | spin_lock_irqsave(&rq->lock, flags); | 7529 | spin_lock_irqsave(&rq->lock, flags); |
7501 | rq->calc_load_update = calc_load_update; | ||
7502 | rq->calc_load_active = 0; | ||
7503 | if (rq->rd) { | 7530 | if (rq->rd) { |
7504 | BUG_ON(!cpumask_test_cpu(cpu, rq->rd->span)); | 7531 | BUG_ON(!cpumask_test_cpu(cpu, rq->rd->span)); |
7505 | 7532 | ||
@@ -9070,7 +9097,7 @@ static void init_rt_rq(struct rt_rq *rt_rq, struct rq *rq) | |||
9070 | #ifdef CONFIG_SMP | 9097 | #ifdef CONFIG_SMP |
9071 | rt_rq->rt_nr_migratory = 0; | 9098 | rt_rq->rt_nr_migratory = 0; |
9072 | rt_rq->overloaded = 0; | 9099 | rt_rq->overloaded = 0; |
9073 | plist_head_init(&rq->rt.pushable_tasks, &rq->lock); | 9100 | plist_head_init(&rt_rq->pushable_tasks, &rq->lock); |
9074 | #endif | 9101 | #endif |
9075 | 9102 | ||
9076 | rt_rq->rt_time = 0; | 9103 | rt_rq->rt_time = 0; |