diff options
Diffstat (limited to 'kernel/sched.c')
-rw-r--r-- | kernel/sched.c | 345 |
1 files changed, 231 insertions, 114 deletions
diff --git a/kernel/sched.c b/kernel/sched.c index 8d25be06db62..e7f2cfa6a257 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
@@ -309,6 +309,8 @@ static DEFINE_PER_CPU_SHARED_ALIGNED(struct rt_rq, init_rt_rq); | |||
309 | */ | 309 | */ |
310 | static DEFINE_SPINLOCK(task_group_lock); | 310 | static DEFINE_SPINLOCK(task_group_lock); |
311 | 311 | ||
312 | #ifdef CONFIG_FAIR_GROUP_SCHED | ||
313 | |||
312 | #ifdef CONFIG_SMP | 314 | #ifdef CONFIG_SMP |
313 | static int root_task_group_empty(void) | 315 | static int root_task_group_empty(void) |
314 | { | 316 | { |
@@ -316,7 +318,6 @@ static int root_task_group_empty(void) | |||
316 | } | 318 | } |
317 | #endif | 319 | #endif |
318 | 320 | ||
319 | #ifdef CONFIG_FAIR_GROUP_SCHED | ||
320 | #ifdef CONFIG_USER_SCHED | 321 | #ifdef CONFIG_USER_SCHED |
321 | # define INIT_TASK_GROUP_LOAD (2*NICE_0_LOAD) | 322 | # define INIT_TASK_GROUP_LOAD (2*NICE_0_LOAD) |
322 | #else /* !CONFIG_USER_SCHED */ | 323 | #else /* !CONFIG_USER_SCHED */ |
@@ -534,14 +535,12 @@ struct rq { | |||
534 | #define CPU_LOAD_IDX_MAX 5 | 535 | #define CPU_LOAD_IDX_MAX 5 |
535 | unsigned long cpu_load[CPU_LOAD_IDX_MAX]; | 536 | unsigned long cpu_load[CPU_LOAD_IDX_MAX]; |
536 | #ifdef CONFIG_NO_HZ | 537 | #ifdef CONFIG_NO_HZ |
537 | unsigned long last_tick_seen; | ||
538 | unsigned char in_nohz_recently; | 538 | unsigned char in_nohz_recently; |
539 | #endif | 539 | #endif |
540 | /* capture load from *all* tasks on this cpu: */ | 540 | /* capture load from *all* tasks on this cpu: */ |
541 | struct load_weight load; | 541 | struct load_weight load; |
542 | unsigned long nr_load_updates; | 542 | unsigned long nr_load_updates; |
543 | u64 nr_switches; | 543 | u64 nr_switches; |
544 | u64 nr_migrations_in; | ||
545 | 544 | ||
546 | struct cfs_rq cfs; | 545 | struct cfs_rq cfs; |
547 | struct rt_rq rt; | 546 | struct rt_rq rt; |
@@ -590,6 +589,8 @@ struct rq { | |||
590 | 589 | ||
591 | u64 rt_avg; | 590 | u64 rt_avg; |
592 | u64 age_stamp; | 591 | u64 age_stamp; |
592 | u64 idle_stamp; | ||
593 | u64 avg_idle; | ||
593 | #endif | 594 | #endif |
594 | 595 | ||
595 | /* calc_load related fields */ | 596 | /* calc_load related fields */ |
@@ -676,6 +677,7 @@ inline void update_rq_clock(struct rq *rq) | |||
676 | 677 | ||
677 | /** | 678 | /** |
678 | * runqueue_is_locked | 679 | * runqueue_is_locked |
680 | * @cpu: the processor in question. | ||
679 | * | 681 | * |
680 | * Returns true if the current cpu runqueue is locked. | 682 | * Returns true if the current cpu runqueue is locked. |
681 | * This interface allows printk to be called with the runqueue lock | 683 | * This interface allows printk to be called with the runqueue lock |
@@ -770,7 +772,7 @@ sched_feat_write(struct file *filp, const char __user *ubuf, | |||
770 | if (!sched_feat_names[i]) | 772 | if (!sched_feat_names[i]) |
771 | return -EINVAL; | 773 | return -EINVAL; |
772 | 774 | ||
773 | filp->f_pos += cnt; | 775 | *ppos += cnt; |
774 | 776 | ||
775 | return cnt; | 777 | return cnt; |
776 | } | 778 | } |
@@ -1563,11 +1565,7 @@ static unsigned long cpu_avg_load_per_task(int cpu) | |||
1563 | 1565 | ||
1564 | #ifdef CONFIG_FAIR_GROUP_SCHED | 1566 | #ifdef CONFIG_FAIR_GROUP_SCHED |
1565 | 1567 | ||
1566 | struct update_shares_data { | 1568 | static __read_mostly unsigned long *update_shares_data; |
1567 | unsigned long rq_weight[NR_CPUS]; | ||
1568 | }; | ||
1569 | |||
1570 | static DEFINE_PER_CPU(struct update_shares_data, update_shares_data); | ||
1571 | 1569 | ||
1572 | static void __set_se_shares(struct sched_entity *se, unsigned long shares); | 1570 | static void __set_se_shares(struct sched_entity *se, unsigned long shares); |
1573 | 1571 | ||
@@ -1577,12 +1575,12 @@ static void __set_se_shares(struct sched_entity *se, unsigned long shares); | |||
1577 | static void update_group_shares_cpu(struct task_group *tg, int cpu, | 1575 | static void update_group_shares_cpu(struct task_group *tg, int cpu, |
1578 | unsigned long sd_shares, | 1576 | unsigned long sd_shares, |
1579 | unsigned long sd_rq_weight, | 1577 | unsigned long sd_rq_weight, |
1580 | struct update_shares_data *usd) | 1578 | unsigned long *usd_rq_weight) |
1581 | { | 1579 | { |
1582 | unsigned long shares, rq_weight; | 1580 | unsigned long shares, rq_weight; |
1583 | int boost = 0; | 1581 | int boost = 0; |
1584 | 1582 | ||
1585 | rq_weight = usd->rq_weight[cpu]; | 1583 | rq_weight = usd_rq_weight[cpu]; |
1586 | if (!rq_weight) { | 1584 | if (!rq_weight) { |
1587 | boost = 1; | 1585 | boost = 1; |
1588 | rq_weight = NICE_0_LOAD; | 1586 | rq_weight = NICE_0_LOAD; |
@@ -1617,7 +1615,7 @@ static void update_group_shares_cpu(struct task_group *tg, int cpu, | |||
1617 | static int tg_shares_up(struct task_group *tg, void *data) | 1615 | static int tg_shares_up(struct task_group *tg, void *data) |
1618 | { | 1616 | { |
1619 | unsigned long weight, rq_weight = 0, shares = 0; | 1617 | unsigned long weight, rq_weight = 0, shares = 0; |
1620 | struct update_shares_data *usd; | 1618 | unsigned long *usd_rq_weight; |
1621 | struct sched_domain *sd = data; | 1619 | struct sched_domain *sd = data; |
1622 | unsigned long flags; | 1620 | unsigned long flags; |
1623 | int i; | 1621 | int i; |
@@ -1626,11 +1624,11 @@ static int tg_shares_up(struct task_group *tg, void *data) | |||
1626 | return 0; | 1624 | return 0; |
1627 | 1625 | ||
1628 | local_irq_save(flags); | 1626 | local_irq_save(flags); |
1629 | usd = &__get_cpu_var(update_shares_data); | 1627 | usd_rq_weight = per_cpu_ptr(update_shares_data, smp_processor_id()); |
1630 | 1628 | ||
1631 | for_each_cpu(i, sched_domain_span(sd)) { | 1629 | for_each_cpu(i, sched_domain_span(sd)) { |
1632 | weight = tg->cfs_rq[i]->load.weight; | 1630 | weight = tg->cfs_rq[i]->load.weight; |
1633 | usd->rq_weight[i] = weight; | 1631 | usd_rq_weight[i] = weight; |
1634 | 1632 | ||
1635 | /* | 1633 | /* |
1636 | * If there are currently no tasks on the cpu pretend there | 1634 | * If there are currently no tasks on the cpu pretend there |
@@ -1651,7 +1649,7 @@ static int tg_shares_up(struct task_group *tg, void *data) | |||
1651 | shares = tg->shares; | 1649 | shares = tg->shares; |
1652 | 1650 | ||
1653 | for_each_cpu(i, sched_domain_span(sd)) | 1651 | for_each_cpu(i, sched_domain_span(sd)) |
1654 | update_group_shares_cpu(tg, i, shares, rq_weight, usd); | 1652 | update_group_shares_cpu(tg, i, shares, rq_weight, usd_rq_weight); |
1655 | 1653 | ||
1656 | local_irq_restore(flags); | 1654 | local_irq_restore(flags); |
1657 | 1655 | ||
@@ -1995,6 +1993,39 @@ static inline void check_class_changed(struct rq *rq, struct task_struct *p, | |||
1995 | p->sched_class->prio_changed(rq, p, oldprio, running); | 1993 | p->sched_class->prio_changed(rq, p, oldprio, running); |
1996 | } | 1994 | } |
1997 | 1995 | ||
1996 | /** | ||
1997 | * kthread_bind - bind a just-created kthread to a cpu. | ||
1998 | * @p: thread created by kthread_create(). | ||
1999 | * @cpu: cpu (might not be online, must be possible) for @k to run on. | ||
2000 | * | ||
2001 | * Description: This function is equivalent to set_cpus_allowed(), | ||
2002 | * except that @cpu doesn't need to be online, and the thread must be | ||
2003 | * stopped (i.e., just returned from kthread_create()). | ||
2004 | * | ||
2005 | * Function lives here instead of kthread.c because it messes with | ||
2006 | * scheduler internals which require locking. | ||
2007 | */ | ||
2008 | void kthread_bind(struct task_struct *p, unsigned int cpu) | ||
2009 | { | ||
2010 | struct rq *rq = cpu_rq(cpu); | ||
2011 | unsigned long flags; | ||
2012 | |||
2013 | /* Must have done schedule() in kthread() before we set_task_cpu */ | ||
2014 | if (!wait_task_inactive(p, TASK_UNINTERRUPTIBLE)) { | ||
2015 | WARN_ON(1); | ||
2016 | return; | ||
2017 | } | ||
2018 | |||
2019 | spin_lock_irqsave(&rq->lock, flags); | ||
2020 | update_rq_clock(rq); | ||
2021 | set_task_cpu(p, cpu); | ||
2022 | p->cpus_allowed = cpumask_of_cpu(cpu); | ||
2023 | p->rt.nr_cpus_allowed = 1; | ||
2024 | p->flags |= PF_THREAD_BOUND; | ||
2025 | spin_unlock_irqrestore(&rq->lock, flags); | ||
2026 | } | ||
2027 | EXPORT_SYMBOL(kthread_bind); | ||
2028 | |||
1998 | #ifdef CONFIG_SMP | 2029 | #ifdef CONFIG_SMP |
1999 | /* | 2030 | /* |
2000 | * Is this task likely cache-hot: | 2031 | * Is this task likely cache-hot: |
@@ -2007,7 +2038,7 @@ task_hot(struct task_struct *p, u64 now, struct sched_domain *sd) | |||
2007 | /* | 2038 | /* |
2008 | * Buddy candidates are cache hot: | 2039 | * Buddy candidates are cache hot: |
2009 | */ | 2040 | */ |
2010 | if (sched_feat(CACHE_HOT_BUDDY) && | 2041 | if (sched_feat(CACHE_HOT_BUDDY) && this_rq()->nr_running && |
2011 | (&p->se == cfs_rq_of(&p->se)->next || | 2042 | (&p->se == cfs_rq_of(&p->se)->next || |
2012 | &p->se == cfs_rq_of(&p->se)->last)) | 2043 | &p->se == cfs_rq_of(&p->se)->last)) |
2013 | return 1; | 2044 | return 1; |
@@ -2048,7 +2079,6 @@ void set_task_cpu(struct task_struct *p, unsigned int new_cpu) | |||
2048 | #endif | 2079 | #endif |
2049 | if (old_cpu != new_cpu) { | 2080 | if (old_cpu != new_cpu) { |
2050 | p->se.nr_migrations++; | 2081 | p->se.nr_migrations++; |
2051 | new_rq->nr_migrations_in++; | ||
2052 | #ifdef CONFIG_SCHEDSTATS | 2082 | #ifdef CONFIG_SCHEDSTATS |
2053 | if (task_hot(p, old_rq->clock, NULL)) | 2083 | if (task_hot(p, old_rq->clock, NULL)) |
2054 | schedstat_inc(p, se.nr_forced2_migrations); | 2084 | schedstat_inc(p, se.nr_forced2_migrations); |
@@ -2085,6 +2115,7 @@ migrate_task(struct task_struct *p, int dest_cpu, struct migration_req *req) | |||
2085 | * it is sufficient to simply update the task's cpu field. | 2115 | * it is sufficient to simply update the task's cpu field. |
2086 | */ | 2116 | */ |
2087 | if (!p->se.on_rq && !task_running(rq, p)) { | 2117 | if (!p->se.on_rq && !task_running(rq, p)) { |
2118 | update_rq_clock(rq); | ||
2088 | set_task_cpu(p, dest_cpu); | 2119 | set_task_cpu(p, dest_cpu); |
2089 | return 0; | 2120 | return 0; |
2090 | } | 2121 | } |
@@ -2311,7 +2342,7 @@ static int try_to_wake_up(struct task_struct *p, unsigned int state, | |||
2311 | { | 2342 | { |
2312 | int cpu, orig_cpu, this_cpu, success = 0; | 2343 | int cpu, orig_cpu, this_cpu, success = 0; |
2313 | unsigned long flags; | 2344 | unsigned long flags; |
2314 | struct rq *rq; | 2345 | struct rq *rq, *orig_rq; |
2315 | 2346 | ||
2316 | if (!sched_feat(SYNC_WAKEUPS)) | 2347 | if (!sched_feat(SYNC_WAKEUPS)) |
2317 | wake_flags &= ~WF_SYNC; | 2348 | wake_flags &= ~WF_SYNC; |
@@ -2319,7 +2350,7 @@ static int try_to_wake_up(struct task_struct *p, unsigned int state, | |||
2319 | this_cpu = get_cpu(); | 2350 | this_cpu = get_cpu(); |
2320 | 2351 | ||
2321 | smp_wmb(); | 2352 | smp_wmb(); |
2322 | rq = task_rq_lock(p, &flags); | 2353 | rq = orig_rq = task_rq_lock(p, &flags); |
2323 | update_rq_clock(rq); | 2354 | update_rq_clock(rq); |
2324 | if (!(p->state & state)) | 2355 | if (!(p->state & state)) |
2325 | goto out; | 2356 | goto out; |
@@ -2346,10 +2377,15 @@ static int try_to_wake_up(struct task_struct *p, unsigned int state, | |||
2346 | task_rq_unlock(rq, &flags); | 2377 | task_rq_unlock(rq, &flags); |
2347 | 2378 | ||
2348 | cpu = p->sched_class->select_task_rq(p, SD_BALANCE_WAKE, wake_flags); | 2379 | cpu = p->sched_class->select_task_rq(p, SD_BALANCE_WAKE, wake_flags); |
2349 | if (cpu != orig_cpu) | 2380 | if (cpu != orig_cpu) { |
2381 | local_irq_save(flags); | ||
2382 | rq = cpu_rq(cpu); | ||
2383 | update_rq_clock(rq); | ||
2350 | set_task_cpu(p, cpu); | 2384 | set_task_cpu(p, cpu); |
2351 | 2385 | local_irq_restore(flags); | |
2386 | } | ||
2352 | rq = task_rq_lock(p, &flags); | 2387 | rq = task_rq_lock(p, &flags); |
2388 | |||
2353 | WARN_ON(p->state != TASK_WAKING); | 2389 | WARN_ON(p->state != TASK_WAKING); |
2354 | cpu = task_cpu(p); | 2390 | cpu = task_cpu(p); |
2355 | 2391 | ||
@@ -2406,6 +2442,17 @@ out_running: | |||
2406 | #ifdef CONFIG_SMP | 2442 | #ifdef CONFIG_SMP |
2407 | if (p->sched_class->task_wake_up) | 2443 | if (p->sched_class->task_wake_up) |
2408 | p->sched_class->task_wake_up(rq, p); | 2444 | p->sched_class->task_wake_up(rq, p); |
2445 | |||
2446 | if (unlikely(rq->idle_stamp)) { | ||
2447 | u64 delta = rq->clock - rq->idle_stamp; | ||
2448 | u64 max = 2*sysctl_sched_migration_cost; | ||
2449 | |||
2450 | if (delta > max) | ||
2451 | rq->avg_idle = max; | ||
2452 | else | ||
2453 | update_avg(&rq->avg_idle, delta); | ||
2454 | rq->idle_stamp = 0; | ||
2455 | } | ||
2409 | #endif | 2456 | #endif |
2410 | out: | 2457 | out: |
2411 | task_rq_unlock(rq, &flags); | 2458 | task_rq_unlock(rq, &flags); |
@@ -2511,6 +2558,7 @@ static void __sched_fork(struct task_struct *p) | |||
2511 | void sched_fork(struct task_struct *p, int clone_flags) | 2558 | void sched_fork(struct task_struct *p, int clone_flags) |
2512 | { | 2559 | { |
2513 | int cpu = get_cpu(); | 2560 | int cpu = get_cpu(); |
2561 | unsigned long flags; | ||
2514 | 2562 | ||
2515 | __sched_fork(p); | 2563 | __sched_fork(p); |
2516 | 2564 | ||
@@ -2547,7 +2595,10 @@ void sched_fork(struct task_struct *p, int clone_flags) | |||
2547 | #ifdef CONFIG_SMP | 2595 | #ifdef CONFIG_SMP |
2548 | cpu = p->sched_class->select_task_rq(p, SD_BALANCE_FORK, 0); | 2596 | cpu = p->sched_class->select_task_rq(p, SD_BALANCE_FORK, 0); |
2549 | #endif | 2597 | #endif |
2598 | local_irq_save(flags); | ||
2599 | update_rq_clock(cpu_rq(cpu)); | ||
2550 | set_task_cpu(p, cpu); | 2600 | set_task_cpu(p, cpu); |
2601 | local_irq_restore(flags); | ||
2551 | 2602 | ||
2552 | #if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) | 2603 | #if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) |
2553 | if (likely(sched_info_on())) | 2604 | if (likely(sched_info_on())) |
@@ -2814,14 +2865,14 @@ context_switch(struct rq *rq, struct task_struct *prev, | |||
2814 | */ | 2865 | */ |
2815 | arch_start_context_switch(prev); | 2866 | arch_start_context_switch(prev); |
2816 | 2867 | ||
2817 | if (unlikely(!mm)) { | 2868 | if (likely(!mm)) { |
2818 | next->active_mm = oldmm; | 2869 | next->active_mm = oldmm; |
2819 | atomic_inc(&oldmm->mm_count); | 2870 | atomic_inc(&oldmm->mm_count); |
2820 | enter_lazy_tlb(oldmm, next); | 2871 | enter_lazy_tlb(oldmm, next); |
2821 | } else | 2872 | } else |
2822 | switch_mm(oldmm, mm, next); | 2873 | switch_mm(oldmm, mm, next); |
2823 | 2874 | ||
2824 | if (unlikely(!prev->mm)) { | 2875 | if (likely(!prev->mm)) { |
2825 | prev->active_mm = NULL; | 2876 | prev->active_mm = NULL; |
2826 | rq->prev_mm = oldmm; | 2877 | rq->prev_mm = oldmm; |
2827 | } | 2878 | } |
@@ -2984,15 +3035,6 @@ static void calc_load_account_active(struct rq *this_rq) | |||
2984 | } | 3035 | } |
2985 | 3036 | ||
2986 | /* | 3037 | /* |
2987 | * Externally visible per-cpu scheduler statistics: | ||
2988 | * cpu_nr_migrations(cpu) - number of migrations into that cpu | ||
2989 | */ | ||
2990 | u64 cpu_nr_migrations(int cpu) | ||
2991 | { | ||
2992 | return cpu_rq(cpu)->nr_migrations_in; | ||
2993 | } | ||
2994 | |||
2995 | /* | ||
2996 | * Update rq->cpu_load[] statistics. This function is usually called every | 3038 | * Update rq->cpu_load[] statistics. This function is usually called every |
2997 | * scheduler tick (TICK_NSEC). | 3039 | * scheduler tick (TICK_NSEC). |
2998 | */ | 3040 | */ |
@@ -3656,6 +3698,7 @@ static void update_group_power(struct sched_domain *sd, int cpu) | |||
3656 | 3698 | ||
3657 | /** | 3699 | /** |
3658 | * update_sg_lb_stats - Update sched_group's statistics for load balancing. | 3700 | * update_sg_lb_stats - Update sched_group's statistics for load balancing. |
3701 | * @sd: The sched_domain whose statistics are to be updated. | ||
3659 | * @group: sched_group whose statistics are to be updated. | 3702 | * @group: sched_group whose statistics are to be updated. |
3660 | * @this_cpu: Cpu for which load balance is currently performed. | 3703 | * @this_cpu: Cpu for which load balance is currently performed. |
3661 | * @idle: Idle status of this_cpu | 3704 | * @idle: Idle status of this_cpu |
@@ -4091,7 +4134,7 @@ static int load_balance(int this_cpu, struct rq *this_rq, | |||
4091 | unsigned long flags; | 4134 | unsigned long flags; |
4092 | struct cpumask *cpus = __get_cpu_var(load_balance_tmpmask); | 4135 | struct cpumask *cpus = __get_cpu_var(load_balance_tmpmask); |
4093 | 4136 | ||
4094 | cpumask_setall(cpus); | 4137 | cpumask_copy(cpus, cpu_online_mask); |
4095 | 4138 | ||
4096 | /* | 4139 | /* |
4097 | * When power savings policy is enabled for the parent domain, idle | 4140 | * When power savings policy is enabled for the parent domain, idle |
@@ -4254,7 +4297,7 @@ load_balance_newidle(int this_cpu, struct rq *this_rq, struct sched_domain *sd) | |||
4254 | int all_pinned = 0; | 4297 | int all_pinned = 0; |
4255 | struct cpumask *cpus = __get_cpu_var(load_balance_tmpmask); | 4298 | struct cpumask *cpus = __get_cpu_var(load_balance_tmpmask); |
4256 | 4299 | ||
4257 | cpumask_setall(cpus); | 4300 | cpumask_copy(cpus, cpu_online_mask); |
4258 | 4301 | ||
4259 | /* | 4302 | /* |
4260 | * When power savings policy is enabled for the parent domain, idle | 4303 | * When power savings policy is enabled for the parent domain, idle |
@@ -4394,6 +4437,11 @@ static void idle_balance(int this_cpu, struct rq *this_rq) | |||
4394 | int pulled_task = 0; | 4437 | int pulled_task = 0; |
4395 | unsigned long next_balance = jiffies + HZ; | 4438 | unsigned long next_balance = jiffies + HZ; |
4396 | 4439 | ||
4440 | this_rq->idle_stamp = this_rq->clock; | ||
4441 | |||
4442 | if (this_rq->avg_idle < sysctl_sched_migration_cost) | ||
4443 | return; | ||
4444 | |||
4397 | for_each_domain(this_cpu, sd) { | 4445 | for_each_domain(this_cpu, sd) { |
4398 | unsigned long interval; | 4446 | unsigned long interval; |
4399 | 4447 | ||
@@ -4408,8 +4456,10 @@ static void idle_balance(int this_cpu, struct rq *this_rq) | |||
4408 | interval = msecs_to_jiffies(sd->balance_interval); | 4456 | interval = msecs_to_jiffies(sd->balance_interval); |
4409 | if (time_after(next_balance, sd->last_balance + interval)) | 4457 | if (time_after(next_balance, sd->last_balance + interval)) |
4410 | next_balance = sd->last_balance + interval; | 4458 | next_balance = sd->last_balance + interval; |
4411 | if (pulled_task) | 4459 | if (pulled_task) { |
4460 | this_rq->idle_stamp = 0; | ||
4412 | break; | 4461 | break; |
4462 | } | ||
4413 | } | 4463 | } |
4414 | if (pulled_task || time_after(jiffies, this_rq->next_balance)) { | 4464 | if (pulled_task || time_after(jiffies, this_rq->next_balance)) { |
4415 | /* | 4465 | /* |
@@ -5011,8 +5061,13 @@ static void account_guest_time(struct task_struct *p, cputime_t cputime, | |||
5011 | p->gtime = cputime_add(p->gtime, cputime); | 5061 | p->gtime = cputime_add(p->gtime, cputime); |
5012 | 5062 | ||
5013 | /* Add guest time to cpustat. */ | 5063 | /* Add guest time to cpustat. */ |
5014 | cpustat->user = cputime64_add(cpustat->user, tmp); | 5064 | if (TASK_NICE(p) > 0) { |
5015 | cpustat->guest = cputime64_add(cpustat->guest, tmp); | 5065 | cpustat->nice = cputime64_add(cpustat->nice, tmp); |
5066 | cpustat->guest_nice = cputime64_add(cpustat->guest_nice, tmp); | ||
5067 | } else { | ||
5068 | cpustat->user = cputime64_add(cpustat->user, tmp); | ||
5069 | cpustat->guest = cputime64_add(cpustat->guest, tmp); | ||
5070 | } | ||
5016 | } | 5071 | } |
5017 | 5072 | ||
5018 | /* | 5073 | /* |
@@ -5127,60 +5182,86 @@ void account_idle_ticks(unsigned long ticks) | |||
5127 | * Use precise platform statistics if available: | 5182 | * Use precise platform statistics if available: |
5128 | */ | 5183 | */ |
5129 | #ifdef CONFIG_VIRT_CPU_ACCOUNTING | 5184 | #ifdef CONFIG_VIRT_CPU_ACCOUNTING |
5130 | cputime_t task_utime(struct task_struct *p) | 5185 | void task_times(struct task_struct *p, cputime_t *ut, cputime_t *st) |
5131 | { | 5186 | { |
5132 | return p->utime; | 5187 | *ut = p->utime; |
5188 | *st = p->stime; | ||
5133 | } | 5189 | } |
5134 | 5190 | ||
5135 | cputime_t task_stime(struct task_struct *p) | 5191 | void thread_group_times(struct task_struct *p, cputime_t *ut, cputime_t *st) |
5136 | { | 5192 | { |
5137 | return p->stime; | 5193 | struct task_cputime cputime; |
5194 | |||
5195 | thread_group_cputime(p, &cputime); | ||
5196 | |||
5197 | *ut = cputime.utime; | ||
5198 | *st = cputime.stime; | ||
5138 | } | 5199 | } |
5139 | #else | 5200 | #else |
5140 | cputime_t task_utime(struct task_struct *p) | 5201 | |
5202 | #ifndef nsecs_to_cputime | ||
5203 | # define nsecs_to_cputime(__nsecs) nsecs_to_jiffies(__nsecs) | ||
5204 | #endif | ||
5205 | |||
5206 | void task_times(struct task_struct *p, cputime_t *ut, cputime_t *st) | ||
5141 | { | 5207 | { |
5142 | clock_t utime = cputime_to_clock_t(p->utime), | 5208 | cputime_t rtime, utime = p->utime, total = cputime_add(utime, p->stime); |
5143 | total = utime + cputime_to_clock_t(p->stime); | ||
5144 | u64 temp; | ||
5145 | 5209 | ||
5146 | /* | 5210 | /* |
5147 | * Use CFS's precise accounting: | 5211 | * Use CFS's precise accounting: |
5148 | */ | 5212 | */ |
5149 | temp = (u64)nsec_to_clock_t(p->se.sum_exec_runtime); | 5213 | rtime = nsecs_to_cputime(p->se.sum_exec_runtime); |
5150 | 5214 | ||
5151 | if (total) { | 5215 | if (total) { |
5152 | temp *= utime; | 5216 | u64 temp; |
5217 | |||
5218 | temp = (u64)(rtime * utime); | ||
5153 | do_div(temp, total); | 5219 | do_div(temp, total); |
5154 | } | 5220 | utime = (cputime_t)temp; |
5155 | utime = (clock_t)temp; | 5221 | } else |
5222 | utime = rtime; | ||
5223 | |||
5224 | /* | ||
5225 | * Compare with previous values, to keep monotonicity: | ||
5226 | */ | ||
5227 | p->prev_utime = max(p->prev_utime, utime); | ||
5228 | p->prev_stime = max(p->prev_stime, cputime_sub(rtime, p->prev_utime)); | ||
5156 | 5229 | ||
5157 | p->prev_utime = max(p->prev_utime, clock_t_to_cputime(utime)); | 5230 | *ut = p->prev_utime; |
5158 | return p->prev_utime; | 5231 | *st = p->prev_stime; |
5159 | } | 5232 | } |
5160 | 5233 | ||
5161 | cputime_t task_stime(struct task_struct *p) | 5234 | /* |
5235 | * Must be called with siglock held. | ||
5236 | */ | ||
5237 | void thread_group_times(struct task_struct *p, cputime_t *ut, cputime_t *st) | ||
5162 | { | 5238 | { |
5163 | clock_t stime; | 5239 | struct signal_struct *sig = p->signal; |
5240 | struct task_cputime cputime; | ||
5241 | cputime_t rtime, utime, total; | ||
5164 | 5242 | ||
5165 | /* | 5243 | thread_group_cputime(p, &cputime); |
5166 | * Use CFS's precise accounting. (we subtract utime from | ||
5167 | * the total, to make sure the total observed by userspace | ||
5168 | * grows monotonically - apps rely on that): | ||
5169 | */ | ||
5170 | stime = nsec_to_clock_t(p->se.sum_exec_runtime) - | ||
5171 | cputime_to_clock_t(task_utime(p)); | ||
5172 | 5244 | ||
5173 | if (stime >= 0) | 5245 | total = cputime_add(cputime.utime, cputime.stime); |
5174 | p->prev_stime = max(p->prev_stime, clock_t_to_cputime(stime)); | 5246 | rtime = nsecs_to_cputime(cputime.sum_exec_runtime); |
5175 | 5247 | ||
5176 | return p->prev_stime; | 5248 | if (total) { |
5177 | } | 5249 | u64 temp; |
5178 | #endif | ||
5179 | 5250 | ||
5180 | inline cputime_t task_gtime(struct task_struct *p) | 5251 | temp = (u64)(rtime * cputime.utime); |
5181 | { | 5252 | do_div(temp, total); |
5182 | return p->gtime; | 5253 | utime = (cputime_t)temp; |
5254 | } else | ||
5255 | utime = rtime; | ||
5256 | |||
5257 | sig->prev_utime = max(sig->prev_utime, utime); | ||
5258 | sig->prev_stime = max(sig->prev_stime, | ||
5259 | cputime_sub(rtime, sig->prev_utime)); | ||
5260 | |||
5261 | *ut = sig->prev_utime; | ||
5262 | *st = sig->prev_stime; | ||
5183 | } | 5263 | } |
5264 | #endif | ||
5184 | 5265 | ||
5185 | /* | 5266 | /* |
5186 | * This function gets called by the timer code, with HZ frequency. | 5267 | * This function gets called by the timer code, with HZ frequency. |
@@ -5446,7 +5527,7 @@ need_resched_nonpreemptible: | |||
5446 | } | 5527 | } |
5447 | EXPORT_SYMBOL(schedule); | 5528 | EXPORT_SYMBOL(schedule); |
5448 | 5529 | ||
5449 | #ifdef CONFIG_SMP | 5530 | #ifdef CONFIG_MUTEX_SPIN_ON_OWNER |
5450 | /* | 5531 | /* |
5451 | * Look out! "owner" is an entirely speculative pointer | 5532 | * Look out! "owner" is an entirely speculative pointer |
5452 | * access and not reliable. | 5533 | * access and not reliable. |
@@ -6140,22 +6221,14 @@ __setscheduler(struct rq *rq, struct task_struct *p, int policy, int prio) | |||
6140 | BUG_ON(p->se.on_rq); | 6221 | BUG_ON(p->se.on_rq); |
6141 | 6222 | ||
6142 | p->policy = policy; | 6223 | p->policy = policy; |
6143 | switch (p->policy) { | ||
6144 | case SCHED_NORMAL: | ||
6145 | case SCHED_BATCH: | ||
6146 | case SCHED_IDLE: | ||
6147 | p->sched_class = &fair_sched_class; | ||
6148 | break; | ||
6149 | case SCHED_FIFO: | ||
6150 | case SCHED_RR: | ||
6151 | p->sched_class = &rt_sched_class; | ||
6152 | break; | ||
6153 | } | ||
6154 | |||
6155 | p->rt_priority = prio; | 6224 | p->rt_priority = prio; |
6156 | p->normal_prio = normal_prio(p); | 6225 | p->normal_prio = normal_prio(p); |
6157 | /* we are holding p->pi_lock already */ | 6226 | /* we are holding p->pi_lock already */ |
6158 | p->prio = rt_mutex_getprio(p); | 6227 | p->prio = rt_mutex_getprio(p); |
6228 | if (rt_prio(p->prio)) | ||
6229 | p->sched_class = &rt_sched_class; | ||
6230 | else | ||
6231 | p->sched_class = &fair_sched_class; | ||
6159 | set_load_weight(p); | 6232 | set_load_weight(p); |
6160 | } | 6233 | } |
6161 | 6234 | ||
@@ -6900,7 +6973,7 @@ void show_state_filter(unsigned long state_filter) | |||
6900 | /* | 6973 | /* |
6901 | * Only show locks if all tasks are dumped: | 6974 | * Only show locks if all tasks are dumped: |
6902 | */ | 6975 | */ |
6903 | if (state_filter == -1) | 6976 | if (!state_filter) |
6904 | debug_show_all_locks(); | 6977 | debug_show_all_locks(); |
6905 | } | 6978 | } |
6906 | 6979 | ||
@@ -7371,17 +7444,16 @@ static struct ctl_table sd_ctl_dir[] = { | |||
7371 | .procname = "sched_domain", | 7444 | .procname = "sched_domain", |
7372 | .mode = 0555, | 7445 | .mode = 0555, |
7373 | }, | 7446 | }, |
7374 | {0, }, | 7447 | {} |
7375 | }; | 7448 | }; |
7376 | 7449 | ||
7377 | static struct ctl_table sd_ctl_root[] = { | 7450 | static struct ctl_table sd_ctl_root[] = { |
7378 | { | 7451 | { |
7379 | .ctl_name = CTL_KERN, | ||
7380 | .procname = "kernel", | 7452 | .procname = "kernel", |
7381 | .mode = 0555, | 7453 | .mode = 0555, |
7382 | .child = sd_ctl_dir, | 7454 | .child = sd_ctl_dir, |
7383 | }, | 7455 | }, |
7384 | {0, }, | 7456 | {} |
7385 | }; | 7457 | }; |
7386 | 7458 | ||
7387 | static struct ctl_table *sd_alloc_ctl_entry(int n) | 7459 | static struct ctl_table *sd_alloc_ctl_entry(int n) |
@@ -7705,6 +7777,16 @@ early_initcall(migration_init); | |||
7705 | 7777 | ||
7706 | #ifdef CONFIG_SCHED_DEBUG | 7778 | #ifdef CONFIG_SCHED_DEBUG |
7707 | 7779 | ||
7780 | static __read_mostly int sched_domain_debug_enabled; | ||
7781 | |||
7782 | static int __init sched_domain_debug_setup(char *str) | ||
7783 | { | ||
7784 | sched_domain_debug_enabled = 1; | ||
7785 | |||
7786 | return 0; | ||
7787 | } | ||
7788 | early_param("sched_debug", sched_domain_debug_setup); | ||
7789 | |||
7708 | static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level, | 7790 | static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level, |
7709 | struct cpumask *groupmask) | 7791 | struct cpumask *groupmask) |
7710 | { | 7792 | { |
@@ -7791,6 +7873,9 @@ static void sched_domain_debug(struct sched_domain *sd, int cpu) | |||
7791 | cpumask_var_t groupmask; | 7873 | cpumask_var_t groupmask; |
7792 | int level = 0; | 7874 | int level = 0; |
7793 | 7875 | ||
7876 | if (!sched_domain_debug_enabled) | ||
7877 | return; | ||
7878 | |||
7794 | if (!sd) { | 7879 | if (!sd) { |
7795 | printk(KERN_DEBUG "CPU%d attaching NULL sched-domain.\n", cpu); | 7880 | printk(KERN_DEBUG "CPU%d attaching NULL sched-domain.\n", cpu); |
7796 | return; | 7881 | return; |
@@ -7870,6 +7955,8 @@ sd_parent_degenerate(struct sched_domain *sd, struct sched_domain *parent) | |||
7870 | 7955 | ||
7871 | static void free_rootdomain(struct root_domain *rd) | 7956 | static void free_rootdomain(struct root_domain *rd) |
7872 | { | 7957 | { |
7958 | synchronize_sched(); | ||
7959 | |||
7873 | cpupri_cleanup(&rd->cpupri); | 7960 | cpupri_cleanup(&rd->cpupri); |
7874 | 7961 | ||
7875 | free_cpumask_var(rd->rto_mask); | 7962 | free_cpumask_var(rd->rto_mask); |
@@ -8010,6 +8097,7 @@ static cpumask_var_t cpu_isolated_map; | |||
8010 | /* Setup the mask of cpus configured for isolated domains */ | 8097 | /* Setup the mask of cpus configured for isolated domains */ |
8011 | static int __init isolated_cpu_setup(char *str) | 8098 | static int __init isolated_cpu_setup(char *str) |
8012 | { | 8099 | { |
8100 | alloc_bootmem_cpumask_var(&cpu_isolated_map); | ||
8013 | cpulist_parse(str, cpu_isolated_map); | 8101 | cpulist_parse(str, cpu_isolated_map); |
8014 | return 1; | 8102 | return 1; |
8015 | } | 8103 | } |
@@ -8846,7 +8934,7 @@ static int build_sched_domains(const struct cpumask *cpu_map) | |||
8846 | return __build_sched_domains(cpu_map, NULL); | 8934 | return __build_sched_domains(cpu_map, NULL); |
8847 | } | 8935 | } |
8848 | 8936 | ||
8849 | static struct cpumask *doms_cur; /* current sched domains */ | 8937 | static cpumask_var_t *doms_cur; /* current sched domains */ |
8850 | static int ndoms_cur; /* number of sched domains in 'doms_cur' */ | 8938 | static int ndoms_cur; /* number of sched domains in 'doms_cur' */ |
8851 | static struct sched_domain_attr *dattr_cur; | 8939 | static struct sched_domain_attr *dattr_cur; |
8852 | /* attribues of custom domains in 'doms_cur' */ | 8940 | /* attribues of custom domains in 'doms_cur' */ |
@@ -8868,6 +8956,31 @@ int __attribute__((weak)) arch_update_cpu_topology(void) | |||
8868 | return 0; | 8956 | return 0; |
8869 | } | 8957 | } |
8870 | 8958 | ||
8959 | cpumask_var_t *alloc_sched_domains(unsigned int ndoms) | ||
8960 | { | ||
8961 | int i; | ||
8962 | cpumask_var_t *doms; | ||
8963 | |||
8964 | doms = kmalloc(sizeof(*doms) * ndoms, GFP_KERNEL); | ||
8965 | if (!doms) | ||
8966 | return NULL; | ||
8967 | for (i = 0; i < ndoms; i++) { | ||
8968 | if (!alloc_cpumask_var(&doms[i], GFP_KERNEL)) { | ||
8969 | free_sched_domains(doms, i); | ||
8970 | return NULL; | ||
8971 | } | ||
8972 | } | ||
8973 | return doms; | ||
8974 | } | ||
8975 | |||
8976 | void free_sched_domains(cpumask_var_t doms[], unsigned int ndoms) | ||
8977 | { | ||
8978 | unsigned int i; | ||
8979 | for (i = 0; i < ndoms; i++) | ||
8980 | free_cpumask_var(doms[i]); | ||
8981 | kfree(doms); | ||
8982 | } | ||
8983 | |||
8871 | /* | 8984 | /* |
8872 | * Set up scheduler domains and groups. Callers must hold the hotplug lock. | 8985 | * Set up scheduler domains and groups. Callers must hold the hotplug lock. |
8873 | * For now this just excludes isolated cpus, but could be used to | 8986 | * For now this just excludes isolated cpus, but could be used to |
@@ -8879,12 +8992,12 @@ static int arch_init_sched_domains(const struct cpumask *cpu_map) | |||
8879 | 8992 | ||
8880 | arch_update_cpu_topology(); | 8993 | arch_update_cpu_topology(); |
8881 | ndoms_cur = 1; | 8994 | ndoms_cur = 1; |
8882 | doms_cur = kmalloc(cpumask_size(), GFP_KERNEL); | 8995 | doms_cur = alloc_sched_domains(ndoms_cur); |
8883 | if (!doms_cur) | 8996 | if (!doms_cur) |
8884 | doms_cur = fallback_doms; | 8997 | doms_cur = &fallback_doms; |
8885 | cpumask_andnot(doms_cur, cpu_map, cpu_isolated_map); | 8998 | cpumask_andnot(doms_cur[0], cpu_map, cpu_isolated_map); |
8886 | dattr_cur = NULL; | 8999 | dattr_cur = NULL; |
8887 | err = build_sched_domains(doms_cur); | 9000 | err = build_sched_domains(doms_cur[0]); |
8888 | register_sched_domain_sysctl(); | 9001 | register_sched_domain_sysctl(); |
8889 | 9002 | ||
8890 | return err; | 9003 | return err; |
@@ -8934,19 +9047,19 @@ static int dattrs_equal(struct sched_domain_attr *cur, int idx_cur, | |||
8934 | * doms_new[] to the current sched domain partitioning, doms_cur[]. | 9047 | * doms_new[] to the current sched domain partitioning, doms_cur[]. |
8935 | * It destroys each deleted domain and builds each new domain. | 9048 | * It destroys each deleted domain and builds each new domain. |
8936 | * | 9049 | * |
8937 | * 'doms_new' is an array of cpumask's of length 'ndoms_new'. | 9050 | * 'doms_new' is an array of cpumask_var_t's of length 'ndoms_new'. |
8938 | * The masks don't intersect (don't overlap.) We should setup one | 9051 | * The masks don't intersect (don't overlap.) We should setup one |
8939 | * sched domain for each mask. CPUs not in any of the cpumasks will | 9052 | * sched domain for each mask. CPUs not in any of the cpumasks will |
8940 | * not be load balanced. If the same cpumask appears both in the | 9053 | * not be load balanced. If the same cpumask appears both in the |
8941 | * current 'doms_cur' domains and in the new 'doms_new', we can leave | 9054 | * current 'doms_cur' domains and in the new 'doms_new', we can leave |
8942 | * it as it is. | 9055 | * it as it is. |
8943 | * | 9056 | * |
8944 | * The passed in 'doms_new' should be kmalloc'd. This routine takes | 9057 | * The passed in 'doms_new' should be allocated using |
8945 | * ownership of it and will kfree it when done with it. If the caller | 9058 | * alloc_sched_domains. This routine takes ownership of it and will |
8946 | * failed the kmalloc call, then it can pass in doms_new == NULL && | 9059 | * free_sched_domains it when done with it. If the caller failed the |
8947 | * ndoms_new == 1, and partition_sched_domains() will fallback to | 9060 | * alloc call, then it can pass in doms_new == NULL && ndoms_new == 1, |
8948 | * the single partition 'fallback_doms', it also forces the domains | 9061 | * and partition_sched_domains() will fallback to the single partition |
8949 | * to be rebuilt. | 9062 | * 'fallback_doms', it also forces the domains to be rebuilt. |
8950 | * | 9063 | * |
8951 | * If doms_new == NULL it will be replaced with cpu_online_mask. | 9064 | * If doms_new == NULL it will be replaced with cpu_online_mask. |
8952 | * ndoms_new == 0 is a special case for destroying existing domains, | 9065 | * ndoms_new == 0 is a special case for destroying existing domains, |
@@ -8954,8 +9067,7 @@ static int dattrs_equal(struct sched_domain_attr *cur, int idx_cur, | |||
8954 | * | 9067 | * |
8955 | * Call with hotplug lock held | 9068 | * Call with hotplug lock held |
8956 | */ | 9069 | */ |
8957 | /* FIXME: Change to struct cpumask *doms_new[] */ | 9070 | void partition_sched_domains(int ndoms_new, cpumask_var_t doms_new[], |
8958 | void partition_sched_domains(int ndoms_new, struct cpumask *doms_new, | ||
8959 | struct sched_domain_attr *dattr_new) | 9071 | struct sched_domain_attr *dattr_new) |
8960 | { | 9072 | { |
8961 | int i, j, n; | 9073 | int i, j, n; |
@@ -8974,40 +9086,40 @@ void partition_sched_domains(int ndoms_new, struct cpumask *doms_new, | |||
8974 | /* Destroy deleted domains */ | 9086 | /* Destroy deleted domains */ |
8975 | for (i = 0; i < ndoms_cur; i++) { | 9087 | for (i = 0; i < ndoms_cur; i++) { |
8976 | for (j = 0; j < n && !new_topology; j++) { | 9088 | for (j = 0; j < n && !new_topology; j++) { |
8977 | if (cpumask_equal(&doms_cur[i], &doms_new[j]) | 9089 | if (cpumask_equal(doms_cur[i], doms_new[j]) |
8978 | && dattrs_equal(dattr_cur, i, dattr_new, j)) | 9090 | && dattrs_equal(dattr_cur, i, dattr_new, j)) |
8979 | goto match1; | 9091 | goto match1; |
8980 | } | 9092 | } |
8981 | /* no match - a current sched domain not in new doms_new[] */ | 9093 | /* no match - a current sched domain not in new doms_new[] */ |
8982 | detach_destroy_domains(doms_cur + i); | 9094 | detach_destroy_domains(doms_cur[i]); |
8983 | match1: | 9095 | match1: |
8984 | ; | 9096 | ; |
8985 | } | 9097 | } |
8986 | 9098 | ||
8987 | if (doms_new == NULL) { | 9099 | if (doms_new == NULL) { |
8988 | ndoms_cur = 0; | 9100 | ndoms_cur = 0; |
8989 | doms_new = fallback_doms; | 9101 | doms_new = &fallback_doms; |
8990 | cpumask_andnot(&doms_new[0], cpu_online_mask, cpu_isolated_map); | 9102 | cpumask_andnot(doms_new[0], cpu_online_mask, cpu_isolated_map); |
8991 | WARN_ON_ONCE(dattr_new); | 9103 | WARN_ON_ONCE(dattr_new); |
8992 | } | 9104 | } |
8993 | 9105 | ||
8994 | /* Build new domains */ | 9106 | /* Build new domains */ |
8995 | for (i = 0; i < ndoms_new; i++) { | 9107 | for (i = 0; i < ndoms_new; i++) { |
8996 | for (j = 0; j < ndoms_cur && !new_topology; j++) { | 9108 | for (j = 0; j < ndoms_cur && !new_topology; j++) { |
8997 | if (cpumask_equal(&doms_new[i], &doms_cur[j]) | 9109 | if (cpumask_equal(doms_new[i], doms_cur[j]) |
8998 | && dattrs_equal(dattr_new, i, dattr_cur, j)) | 9110 | && dattrs_equal(dattr_new, i, dattr_cur, j)) |
8999 | goto match2; | 9111 | goto match2; |
9000 | } | 9112 | } |
9001 | /* no match - add a new doms_new */ | 9113 | /* no match - add a new doms_new */ |
9002 | __build_sched_domains(doms_new + i, | 9114 | __build_sched_domains(doms_new[i], |
9003 | dattr_new ? dattr_new + i : NULL); | 9115 | dattr_new ? dattr_new + i : NULL); |
9004 | match2: | 9116 | match2: |
9005 | ; | 9117 | ; |
9006 | } | 9118 | } |
9007 | 9119 | ||
9008 | /* Remember the new sched domains */ | 9120 | /* Remember the new sched domains */ |
9009 | if (doms_cur != fallback_doms) | 9121 | if (doms_cur != &fallback_doms) |
9010 | kfree(doms_cur); | 9122 | free_sched_domains(doms_cur, ndoms_cur); |
9011 | kfree(dattr_cur); /* kfree(NULL) is safe */ | 9123 | kfree(dattr_cur); /* kfree(NULL) is safe */ |
9012 | doms_cur = doms_new; | 9124 | doms_cur = doms_new; |
9013 | dattr_cur = dattr_new; | 9125 | dattr_cur = dattr_new; |
@@ -9329,10 +9441,6 @@ void __init sched_init(void) | |||
9329 | #ifdef CONFIG_CPUMASK_OFFSTACK | 9441 | #ifdef CONFIG_CPUMASK_OFFSTACK |
9330 | alloc_size += num_possible_cpus() * cpumask_size(); | 9442 | alloc_size += num_possible_cpus() * cpumask_size(); |
9331 | #endif | 9443 | #endif |
9332 | /* | ||
9333 | * As sched_init() is called before page_alloc is setup, | ||
9334 | * we use alloc_bootmem(). | ||
9335 | */ | ||
9336 | if (alloc_size) { | 9444 | if (alloc_size) { |
9337 | ptr = (unsigned long)kzalloc(alloc_size, GFP_NOWAIT); | 9445 | ptr = (unsigned long)kzalloc(alloc_size, GFP_NOWAIT); |
9338 | 9446 | ||
@@ -9401,6 +9509,10 @@ void __init sched_init(void) | |||
9401 | #endif /* CONFIG_USER_SCHED */ | 9509 | #endif /* CONFIG_USER_SCHED */ |
9402 | #endif /* CONFIG_GROUP_SCHED */ | 9510 | #endif /* CONFIG_GROUP_SCHED */ |
9403 | 9511 | ||
9512 | #if defined CONFIG_FAIR_GROUP_SCHED && defined CONFIG_SMP | ||
9513 | update_shares_data = __alloc_percpu(nr_cpu_ids * sizeof(unsigned long), | ||
9514 | __alignof__(unsigned long)); | ||
9515 | #endif | ||
9404 | for_each_possible_cpu(i) { | 9516 | for_each_possible_cpu(i) { |
9405 | struct rq *rq; | 9517 | struct rq *rq; |
9406 | 9518 | ||
@@ -9483,6 +9595,8 @@ void __init sched_init(void) | |||
9483 | rq->cpu = i; | 9595 | rq->cpu = i; |
9484 | rq->online = 0; | 9596 | rq->online = 0; |
9485 | rq->migration_thread = NULL; | 9597 | rq->migration_thread = NULL; |
9598 | rq->idle_stamp = 0; | ||
9599 | rq->avg_idle = 2*sysctl_sched_migration_cost; | ||
9486 | INIT_LIST_HEAD(&rq->migration_queue); | 9600 | INIT_LIST_HEAD(&rq->migration_queue); |
9487 | rq_attach_root(rq, &def_root_domain); | 9601 | rq_attach_root(rq, &def_root_domain); |
9488 | #endif | 9602 | #endif |
@@ -9526,13 +9640,15 @@ void __init sched_init(void) | |||
9526 | current->sched_class = &fair_sched_class; | 9640 | current->sched_class = &fair_sched_class; |
9527 | 9641 | ||
9528 | /* Allocate the nohz_cpu_mask if CONFIG_CPUMASK_OFFSTACK */ | 9642 | /* Allocate the nohz_cpu_mask if CONFIG_CPUMASK_OFFSTACK */ |
9529 | alloc_cpumask_var(&nohz_cpu_mask, GFP_NOWAIT); | 9643 | zalloc_cpumask_var(&nohz_cpu_mask, GFP_NOWAIT); |
9530 | #ifdef CONFIG_SMP | 9644 | #ifdef CONFIG_SMP |
9531 | #ifdef CONFIG_NO_HZ | 9645 | #ifdef CONFIG_NO_HZ |
9532 | alloc_cpumask_var(&nohz.cpu_mask, GFP_NOWAIT); | 9646 | zalloc_cpumask_var(&nohz.cpu_mask, GFP_NOWAIT); |
9533 | alloc_cpumask_var(&nohz.ilb_grp_nohz_mask, GFP_NOWAIT); | 9647 | alloc_cpumask_var(&nohz.ilb_grp_nohz_mask, GFP_NOWAIT); |
9534 | #endif | 9648 | #endif |
9535 | alloc_cpumask_var(&cpu_isolated_map, GFP_NOWAIT); | 9649 | /* May be allocated at isolcpus cmdline parse time */ |
9650 | if (cpu_isolated_map == NULL) | ||
9651 | zalloc_cpumask_var(&cpu_isolated_map, GFP_NOWAIT); | ||
9536 | #endif /* SMP */ | 9652 | #endif /* SMP */ |
9537 | 9653 | ||
9538 | perf_event_init(); | 9654 | perf_event_init(); |
@@ -10862,6 +10978,7 @@ void synchronize_sched_expedited(void) | |||
10862 | spin_unlock_irqrestore(&rq->lock, flags); | 10978 | spin_unlock_irqrestore(&rq->lock, flags); |
10863 | } | 10979 | } |
10864 | rcu_expedited_state = RCU_EXPEDITED_STATE_IDLE; | 10980 | rcu_expedited_state = RCU_EXPEDITED_STATE_IDLE; |
10981 | synchronize_sched_expedited_count++; | ||
10865 | mutex_unlock(&rcu_sched_expedited_mutex); | 10982 | mutex_unlock(&rcu_sched_expedited_mutex); |
10866 | put_online_cpus(); | 10983 | put_online_cpus(); |
10867 | if (need_full_sync) | 10984 | if (need_full_sync) |