diff options
Diffstat (limited to 'kernel/sched.c')
-rw-r--r-- | kernel/sched.c | 56 |
1 files changed, 26 insertions, 30 deletions
diff --git a/kernel/sched.c b/kernel/sched.c index 8e2558c2ba6..11dd52780ad 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
@@ -3448,19 +3448,23 @@ find_busiest_queue(struct sched_group *group, enum cpu_idle_type idle, | |||
3448 | */ | 3448 | */ |
3449 | #define MAX_PINNED_INTERVAL 512 | 3449 | #define MAX_PINNED_INTERVAL 512 |
3450 | 3450 | ||
3451 | /* Working cpumask for load_balance and load_balance_newidle. */ | ||
3452 | static DEFINE_PER_CPU(cpumask_var_t, load_balance_tmpmask); | ||
3453 | |||
3451 | /* | 3454 | /* |
3452 | * Check this_cpu to ensure it is balanced within domain. Attempt to move | 3455 | * Check this_cpu to ensure it is balanced within domain. Attempt to move |
3453 | * tasks if there is an imbalance. | 3456 | * tasks if there is an imbalance. |
3454 | */ | 3457 | */ |
3455 | static int load_balance(int this_cpu, struct rq *this_rq, | 3458 | static int load_balance(int this_cpu, struct rq *this_rq, |
3456 | struct sched_domain *sd, enum cpu_idle_type idle, | 3459 | struct sched_domain *sd, enum cpu_idle_type idle, |
3457 | int *balance, struct cpumask *cpus) | 3460 | int *balance) |
3458 | { | 3461 | { |
3459 | int ld_moved, all_pinned = 0, active_balance = 0, sd_idle = 0; | 3462 | int ld_moved, all_pinned = 0, active_balance = 0, sd_idle = 0; |
3460 | struct sched_group *group; | 3463 | struct sched_group *group; |
3461 | unsigned long imbalance; | 3464 | unsigned long imbalance; |
3462 | struct rq *busiest; | 3465 | struct rq *busiest; |
3463 | unsigned long flags; | 3466 | unsigned long flags; |
3467 | struct cpumask *cpus = __get_cpu_var(load_balance_tmpmask); | ||
3464 | 3468 | ||
3465 | cpumask_setall(cpus); | 3469 | cpumask_setall(cpus); |
3466 | 3470 | ||
@@ -3615,8 +3619,7 @@ out: | |||
3615 | * this_rq is locked. | 3619 | * this_rq is locked. |
3616 | */ | 3620 | */ |
3617 | static int | 3621 | static int |
3618 | load_balance_newidle(int this_cpu, struct rq *this_rq, struct sched_domain *sd, | 3622 | load_balance_newidle(int this_cpu, struct rq *this_rq, struct sched_domain *sd) |
3619 | struct cpumask *cpus) | ||
3620 | { | 3623 | { |
3621 | struct sched_group *group; | 3624 | struct sched_group *group; |
3622 | struct rq *busiest = NULL; | 3625 | struct rq *busiest = NULL; |
@@ -3624,6 +3627,7 @@ load_balance_newidle(int this_cpu, struct rq *this_rq, struct sched_domain *sd, | |||
3624 | int ld_moved = 0; | 3627 | int ld_moved = 0; |
3625 | int sd_idle = 0; | 3628 | int sd_idle = 0; |
3626 | int all_pinned = 0; | 3629 | int all_pinned = 0; |
3630 | struct cpumask *cpus = __get_cpu_var(load_balance_tmpmask); | ||
3627 | 3631 | ||
3628 | cpumask_setall(cpus); | 3632 | cpumask_setall(cpus); |
3629 | 3633 | ||
@@ -3764,10 +3768,6 @@ static void idle_balance(int this_cpu, struct rq *this_rq) | |||
3764 | struct sched_domain *sd; | 3768 | struct sched_domain *sd; |
3765 | int pulled_task = 0; | 3769 | int pulled_task = 0; |
3766 | unsigned long next_balance = jiffies + HZ; | 3770 | unsigned long next_balance = jiffies + HZ; |
3767 | cpumask_var_t tmpmask; | ||
3768 | |||
3769 | if (!alloc_cpumask_var(&tmpmask, GFP_ATOMIC)) | ||
3770 | return; | ||
3771 | 3771 | ||
3772 | for_each_domain(this_cpu, sd) { | 3772 | for_each_domain(this_cpu, sd) { |
3773 | unsigned long interval; | 3773 | unsigned long interval; |
@@ -3778,7 +3778,7 @@ static void idle_balance(int this_cpu, struct rq *this_rq) | |||
3778 | if (sd->flags & SD_BALANCE_NEWIDLE) | 3778 | if (sd->flags & SD_BALANCE_NEWIDLE) |
3779 | /* If we've pulled tasks over stop searching: */ | 3779 | /* If we've pulled tasks over stop searching: */ |
3780 | pulled_task = load_balance_newidle(this_cpu, this_rq, | 3780 | pulled_task = load_balance_newidle(this_cpu, this_rq, |
3781 | sd, tmpmask); | 3781 | sd); |
3782 | 3782 | ||
3783 | interval = msecs_to_jiffies(sd->balance_interval); | 3783 | interval = msecs_to_jiffies(sd->balance_interval); |
3784 | if (time_after(next_balance, sd->last_balance + interval)) | 3784 | if (time_after(next_balance, sd->last_balance + interval)) |
@@ -3793,7 +3793,6 @@ static void idle_balance(int this_cpu, struct rq *this_rq) | |||
3793 | */ | 3793 | */ |
3794 | this_rq->next_balance = next_balance; | 3794 | this_rq->next_balance = next_balance; |
3795 | } | 3795 | } |
3796 | free_cpumask_var(tmpmask); | ||
3797 | } | 3796 | } |
3798 | 3797 | ||
3799 | /* | 3798 | /* |
@@ -3943,11 +3942,6 @@ static void rebalance_domains(int cpu, enum cpu_idle_type idle) | |||
3943 | unsigned long next_balance = jiffies + 60*HZ; | 3942 | unsigned long next_balance = jiffies + 60*HZ; |
3944 | int update_next_balance = 0; | 3943 | int update_next_balance = 0; |
3945 | int need_serialize; | 3944 | int need_serialize; |
3946 | cpumask_var_t tmp; | ||
3947 | |||
3948 | /* Fails alloc? Rebalancing probably not a priority right now. */ | ||
3949 | if (!alloc_cpumask_var(&tmp, GFP_ATOMIC)) | ||
3950 | return; | ||
3951 | 3945 | ||
3952 | for_each_domain(cpu, sd) { | 3946 | for_each_domain(cpu, sd) { |
3953 | if (!(sd->flags & SD_LOAD_BALANCE)) | 3947 | if (!(sd->flags & SD_LOAD_BALANCE)) |
@@ -3972,7 +3966,7 @@ static void rebalance_domains(int cpu, enum cpu_idle_type idle) | |||
3972 | } | 3966 | } |
3973 | 3967 | ||
3974 | if (time_after_eq(jiffies, sd->last_balance + interval)) { | 3968 | if (time_after_eq(jiffies, sd->last_balance + interval)) { |
3975 | if (load_balance(cpu, rq, sd, idle, &balance, tmp)) { | 3969 | if (load_balance(cpu, rq, sd, idle, &balance)) { |
3976 | /* | 3970 | /* |
3977 | * We've pulled tasks over so either we're no | 3971 | * We've pulled tasks over so either we're no |
3978 | * longer idle, or one of our SMT siblings is | 3972 | * longer idle, or one of our SMT siblings is |
@@ -4006,8 +4000,6 @@ out: | |||
4006 | */ | 4000 | */ |
4007 | if (likely(update_next_balance)) | 4001 | if (likely(update_next_balance)) |
4008 | rq->next_balance = next_balance; | 4002 | rq->next_balance = next_balance; |
4009 | |||
4010 | free_cpumask_var(tmp); | ||
4011 | } | 4003 | } |
4012 | 4004 | ||
4013 | /* | 4005 | /* |
@@ -5944,12 +5936,7 @@ void sched_show_task(struct task_struct *p) | |||
5944 | printk(KERN_CONT " %016lx ", thread_saved_pc(p)); | 5936 | printk(KERN_CONT " %016lx ", thread_saved_pc(p)); |
5945 | #endif | 5937 | #endif |
5946 | #ifdef CONFIG_DEBUG_STACK_USAGE | 5938 | #ifdef CONFIG_DEBUG_STACK_USAGE |
5947 | { | 5939 | free = stack_not_used(p); |
5948 | unsigned long *n = end_of_stack(p); | ||
5949 | while (!*n) | ||
5950 | n++; | ||
5951 | free = (unsigned long)n - (unsigned long)end_of_stack(p); | ||
5952 | } | ||
5953 | #endif | 5940 | #endif |
5954 | printk(KERN_CONT "%5lu %5d %6d\n", free, | 5941 | printk(KERN_CONT "%5lu %5d %6d\n", free, |
5955 | task_pid_nr(p), task_pid_nr(p->real_parent)); | 5942 | task_pid_nr(p), task_pid_nr(p->real_parent)); |
@@ -7254,7 +7241,7 @@ cpu_to_core_group(int cpu, const struct cpumask *cpu_map, | |||
7254 | { | 7241 | { |
7255 | int group; | 7242 | int group; |
7256 | 7243 | ||
7257 | cpumask_and(mask, &per_cpu(cpu_sibling_map, cpu), cpu_map); | 7244 | cpumask_and(mask, topology_thread_cpumask(cpu), cpu_map); |
7258 | group = cpumask_first(mask); | 7245 | group = cpumask_first(mask); |
7259 | if (sg) | 7246 | if (sg) |
7260 | *sg = &per_cpu(sched_group_core, group).sg; | 7247 | *sg = &per_cpu(sched_group_core, group).sg; |
@@ -7283,7 +7270,7 @@ cpu_to_phys_group(int cpu, const struct cpumask *cpu_map, | |||
7283 | cpumask_and(mask, cpu_coregroup_mask(cpu), cpu_map); | 7270 | cpumask_and(mask, cpu_coregroup_mask(cpu), cpu_map); |
7284 | group = cpumask_first(mask); | 7271 | group = cpumask_first(mask); |
7285 | #elif defined(CONFIG_SCHED_SMT) | 7272 | #elif defined(CONFIG_SCHED_SMT) |
7286 | cpumask_and(mask, &per_cpu(cpu_sibling_map, cpu), cpu_map); | 7273 | cpumask_and(mask, topology_thread_cpumask(cpu), cpu_map); |
7287 | group = cpumask_first(mask); | 7274 | group = cpumask_first(mask); |
7288 | #else | 7275 | #else |
7289 | group = cpu; | 7276 | group = cpu; |
@@ -7626,7 +7613,7 @@ static int __build_sched_domains(const struct cpumask *cpu_map, | |||
7626 | SD_INIT(sd, SIBLING); | 7613 | SD_INIT(sd, SIBLING); |
7627 | set_domain_attribute(sd, attr); | 7614 | set_domain_attribute(sd, attr); |
7628 | cpumask_and(sched_domain_span(sd), | 7615 | cpumask_and(sched_domain_span(sd), |
7629 | &per_cpu(cpu_sibling_map, i), cpu_map); | 7616 | topology_thread_cpumask(i), cpu_map); |
7630 | sd->parent = p; | 7617 | sd->parent = p; |
7631 | p->child = sd; | 7618 | p->child = sd; |
7632 | cpu_to_cpu_group(i, cpu_map, &sd->groups, tmpmask); | 7619 | cpu_to_cpu_group(i, cpu_map, &sd->groups, tmpmask); |
@@ -7637,7 +7624,7 @@ static int __build_sched_domains(const struct cpumask *cpu_map, | |||
7637 | /* Set up CPU (sibling) groups */ | 7624 | /* Set up CPU (sibling) groups */ |
7638 | for_each_cpu(i, cpu_map) { | 7625 | for_each_cpu(i, cpu_map) { |
7639 | cpumask_and(this_sibling_map, | 7626 | cpumask_and(this_sibling_map, |
7640 | &per_cpu(cpu_sibling_map, i), cpu_map); | 7627 | topology_thread_cpumask(i), cpu_map); |
7641 | if (i != cpumask_first(this_sibling_map)) | 7628 | if (i != cpumask_first(this_sibling_map)) |
7642 | continue; | 7629 | continue; |
7643 | 7630 | ||
@@ -8309,6 +8296,9 @@ void __init sched_init(void) | |||
8309 | #ifdef CONFIG_USER_SCHED | 8296 | #ifdef CONFIG_USER_SCHED |
8310 | alloc_size *= 2; | 8297 | alloc_size *= 2; |
8311 | #endif | 8298 | #endif |
8299 | #ifdef CONFIG_CPUMASK_OFFSTACK | ||
8300 | alloc_size += num_possible_cpus() * cpumask_size(); | ||
8301 | #endif | ||
8312 | /* | 8302 | /* |
8313 | * As sched_init() is called before page_alloc is setup, | 8303 | * As sched_init() is called before page_alloc is setup, |
8314 | * we use alloc_bootmem(). | 8304 | * we use alloc_bootmem(). |
@@ -8346,6 +8336,12 @@ void __init sched_init(void) | |||
8346 | ptr += nr_cpu_ids * sizeof(void **); | 8336 | ptr += nr_cpu_ids * sizeof(void **); |
8347 | #endif /* CONFIG_USER_SCHED */ | 8337 | #endif /* CONFIG_USER_SCHED */ |
8348 | #endif /* CONFIG_RT_GROUP_SCHED */ | 8338 | #endif /* CONFIG_RT_GROUP_SCHED */ |
8339 | #ifdef CONFIG_CPUMASK_OFFSTACK | ||
8340 | for_each_possible_cpu(i) { | ||
8341 | per_cpu(load_balance_tmpmask, i) = (void *)ptr; | ||
8342 | ptr += cpumask_size(); | ||
8343 | } | ||
8344 | #endif /* CONFIG_CPUMASK_OFFSTACK */ | ||
8349 | } | 8345 | } |
8350 | 8346 | ||
8351 | #ifdef CONFIG_SMP | 8347 | #ifdef CONFIG_SMP |
@@ -9490,7 +9486,7 @@ cpuacct_destroy(struct cgroup_subsys *ss, struct cgroup *cgrp) | |||
9490 | 9486 | ||
9491 | static u64 cpuacct_cpuusage_read(struct cpuacct *ca, int cpu) | 9487 | static u64 cpuacct_cpuusage_read(struct cpuacct *ca, int cpu) |
9492 | { | 9488 | { |
9493 | u64 *cpuusage = percpu_ptr(ca->cpuusage, cpu); | 9489 | u64 *cpuusage = per_cpu_ptr(ca->cpuusage, cpu); |
9494 | u64 data; | 9490 | u64 data; |
9495 | 9491 | ||
9496 | #ifndef CONFIG_64BIT | 9492 | #ifndef CONFIG_64BIT |
@@ -9509,7 +9505,7 @@ static u64 cpuacct_cpuusage_read(struct cpuacct *ca, int cpu) | |||
9509 | 9505 | ||
9510 | static void cpuacct_cpuusage_write(struct cpuacct *ca, int cpu, u64 val) | 9506 | static void cpuacct_cpuusage_write(struct cpuacct *ca, int cpu, u64 val) |
9511 | { | 9507 | { |
9512 | u64 *cpuusage = percpu_ptr(ca->cpuusage, cpu); | 9508 | u64 *cpuusage = per_cpu_ptr(ca->cpuusage, cpu); |
9513 | 9509 | ||
9514 | #ifndef CONFIG_64BIT | 9510 | #ifndef CONFIG_64BIT |
9515 | /* | 9511 | /* |
@@ -9605,7 +9601,7 @@ static void cpuacct_charge(struct task_struct *tsk, u64 cputime) | |||
9605 | ca = task_ca(tsk); | 9601 | ca = task_ca(tsk); |
9606 | 9602 | ||
9607 | for (; ca; ca = ca->parent) { | 9603 | for (; ca; ca = ca->parent) { |
9608 | u64 *cpuusage = percpu_ptr(ca->cpuusage, cpu); | 9604 | u64 *cpuusage = per_cpu_ptr(ca->cpuusage, cpu); |
9609 | *cpuusage += cputime; | 9605 | *cpuusage += cputime; |
9610 | } | 9606 | } |
9611 | } | 9607 | } |