diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-01-02 14:44:09 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-01-02 14:44:09 -0500 |
commit | b840d79631c882786925303c2b0f4fefc31845ed (patch) | |
tree | cda60a95d4507fe1321fc285af38982d7eb9693b /kernel | |
parent | 597b0d21626da4e6f09f132442caf0cc2b0eb47c (diff) | |
parent | c3d80000e3a812fe5a200d6bde755fbd7fa65481 (diff) |
Merge branch 'cpus4096-for-linus-2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'cpus4096-for-linus-2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (66 commits)
x86: export vector_used_by_percpu_irq
x86: use logical apicid in x2apic_cluster's x2apic_cpu_mask_to_apicid_and()
sched: nominate preferred wakeup cpu, fix
x86: fix lguest used_vectors breakage, -v2
x86: fix warning in arch/x86/kernel/io_apic.c
sched: fix warning in kernel/sched.c
sched: move test_sd_parent() to an SMP section of sched.h
sched: add SD_BALANCE_NEWIDLE at MC and CPU level for sched_mc>0
sched: activate active load balancing in new idle cpus
sched: bias task wakeups to preferred semi-idle packages
sched: nominate preferred wakeup cpu
sched: favour lower logical cpu number for sched_mc balance
sched: framework for sched_mc/smt_power_savings=N
sched: convert BALANCE_FOR_xx_POWER to inline functions
x86: use possible_cpus=NUM to extend the possible cpus allowed
x86: fix cpu_mask_to_apicid_and to include cpu_online_mask
x86: update io_apic.c to the new cpumask code
x86: Introduce topology_core_cpumask()/topology_thread_cpumask()
x86: xen: use smp_call_function_many()
x86: use work_on_cpu in x86/kernel/cpu/mcheck/mce_amd_64.c
...
Fixed up trivial conflict in kernel/time/tick-sched.c manually
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/cpu.c | 11 | ||||
-rw-r--r-- | kernel/cpuset.c | 4 | ||||
-rw-r--r-- | kernel/irq/chip.c | 2 | ||||
-rw-r--r-- | kernel/irq/manage.c | 22 | ||||
-rw-r--r-- | kernel/irq/migration.c | 14 | ||||
-rw-r--r-- | kernel/irq/proc.c | 29 | ||||
-rw-r--r-- | kernel/profile.c | 4 | ||||
-rw-r--r-- | kernel/rcuclassic.c | 2 | ||||
-rw-r--r-- | kernel/sched.c | 970 | ||||
-rw-r--r-- | kernel/sched_cpupri.c | 39 | ||||
-rw-r--r-- | kernel/sched_cpupri.h | 5 | ||||
-rw-r--r-- | kernel/sched_fair.c | 32 | ||||
-rw-r--r-- | kernel/sched_rt.c | 73 | ||||
-rw-r--r-- | kernel/sched_stats.h | 3 | ||||
-rw-r--r-- | kernel/taskstats.c | 2 | ||||
-rw-r--r-- | kernel/time/clockevents.c | 2 | ||||
-rw-r--r-- | kernel/time/tick-broadcast.c | 2 | ||||
-rw-r--r-- | kernel/time/tick-common.c | 12 | ||||
-rw-r--r-- | kernel/time/tick-sched.c | 10 | ||||
-rw-r--r-- | kernel/trace/trace.c | 4 |
20 files changed, 722 insertions, 520 deletions
diff --git a/kernel/cpu.c b/kernel/cpu.c index 8ea32e8d68b0..bae131a1211b 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c | |||
@@ -24,19 +24,20 @@ | |||
24 | cpumask_t cpu_present_map __read_mostly; | 24 | cpumask_t cpu_present_map __read_mostly; |
25 | EXPORT_SYMBOL(cpu_present_map); | 25 | EXPORT_SYMBOL(cpu_present_map); |
26 | 26 | ||
27 | #ifndef CONFIG_SMP | ||
28 | |||
29 | /* | 27 | /* |
30 | * Represents all cpu's that are currently online. | 28 | * Represents all cpu's that are currently online. |
31 | */ | 29 | */ |
32 | cpumask_t cpu_online_map __read_mostly = CPU_MASK_ALL; | 30 | cpumask_t cpu_online_map __read_mostly; |
33 | EXPORT_SYMBOL(cpu_online_map); | 31 | EXPORT_SYMBOL(cpu_online_map); |
34 | 32 | ||
33 | #ifdef CONFIG_INIT_ALL_POSSIBLE | ||
35 | cpumask_t cpu_possible_map __read_mostly = CPU_MASK_ALL; | 34 | cpumask_t cpu_possible_map __read_mostly = CPU_MASK_ALL; |
35 | #else | ||
36 | cpumask_t cpu_possible_map __read_mostly; | ||
37 | #endif | ||
36 | EXPORT_SYMBOL(cpu_possible_map); | 38 | EXPORT_SYMBOL(cpu_possible_map); |
37 | 39 | ||
38 | #else /* CONFIG_SMP */ | 40 | #ifdef CONFIG_SMP |
39 | |||
40 | /* Serializes the updates to cpu_online_map, cpu_present_map */ | 41 | /* Serializes the updates to cpu_online_map, cpu_present_map */ |
41 | static DEFINE_MUTEX(cpu_add_remove_lock); | 42 | static DEFINE_MUTEX(cpu_add_remove_lock); |
42 | 43 | ||
diff --git a/kernel/cpuset.c b/kernel/cpuset.c index 96c0ba13b8cd..39c1a4c1c5a9 100644 --- a/kernel/cpuset.c +++ b/kernel/cpuset.c | |||
@@ -896,7 +896,7 @@ static int update_cpumask(struct cpuset *cs, const char *buf) | |||
896 | if (!*buf) { | 896 | if (!*buf) { |
897 | cpus_clear(trialcs.cpus_allowed); | 897 | cpus_clear(trialcs.cpus_allowed); |
898 | } else { | 898 | } else { |
899 | retval = cpulist_parse(buf, trialcs.cpus_allowed); | 899 | retval = cpulist_parse(buf, &trialcs.cpus_allowed); |
900 | if (retval < 0) | 900 | if (retval < 0) |
901 | return retval; | 901 | return retval; |
902 | 902 | ||
@@ -1482,7 +1482,7 @@ static int cpuset_sprintf_cpulist(char *page, struct cpuset *cs) | |||
1482 | mask = cs->cpus_allowed; | 1482 | mask = cs->cpus_allowed; |
1483 | mutex_unlock(&callback_mutex); | 1483 | mutex_unlock(&callback_mutex); |
1484 | 1484 | ||
1485 | return cpulist_scnprintf(page, PAGE_SIZE, mask); | 1485 | return cpulist_scnprintf(page, PAGE_SIZE, &mask); |
1486 | } | 1486 | } |
1487 | 1487 | ||
1488 | static int cpuset_sprintf_memlist(char *page, struct cpuset *cs) | 1488 | static int cpuset_sprintf_memlist(char *page, struct cpuset *cs) |
diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c index 6eb3c7952b64..f63c706d25e1 100644 --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c | |||
@@ -46,7 +46,7 @@ void dynamic_irq_init(unsigned int irq) | |||
46 | desc->irq_count = 0; | 46 | desc->irq_count = 0; |
47 | desc->irqs_unhandled = 0; | 47 | desc->irqs_unhandled = 0; |
48 | #ifdef CONFIG_SMP | 48 | #ifdef CONFIG_SMP |
49 | cpus_setall(desc->affinity); | 49 | cpumask_setall(&desc->affinity); |
50 | #endif | 50 | #endif |
51 | spin_unlock_irqrestore(&desc->lock, flags); | 51 | spin_unlock_irqrestore(&desc->lock, flags); |
52 | } | 52 | } |
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index 540f6c49f3fa..61c4a9b62165 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c | |||
@@ -79,7 +79,7 @@ int irq_can_set_affinity(unsigned int irq) | |||
79 | * @cpumask: cpumask | 79 | * @cpumask: cpumask |
80 | * | 80 | * |
81 | */ | 81 | */ |
82 | int irq_set_affinity(unsigned int irq, cpumask_t cpumask) | 82 | int irq_set_affinity(unsigned int irq, const struct cpumask *cpumask) |
83 | { | 83 | { |
84 | struct irq_desc *desc = irq_to_desc(irq); | 84 | struct irq_desc *desc = irq_to_desc(irq); |
85 | unsigned long flags; | 85 | unsigned long flags; |
@@ -91,14 +91,14 @@ int irq_set_affinity(unsigned int irq, cpumask_t cpumask) | |||
91 | 91 | ||
92 | #ifdef CONFIG_GENERIC_PENDING_IRQ | 92 | #ifdef CONFIG_GENERIC_PENDING_IRQ |
93 | if (desc->status & IRQ_MOVE_PCNTXT || desc->status & IRQ_DISABLED) { | 93 | if (desc->status & IRQ_MOVE_PCNTXT || desc->status & IRQ_DISABLED) { |
94 | desc->affinity = cpumask; | 94 | cpumask_copy(&desc->affinity, cpumask); |
95 | desc->chip->set_affinity(irq, cpumask); | 95 | desc->chip->set_affinity(irq, cpumask); |
96 | } else { | 96 | } else { |
97 | desc->status |= IRQ_MOVE_PENDING; | 97 | desc->status |= IRQ_MOVE_PENDING; |
98 | desc->pending_mask = cpumask; | 98 | cpumask_copy(&desc->pending_mask, cpumask); |
99 | } | 99 | } |
100 | #else | 100 | #else |
101 | desc->affinity = cpumask; | 101 | cpumask_copy(&desc->affinity, cpumask); |
102 | desc->chip->set_affinity(irq, cpumask); | 102 | desc->chip->set_affinity(irq, cpumask); |
103 | #endif | 103 | #endif |
104 | desc->status |= IRQ_AFFINITY_SET; | 104 | desc->status |= IRQ_AFFINITY_SET; |
@@ -112,26 +112,24 @@ int irq_set_affinity(unsigned int irq, cpumask_t cpumask) | |||
112 | */ | 112 | */ |
113 | int do_irq_select_affinity(unsigned int irq, struct irq_desc *desc) | 113 | int do_irq_select_affinity(unsigned int irq, struct irq_desc *desc) |
114 | { | 114 | { |
115 | cpumask_t mask; | ||
116 | |||
117 | if (!irq_can_set_affinity(irq)) | 115 | if (!irq_can_set_affinity(irq)) |
118 | return 0; | 116 | return 0; |
119 | 117 | ||
120 | cpus_and(mask, cpu_online_map, irq_default_affinity); | ||
121 | |||
122 | /* | 118 | /* |
123 | * Preserve an userspace affinity setup, but make sure that | 119 | * Preserve an userspace affinity setup, but make sure that |
124 | * one of the targets is online. | 120 | * one of the targets is online. |
125 | */ | 121 | */ |
126 | if (desc->status & (IRQ_AFFINITY_SET | IRQ_NO_BALANCING)) { | 122 | if (desc->status & (IRQ_AFFINITY_SET | IRQ_NO_BALANCING)) { |
127 | if (cpus_intersects(desc->affinity, cpu_online_map)) | 123 | if (cpumask_any_and(&desc->affinity, cpu_online_mask) |
128 | mask = desc->affinity; | 124 | < nr_cpu_ids) |
125 | goto set_affinity; | ||
129 | else | 126 | else |
130 | desc->status &= ~IRQ_AFFINITY_SET; | 127 | desc->status &= ~IRQ_AFFINITY_SET; |
131 | } | 128 | } |
132 | 129 | ||
133 | desc->affinity = mask; | 130 | cpumask_and(&desc->affinity, cpu_online_mask, &irq_default_affinity); |
134 | desc->chip->set_affinity(irq, mask); | 131 | set_affinity: |
132 | desc->chip->set_affinity(irq, &desc->affinity); | ||
135 | 133 | ||
136 | return 0; | 134 | return 0; |
137 | } | 135 | } |
diff --git a/kernel/irq/migration.c b/kernel/irq/migration.c index 9db681d95814..bd72329e630c 100644 --- a/kernel/irq/migration.c +++ b/kernel/irq/migration.c | |||
@@ -4,7 +4,6 @@ | |||
4 | void move_masked_irq(int irq) | 4 | void move_masked_irq(int irq) |
5 | { | 5 | { |
6 | struct irq_desc *desc = irq_to_desc(irq); | 6 | struct irq_desc *desc = irq_to_desc(irq); |
7 | cpumask_t tmp; | ||
8 | 7 | ||
9 | if (likely(!(desc->status & IRQ_MOVE_PENDING))) | 8 | if (likely(!(desc->status & IRQ_MOVE_PENDING))) |
10 | return; | 9 | return; |
@@ -19,7 +18,7 @@ void move_masked_irq(int irq) | |||
19 | 18 | ||
20 | desc->status &= ~IRQ_MOVE_PENDING; | 19 | desc->status &= ~IRQ_MOVE_PENDING; |
21 | 20 | ||
22 | if (unlikely(cpus_empty(desc->pending_mask))) | 21 | if (unlikely(cpumask_empty(&desc->pending_mask))) |
23 | return; | 22 | return; |
24 | 23 | ||
25 | if (!desc->chip->set_affinity) | 24 | if (!desc->chip->set_affinity) |
@@ -27,8 +26,6 @@ void move_masked_irq(int irq) | |||
27 | 26 | ||
28 | assert_spin_locked(&desc->lock); | 27 | assert_spin_locked(&desc->lock); |
29 | 28 | ||
30 | cpus_and(tmp, desc->pending_mask, cpu_online_map); | ||
31 | |||
32 | /* | 29 | /* |
33 | * If there was a valid mask to work with, please | 30 | * If there was a valid mask to work with, please |
34 | * do the disable, re-program, enable sequence. | 31 | * do the disable, re-program, enable sequence. |
@@ -41,10 +38,13 @@ void move_masked_irq(int irq) | |||
41 | * For correct operation this depends on the caller | 38 | * For correct operation this depends on the caller |
42 | * masking the irqs. | 39 | * masking the irqs. |
43 | */ | 40 | */ |
44 | if (likely(!cpus_empty(tmp))) { | 41 | if (likely(cpumask_any_and(&desc->pending_mask, cpu_online_mask) |
45 | desc->chip->set_affinity(irq,tmp); | 42 | < nr_cpu_ids)) { |
43 | cpumask_and(&desc->affinity, | ||
44 | &desc->pending_mask, cpu_online_mask); | ||
45 | desc->chip->set_affinity(irq, &desc->affinity); | ||
46 | } | 46 | } |
47 | cpus_clear(desc->pending_mask); | 47 | cpumask_clear(&desc->pending_mask); |
48 | } | 48 | } |
49 | 49 | ||
50 | void move_native_irq(int irq) | 50 | void move_native_irq(int irq) |
diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c index f6b3440f05bc..d2c0e5ee53c5 100644 --- a/kernel/irq/proc.c +++ b/kernel/irq/proc.c | |||
@@ -40,33 +40,42 @@ static ssize_t irq_affinity_proc_write(struct file *file, | |||
40 | const char __user *buffer, size_t count, loff_t *pos) | 40 | const char __user *buffer, size_t count, loff_t *pos) |
41 | { | 41 | { |
42 | unsigned int irq = (int)(long)PDE(file->f_path.dentry->d_inode)->data; | 42 | unsigned int irq = (int)(long)PDE(file->f_path.dentry->d_inode)->data; |
43 | cpumask_t new_value; | 43 | cpumask_var_t new_value; |
44 | int err; | 44 | int err; |
45 | 45 | ||
46 | if (!irq_to_desc(irq)->chip->set_affinity || no_irq_affinity || | 46 | if (!irq_to_desc(irq)->chip->set_affinity || no_irq_affinity || |
47 | irq_balancing_disabled(irq)) | 47 | irq_balancing_disabled(irq)) |
48 | return -EIO; | 48 | return -EIO; |
49 | 49 | ||
50 | if (!alloc_cpumask_var(&new_value, GFP_KERNEL)) | ||
51 | return -ENOMEM; | ||
52 | |||
50 | err = cpumask_parse_user(buffer, count, new_value); | 53 | err = cpumask_parse_user(buffer, count, new_value); |
51 | if (err) | 54 | if (err) |
52 | return err; | 55 | goto free_cpumask; |
53 | 56 | ||
54 | if (!is_affinity_mask_valid(new_value)) | 57 | if (!is_affinity_mask_valid(*new_value)) { |
55 | return -EINVAL; | 58 | err = -EINVAL; |
59 | goto free_cpumask; | ||
60 | } | ||
56 | 61 | ||
57 | /* | 62 | /* |
58 | * Do not allow disabling IRQs completely - it's a too easy | 63 | * Do not allow disabling IRQs completely - it's a too easy |
59 | * way to make the system unusable accidentally :-) At least | 64 | * way to make the system unusable accidentally :-) At least |
60 | * one online CPU still has to be targeted. | 65 | * one online CPU still has to be targeted. |
61 | */ | 66 | */ |
62 | if (!cpus_intersects(new_value, cpu_online_map)) | 67 | if (!cpumask_intersects(new_value, cpu_online_mask)) { |
63 | /* Special case for empty set - allow the architecture | 68 | /* Special case for empty set - allow the architecture |
64 | code to set default SMP affinity. */ | 69 | code to set default SMP affinity. */ |
65 | return irq_select_affinity_usr(irq) ? -EINVAL : count; | 70 | err = irq_select_affinity_usr(irq) ? -EINVAL : count; |
66 | 71 | } else { | |
67 | irq_set_affinity(irq, new_value); | 72 | irq_set_affinity(irq, new_value); |
73 | err = count; | ||
74 | } | ||
68 | 75 | ||
69 | return count; | 76 | free_cpumask: |
77 | free_cpumask_var(new_value); | ||
78 | return err; | ||
70 | } | 79 | } |
71 | 80 | ||
72 | static int irq_affinity_proc_open(struct inode *inode, struct file *file) | 81 | static int irq_affinity_proc_open(struct inode *inode, struct file *file) |
@@ -95,7 +104,7 @@ static ssize_t default_affinity_write(struct file *file, | |||
95 | cpumask_t new_value; | 104 | cpumask_t new_value; |
96 | int err; | 105 | int err; |
97 | 106 | ||
98 | err = cpumask_parse_user(buffer, count, new_value); | 107 | err = cpumask_parse_user(buffer, count, &new_value); |
99 | if (err) | 108 | if (err) |
100 | return err; | 109 | return err; |
101 | 110 | ||
diff --git a/kernel/profile.c b/kernel/profile.c index 60adefb59b5e..4cb7d68fed82 100644 --- a/kernel/profile.c +++ b/kernel/profile.c | |||
@@ -442,7 +442,7 @@ void profile_tick(int type) | |||
442 | static int prof_cpu_mask_read_proc(char *page, char **start, off_t off, | 442 | static int prof_cpu_mask_read_proc(char *page, char **start, off_t off, |
443 | int count, int *eof, void *data) | 443 | int count, int *eof, void *data) |
444 | { | 444 | { |
445 | int len = cpumask_scnprintf(page, count, *(cpumask_t *)data); | 445 | int len = cpumask_scnprintf(page, count, (cpumask_t *)data); |
446 | if (count - len < 2) | 446 | if (count - len < 2) |
447 | return -EINVAL; | 447 | return -EINVAL; |
448 | len += sprintf(page + len, "\n"); | 448 | len += sprintf(page + len, "\n"); |
@@ -456,7 +456,7 @@ static int prof_cpu_mask_write_proc(struct file *file, | |||
456 | unsigned long full_count = count, err; | 456 | unsigned long full_count = count, err; |
457 | cpumask_t new_value; | 457 | cpumask_t new_value; |
458 | 458 | ||
459 | err = cpumask_parse_user(buffer, count, new_value); | 459 | err = cpumask_parse_user(buffer, count, &new_value); |
460 | if (err) | 460 | if (err) |
461 | return err; | 461 | return err; |
462 | 462 | ||
diff --git a/kernel/rcuclassic.c b/kernel/rcuclassic.c index e503a002f330..c03ca3e61919 100644 --- a/kernel/rcuclassic.c +++ b/kernel/rcuclassic.c | |||
@@ -393,7 +393,7 @@ static void rcu_start_batch(struct rcu_ctrlblk *rcp) | |||
393 | * unnecessarily. | 393 | * unnecessarily. |
394 | */ | 394 | */ |
395 | smp_mb(); | 395 | smp_mb(); |
396 | cpus_andnot(rcp->cpumask, cpu_online_map, nohz_cpu_mask); | 396 | cpumask_andnot(&rcp->cpumask, cpu_online_mask, nohz_cpu_mask); |
397 | 397 | ||
398 | rcp->signaled = 0; | 398 | rcp->signaled = 0; |
399 | } | 399 | } |
diff --git a/kernel/sched.c b/kernel/sched.c index fff1c4a20b65..27ba1d642f0f 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
@@ -498,18 +498,26 @@ struct rt_rq { | |||
498 | */ | 498 | */ |
499 | struct root_domain { | 499 | struct root_domain { |
500 | atomic_t refcount; | 500 | atomic_t refcount; |
501 | cpumask_t span; | 501 | cpumask_var_t span; |
502 | cpumask_t online; | 502 | cpumask_var_t online; |
503 | 503 | ||
504 | /* | 504 | /* |
505 | * The "RT overload" flag: it gets set if a CPU has more than | 505 | * The "RT overload" flag: it gets set if a CPU has more than |
506 | * one runnable RT task. | 506 | * one runnable RT task. |
507 | */ | 507 | */ |
508 | cpumask_t rto_mask; | 508 | cpumask_var_t rto_mask; |
509 | atomic_t rto_count; | 509 | atomic_t rto_count; |
510 | #ifdef CONFIG_SMP | 510 | #ifdef CONFIG_SMP |
511 | struct cpupri cpupri; | 511 | struct cpupri cpupri; |
512 | #endif | 512 | #endif |
513 | #if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT) | ||
514 | /* | ||
515 | * Preferred wake up cpu nominated by sched_mc balance that will be | ||
516 | * used when most cpus are idle in the system indicating overall very | ||
517 | * low system utilisation. Triggered at POWERSAVINGS_BALANCE_WAKEUP(2) | ||
518 | */ | ||
519 | unsigned int sched_mc_preferred_wakeup_cpu; | ||
520 | #endif | ||
513 | }; | 521 | }; |
514 | 522 | ||
515 | /* | 523 | /* |
@@ -1514,7 +1522,7 @@ static int tg_shares_up(struct task_group *tg, void *data) | |||
1514 | struct sched_domain *sd = data; | 1522 | struct sched_domain *sd = data; |
1515 | int i; | 1523 | int i; |
1516 | 1524 | ||
1517 | for_each_cpu_mask(i, sd->span) { | 1525 | for_each_cpu(i, sched_domain_span(sd)) { |
1518 | /* | 1526 | /* |
1519 | * If there are currently no tasks on the cpu pretend there | 1527 | * If there are currently no tasks on the cpu pretend there |
1520 | * is one of average load so that when a new task gets to | 1528 | * is one of average load so that when a new task gets to |
@@ -1535,7 +1543,7 @@ static int tg_shares_up(struct task_group *tg, void *data) | |||
1535 | if (!sd->parent || !(sd->parent->flags & SD_LOAD_BALANCE)) | 1543 | if (!sd->parent || !(sd->parent->flags & SD_LOAD_BALANCE)) |
1536 | shares = tg->shares; | 1544 | shares = tg->shares; |
1537 | 1545 | ||
1538 | for_each_cpu_mask(i, sd->span) | 1546 | for_each_cpu(i, sched_domain_span(sd)) |
1539 | update_group_shares_cpu(tg, i, shares, rq_weight); | 1547 | update_group_shares_cpu(tg, i, shares, rq_weight); |
1540 | 1548 | ||
1541 | return 0; | 1549 | return 0; |
@@ -2101,15 +2109,17 @@ find_idlest_group(struct sched_domain *sd, struct task_struct *p, int this_cpu) | |||
2101 | int i; | 2109 | int i; |
2102 | 2110 | ||
2103 | /* Skip over this group if it has no CPUs allowed */ | 2111 | /* Skip over this group if it has no CPUs allowed */ |
2104 | if (!cpus_intersects(group->cpumask, p->cpus_allowed)) | 2112 | if (!cpumask_intersects(sched_group_cpus(group), |
2113 | &p->cpus_allowed)) | ||
2105 | continue; | 2114 | continue; |
2106 | 2115 | ||
2107 | local_group = cpu_isset(this_cpu, group->cpumask); | 2116 | local_group = cpumask_test_cpu(this_cpu, |
2117 | sched_group_cpus(group)); | ||
2108 | 2118 | ||
2109 | /* Tally up the load of all CPUs in the group */ | 2119 | /* Tally up the load of all CPUs in the group */ |
2110 | avg_load = 0; | 2120 | avg_load = 0; |
2111 | 2121 | ||
2112 | for_each_cpu_mask_nr(i, group->cpumask) { | 2122 | for_each_cpu(i, sched_group_cpus(group)) { |
2113 | /* Bias balancing toward cpus of our domain */ | 2123 | /* Bias balancing toward cpus of our domain */ |
2114 | if (local_group) | 2124 | if (local_group) |
2115 | load = source_load(i, load_idx); | 2125 | load = source_load(i, load_idx); |
@@ -2141,17 +2151,14 @@ find_idlest_group(struct sched_domain *sd, struct task_struct *p, int this_cpu) | |||
2141 | * find_idlest_cpu - find the idlest cpu among the cpus in group. | 2151 | * find_idlest_cpu - find the idlest cpu among the cpus in group. |
2142 | */ | 2152 | */ |
2143 | static int | 2153 | static int |
2144 | find_idlest_cpu(struct sched_group *group, struct task_struct *p, int this_cpu, | 2154 | find_idlest_cpu(struct sched_group *group, struct task_struct *p, int this_cpu) |
2145 | cpumask_t *tmp) | ||
2146 | { | 2155 | { |
2147 | unsigned long load, min_load = ULONG_MAX; | 2156 | unsigned long load, min_load = ULONG_MAX; |
2148 | int idlest = -1; | 2157 | int idlest = -1; |
2149 | int i; | 2158 | int i; |
2150 | 2159 | ||
2151 | /* Traverse only the allowed CPUs */ | 2160 | /* Traverse only the allowed CPUs */ |
2152 | cpus_and(*tmp, group->cpumask, p->cpus_allowed); | 2161 | for_each_cpu_and(i, sched_group_cpus(group), &p->cpus_allowed) { |
2153 | |||
2154 | for_each_cpu_mask_nr(i, *tmp) { | ||
2155 | load = weighted_cpuload(i); | 2162 | load = weighted_cpuload(i); |
2156 | 2163 | ||
2157 | if (load < min_load || (load == min_load && i == this_cpu)) { | 2164 | if (load < min_load || (load == min_load && i == this_cpu)) { |
@@ -2193,7 +2200,6 @@ static int sched_balance_self(int cpu, int flag) | |||
2193 | update_shares(sd); | 2200 | update_shares(sd); |
2194 | 2201 | ||
2195 | while (sd) { | 2202 | while (sd) { |
2196 | cpumask_t span, tmpmask; | ||
2197 | struct sched_group *group; | 2203 | struct sched_group *group; |
2198 | int new_cpu, weight; | 2204 | int new_cpu, weight; |
2199 | 2205 | ||
@@ -2202,14 +2208,13 @@ static int sched_balance_self(int cpu, int flag) | |||
2202 | continue; | 2208 | continue; |
2203 | } | 2209 | } |
2204 | 2210 | ||
2205 | span = sd->span; | ||
2206 | group = find_idlest_group(sd, t, cpu); | 2211 | group = find_idlest_group(sd, t, cpu); |
2207 | if (!group) { | 2212 | if (!group) { |
2208 | sd = sd->child; | 2213 | sd = sd->child; |
2209 | continue; | 2214 | continue; |
2210 | } | 2215 | } |
2211 | 2216 | ||
2212 | new_cpu = find_idlest_cpu(group, t, cpu, &tmpmask); | 2217 | new_cpu = find_idlest_cpu(group, t, cpu); |
2213 | if (new_cpu == -1 || new_cpu == cpu) { | 2218 | if (new_cpu == -1 || new_cpu == cpu) { |
2214 | /* Now try balancing at a lower domain level of cpu */ | 2219 | /* Now try balancing at a lower domain level of cpu */ |
2215 | sd = sd->child; | 2220 | sd = sd->child; |
@@ -2218,10 +2223,10 @@ static int sched_balance_self(int cpu, int flag) | |||
2218 | 2223 | ||
2219 | /* Now try balancing at a lower domain level of new_cpu */ | 2224 | /* Now try balancing at a lower domain level of new_cpu */ |
2220 | cpu = new_cpu; | 2225 | cpu = new_cpu; |
2226 | weight = cpumask_weight(sched_domain_span(sd)); | ||
2221 | sd = NULL; | 2227 | sd = NULL; |
2222 | weight = cpus_weight(span); | ||
2223 | for_each_domain(cpu, tmp) { | 2228 | for_each_domain(cpu, tmp) { |
2224 | if (weight <= cpus_weight(tmp->span)) | 2229 | if (weight <= cpumask_weight(sched_domain_span(tmp))) |
2225 | break; | 2230 | break; |
2226 | if (tmp->flags & flag) | 2231 | if (tmp->flags & flag) |
2227 | sd = tmp; | 2232 | sd = tmp; |
@@ -2266,7 +2271,7 @@ static int try_to_wake_up(struct task_struct *p, unsigned int state, int sync) | |||
2266 | cpu = task_cpu(p); | 2271 | cpu = task_cpu(p); |
2267 | 2272 | ||
2268 | for_each_domain(this_cpu, sd) { | 2273 | for_each_domain(this_cpu, sd) { |
2269 | if (cpu_isset(cpu, sd->span)) { | 2274 | if (cpumask_test_cpu(cpu, sched_domain_span(sd))) { |
2270 | update_shares(sd); | 2275 | update_shares(sd); |
2271 | break; | 2276 | break; |
2272 | } | 2277 | } |
@@ -2315,7 +2320,7 @@ static int try_to_wake_up(struct task_struct *p, unsigned int state, int sync) | |||
2315 | else { | 2320 | else { |
2316 | struct sched_domain *sd; | 2321 | struct sched_domain *sd; |
2317 | for_each_domain(this_cpu, sd) { | 2322 | for_each_domain(this_cpu, sd) { |
2318 | if (cpu_isset(cpu, sd->span)) { | 2323 | if (cpumask_test_cpu(cpu, sched_domain_span(sd))) { |
2319 | schedstat_inc(sd, ttwu_wake_remote); | 2324 | schedstat_inc(sd, ttwu_wake_remote); |
2320 | break; | 2325 | break; |
2321 | } | 2326 | } |
@@ -2846,7 +2851,7 @@ static void sched_migrate_task(struct task_struct *p, int dest_cpu) | |||
2846 | struct rq *rq; | 2851 | struct rq *rq; |
2847 | 2852 | ||
2848 | rq = task_rq_lock(p, &flags); | 2853 | rq = task_rq_lock(p, &flags); |
2849 | if (!cpu_isset(dest_cpu, p->cpus_allowed) | 2854 | if (!cpumask_test_cpu(dest_cpu, &p->cpus_allowed) |
2850 | || unlikely(!cpu_active(dest_cpu))) | 2855 | || unlikely(!cpu_active(dest_cpu))) |
2851 | goto out; | 2856 | goto out; |
2852 | 2857 | ||
@@ -2911,7 +2916,7 @@ int can_migrate_task(struct task_struct *p, struct rq *rq, int this_cpu, | |||
2911 | * 2) cannot be migrated to this CPU due to cpus_allowed, or | 2916 | * 2) cannot be migrated to this CPU due to cpus_allowed, or |
2912 | * 3) are cache-hot on their current CPU. | 2917 | * 3) are cache-hot on their current CPU. |
2913 | */ | 2918 | */ |
2914 | if (!cpu_isset(this_cpu, p->cpus_allowed)) { | 2919 | if (!cpumask_test_cpu(this_cpu, &p->cpus_allowed)) { |
2915 | schedstat_inc(p, se.nr_failed_migrations_affine); | 2920 | schedstat_inc(p, se.nr_failed_migrations_affine); |
2916 | return 0; | 2921 | return 0; |
2917 | } | 2922 | } |
@@ -3086,7 +3091,7 @@ static int move_one_task(struct rq *this_rq, int this_cpu, struct rq *busiest, | |||
3086 | static struct sched_group * | 3091 | static struct sched_group * |
3087 | find_busiest_group(struct sched_domain *sd, int this_cpu, | 3092 | find_busiest_group(struct sched_domain *sd, int this_cpu, |
3088 | unsigned long *imbalance, enum cpu_idle_type idle, | 3093 | unsigned long *imbalance, enum cpu_idle_type idle, |
3089 | int *sd_idle, const cpumask_t *cpus, int *balance) | 3094 | int *sd_idle, const struct cpumask *cpus, int *balance) |
3090 | { | 3095 | { |
3091 | struct sched_group *busiest = NULL, *this = NULL, *group = sd->groups; | 3096 | struct sched_group *busiest = NULL, *this = NULL, *group = sd->groups; |
3092 | unsigned long max_load, avg_load, total_load, this_load, total_pwr; | 3097 | unsigned long max_load, avg_load, total_load, this_load, total_pwr; |
@@ -3122,10 +3127,11 @@ find_busiest_group(struct sched_domain *sd, int this_cpu, | |||
3122 | unsigned long sum_avg_load_per_task; | 3127 | unsigned long sum_avg_load_per_task; |
3123 | unsigned long avg_load_per_task; | 3128 | unsigned long avg_load_per_task; |
3124 | 3129 | ||
3125 | local_group = cpu_isset(this_cpu, group->cpumask); | 3130 | local_group = cpumask_test_cpu(this_cpu, |
3131 | sched_group_cpus(group)); | ||
3126 | 3132 | ||
3127 | if (local_group) | 3133 | if (local_group) |
3128 | balance_cpu = first_cpu(group->cpumask); | 3134 | balance_cpu = cpumask_first(sched_group_cpus(group)); |
3129 | 3135 | ||
3130 | /* Tally up the load of all CPUs in the group */ | 3136 | /* Tally up the load of all CPUs in the group */ |
3131 | sum_weighted_load = sum_nr_running = avg_load = 0; | 3137 | sum_weighted_load = sum_nr_running = avg_load = 0; |
@@ -3134,13 +3140,8 @@ find_busiest_group(struct sched_domain *sd, int this_cpu, | |||
3134 | max_cpu_load = 0; | 3140 | max_cpu_load = 0; |
3135 | min_cpu_load = ~0UL; | 3141 | min_cpu_load = ~0UL; |
3136 | 3142 | ||
3137 | for_each_cpu_mask_nr(i, group->cpumask) { | 3143 | for_each_cpu_and(i, sched_group_cpus(group), cpus) { |
3138 | struct rq *rq; | 3144 | struct rq *rq = cpu_rq(i); |
3139 | |||
3140 | if (!cpu_isset(i, *cpus)) | ||
3141 | continue; | ||
3142 | |||
3143 | rq = cpu_rq(i); | ||
3144 | 3145 | ||
3145 | if (*sd_idle && rq->nr_running) | 3146 | if (*sd_idle && rq->nr_running) |
3146 | *sd_idle = 0; | 3147 | *sd_idle = 0; |
@@ -3251,8 +3252,8 @@ find_busiest_group(struct sched_domain *sd, int this_cpu, | |||
3251 | */ | 3252 | */ |
3252 | if ((sum_nr_running < min_nr_running) || | 3253 | if ((sum_nr_running < min_nr_running) || |
3253 | (sum_nr_running == min_nr_running && | 3254 | (sum_nr_running == min_nr_running && |
3254 | first_cpu(group->cpumask) < | 3255 | cpumask_first(sched_group_cpus(group)) > |
3255 | first_cpu(group_min->cpumask))) { | 3256 | cpumask_first(sched_group_cpus(group_min)))) { |
3256 | group_min = group; | 3257 | group_min = group; |
3257 | min_nr_running = sum_nr_running; | 3258 | min_nr_running = sum_nr_running; |
3258 | min_load_per_task = sum_weighted_load / | 3259 | min_load_per_task = sum_weighted_load / |
@@ -3267,8 +3268,8 @@ find_busiest_group(struct sched_domain *sd, int this_cpu, | |||
3267 | if (sum_nr_running <= group_capacity - 1) { | 3268 | if (sum_nr_running <= group_capacity - 1) { |
3268 | if (sum_nr_running > leader_nr_running || | 3269 | if (sum_nr_running > leader_nr_running || |
3269 | (sum_nr_running == leader_nr_running && | 3270 | (sum_nr_running == leader_nr_running && |
3270 | first_cpu(group->cpumask) > | 3271 | cpumask_first(sched_group_cpus(group)) < |
3271 | first_cpu(group_leader->cpumask))) { | 3272 | cpumask_first(sched_group_cpus(group_leader)))) { |
3272 | group_leader = group; | 3273 | group_leader = group; |
3273 | leader_nr_running = sum_nr_running; | 3274 | leader_nr_running = sum_nr_running; |
3274 | } | 3275 | } |
@@ -3394,6 +3395,10 @@ out_balanced: | |||
3394 | 3395 | ||
3395 | if (this == group_leader && group_leader != group_min) { | 3396 | if (this == group_leader && group_leader != group_min) { |
3396 | *imbalance = min_load_per_task; | 3397 | *imbalance = min_load_per_task; |
3398 | if (sched_mc_power_savings >= POWERSAVINGS_BALANCE_WAKEUP) { | ||
3399 | cpu_rq(this_cpu)->rd->sched_mc_preferred_wakeup_cpu = | ||
3400 | cpumask_first(sched_group_cpus(group_leader)); | ||
3401 | } | ||
3397 | return group_min; | 3402 | return group_min; |
3398 | } | 3403 | } |
3399 | #endif | 3404 | #endif |
@@ -3407,16 +3412,16 @@ ret: | |||
3407 | */ | 3412 | */ |
3408 | static struct rq * | 3413 | static struct rq * |
3409 | find_busiest_queue(struct sched_group *group, enum cpu_idle_type idle, | 3414 | find_busiest_queue(struct sched_group *group, enum cpu_idle_type idle, |
3410 | unsigned long imbalance, const cpumask_t *cpus) | 3415 | unsigned long imbalance, const struct cpumask *cpus) |
3411 | { | 3416 | { |
3412 | struct rq *busiest = NULL, *rq; | 3417 | struct rq *busiest = NULL, *rq; |
3413 | unsigned long max_load = 0; | 3418 | unsigned long max_load = 0; |
3414 | int i; | 3419 | int i; |
3415 | 3420 | ||
3416 | for_each_cpu_mask_nr(i, group->cpumask) { | 3421 | for_each_cpu(i, sched_group_cpus(group)) { |
3417 | unsigned long wl; | 3422 | unsigned long wl; |
3418 | 3423 | ||
3419 | if (!cpu_isset(i, *cpus)) | 3424 | if (!cpumask_test_cpu(i, cpus)) |
3420 | continue; | 3425 | continue; |
3421 | 3426 | ||
3422 | rq = cpu_rq(i); | 3427 | rq = cpu_rq(i); |
@@ -3446,7 +3451,7 @@ find_busiest_queue(struct sched_group *group, enum cpu_idle_type idle, | |||
3446 | */ | 3451 | */ |
3447 | static int load_balance(int this_cpu, struct rq *this_rq, | 3452 | static int load_balance(int this_cpu, struct rq *this_rq, |
3448 | struct sched_domain *sd, enum cpu_idle_type idle, | 3453 | struct sched_domain *sd, enum cpu_idle_type idle, |
3449 | int *balance, cpumask_t *cpus) | 3454 | int *balance, struct cpumask *cpus) |
3450 | { | 3455 | { |
3451 | int ld_moved, all_pinned = 0, active_balance = 0, sd_idle = 0; | 3456 | int ld_moved, all_pinned = 0, active_balance = 0, sd_idle = 0; |
3452 | struct sched_group *group; | 3457 | struct sched_group *group; |
@@ -3454,7 +3459,7 @@ static int load_balance(int this_cpu, struct rq *this_rq, | |||
3454 | struct rq *busiest; | 3459 | struct rq *busiest; |
3455 | unsigned long flags; | 3460 | unsigned long flags; |
3456 | 3461 | ||
3457 | cpus_setall(*cpus); | 3462 | cpumask_setall(cpus); |
3458 | 3463 | ||
3459 | /* | 3464 | /* |
3460 | * When power savings policy is enabled for the parent domain, idle | 3465 | * When power savings policy is enabled for the parent domain, idle |
@@ -3514,8 +3519,8 @@ redo: | |||
3514 | 3519 | ||
3515 | /* All tasks on this runqueue were pinned by CPU affinity */ | 3520 | /* All tasks on this runqueue were pinned by CPU affinity */ |
3516 | if (unlikely(all_pinned)) { | 3521 | if (unlikely(all_pinned)) { |
3517 | cpu_clear(cpu_of(busiest), *cpus); | 3522 | cpumask_clear_cpu(cpu_of(busiest), cpus); |
3518 | if (!cpus_empty(*cpus)) | 3523 | if (!cpumask_empty(cpus)) |
3519 | goto redo; | 3524 | goto redo; |
3520 | goto out_balanced; | 3525 | goto out_balanced; |
3521 | } | 3526 | } |
@@ -3532,7 +3537,8 @@ redo: | |||
3532 | /* don't kick the migration_thread, if the curr | 3537 | /* don't kick the migration_thread, if the curr |
3533 | * task on busiest cpu can't be moved to this_cpu | 3538 | * task on busiest cpu can't be moved to this_cpu |
3534 | */ | 3539 | */ |
3535 | if (!cpu_isset(this_cpu, busiest->curr->cpus_allowed)) { | 3540 | if (!cpumask_test_cpu(this_cpu, |
3541 | &busiest->curr->cpus_allowed)) { | ||
3536 | spin_unlock_irqrestore(&busiest->lock, flags); | 3542 | spin_unlock_irqrestore(&busiest->lock, flags); |
3537 | all_pinned = 1; | 3543 | all_pinned = 1; |
3538 | goto out_one_pinned; | 3544 | goto out_one_pinned; |
@@ -3607,7 +3613,7 @@ out: | |||
3607 | */ | 3613 | */ |
3608 | static int | 3614 | static int |
3609 | load_balance_newidle(int this_cpu, struct rq *this_rq, struct sched_domain *sd, | 3615 | load_balance_newidle(int this_cpu, struct rq *this_rq, struct sched_domain *sd, |
3610 | cpumask_t *cpus) | 3616 | struct cpumask *cpus) |
3611 | { | 3617 | { |
3612 | struct sched_group *group; | 3618 | struct sched_group *group; |
3613 | struct rq *busiest = NULL; | 3619 | struct rq *busiest = NULL; |
@@ -3616,7 +3622,7 @@ load_balance_newidle(int this_cpu, struct rq *this_rq, struct sched_domain *sd, | |||
3616 | int sd_idle = 0; | 3622 | int sd_idle = 0; |
3617 | int all_pinned = 0; | 3623 | int all_pinned = 0; |
3618 | 3624 | ||
3619 | cpus_setall(*cpus); | 3625 | cpumask_setall(cpus); |
3620 | 3626 | ||
3621 | /* | 3627 | /* |
3622 | * When power savings policy is enabled for the parent domain, idle | 3628 | * When power savings policy is enabled for the parent domain, idle |
@@ -3660,17 +3666,71 @@ redo: | |||
3660 | double_unlock_balance(this_rq, busiest); | 3666 | double_unlock_balance(this_rq, busiest); |
3661 | 3667 | ||
3662 | if (unlikely(all_pinned)) { | 3668 | if (unlikely(all_pinned)) { |
3663 | cpu_clear(cpu_of(busiest), *cpus); | 3669 | cpumask_clear_cpu(cpu_of(busiest), cpus); |
3664 | if (!cpus_empty(*cpus)) | 3670 | if (!cpumask_empty(cpus)) |
3665 | goto redo; | 3671 | goto redo; |
3666 | } | 3672 | } |
3667 | } | 3673 | } |
3668 | 3674 | ||
3669 | if (!ld_moved) { | 3675 | if (!ld_moved) { |
3676 | int active_balance = 0; | ||
3677 | |||
3670 | schedstat_inc(sd, lb_failed[CPU_NEWLY_IDLE]); | 3678 | schedstat_inc(sd, lb_failed[CPU_NEWLY_IDLE]); |
3671 | if (!sd_idle && sd->flags & SD_SHARE_CPUPOWER && | 3679 | if (!sd_idle && sd->flags & SD_SHARE_CPUPOWER && |
3672 | !test_sd_parent(sd, SD_POWERSAVINGS_BALANCE)) | 3680 | !test_sd_parent(sd, SD_POWERSAVINGS_BALANCE)) |
3673 | return -1; | 3681 | return -1; |
3682 | |||
3683 | if (sched_mc_power_savings < POWERSAVINGS_BALANCE_WAKEUP) | ||
3684 | return -1; | ||
3685 | |||
3686 | if (sd->nr_balance_failed++ < 2) | ||
3687 | return -1; | ||
3688 | |||
3689 | /* | ||
3690 | * The only task running in a non-idle cpu can be moved to this | ||
3691 | * cpu in an attempt to completely freeup the other CPU | ||
3692 | * package. The same method used to move task in load_balance() | ||
3693 | * have been extended for load_balance_newidle() to speedup | ||
3694 | * consolidation at sched_mc=POWERSAVINGS_BALANCE_WAKEUP (2) | ||
3695 | * | ||
3696 | * The package power saving logic comes from | ||
3697 | * find_busiest_group(). If there are no imbalance, then | ||
3698 | * f_b_g() will return NULL. However when sched_mc={1,2} then | ||
3699 | * f_b_g() will select a group from which a running task may be | ||
3700 | * pulled to this cpu in order to make the other package idle. | ||
3701 | * If there is no opportunity to make a package idle and if | ||
3702 | * there are no imbalance, then f_b_g() will return NULL and no | ||
3703 | * action will be taken in load_balance_newidle(). | ||
3704 | * | ||
3705 | * Under normal task pull operation due to imbalance, there | ||
3706 | * will be more than one task in the source run queue and | ||
3707 | * move_tasks() will succeed. ld_moved will be true and this | ||
3708 | * active balance code will not be triggered. | ||
3709 | */ | ||
3710 | |||
3711 | /* Lock busiest in correct order while this_rq is held */ | ||
3712 | double_lock_balance(this_rq, busiest); | ||
3713 | |||
3714 | /* | ||
3715 | * don't kick the migration_thread, if the curr | ||
3716 | * task on busiest cpu can't be moved to this_cpu | ||
3717 | */ | ||
3718 | if (!cpu_isset(this_cpu, busiest->curr->cpus_allowed)) { | ||
3719 | double_unlock_balance(this_rq, busiest); | ||
3720 | all_pinned = 1; | ||
3721 | return ld_moved; | ||
3722 | } | ||
3723 | |||
3724 | if (!busiest->active_balance) { | ||
3725 | busiest->active_balance = 1; | ||
3726 | busiest->push_cpu = this_cpu; | ||
3727 | active_balance = 1; | ||
3728 | } | ||
3729 | |||
3730 | double_unlock_balance(this_rq, busiest); | ||
3731 | if (active_balance) | ||
3732 | wake_up_process(busiest->migration_thread); | ||
3733 | |||
3674 | } else | 3734 | } else |
3675 | sd->nr_balance_failed = 0; | 3735 | sd->nr_balance_failed = 0; |
3676 | 3736 | ||
@@ -3696,7 +3756,10 @@ static void idle_balance(int this_cpu, struct rq *this_rq) | |||
3696 | struct sched_domain *sd; | 3756 | struct sched_domain *sd; |
3697 | int pulled_task = 0; | 3757 | int pulled_task = 0; |
3698 | unsigned long next_balance = jiffies + HZ; | 3758 | unsigned long next_balance = jiffies + HZ; |
3699 | cpumask_t tmpmask; | 3759 | cpumask_var_t tmpmask; |
3760 | |||
3761 | if (!alloc_cpumask_var(&tmpmask, GFP_ATOMIC)) | ||
3762 | return; | ||
3700 | 3763 | ||
3701 | for_each_domain(this_cpu, sd) { | 3764 | for_each_domain(this_cpu, sd) { |
3702 | unsigned long interval; | 3765 | unsigned long interval; |
@@ -3707,7 +3770,7 @@ static void idle_balance(int this_cpu, struct rq *this_rq) | |||
3707 | if (sd->flags & SD_BALANCE_NEWIDLE) | 3770 | if (sd->flags & SD_BALANCE_NEWIDLE) |
3708 | /* If we've pulled tasks over stop searching: */ | 3771 | /* If we've pulled tasks over stop searching: */ |
3709 | pulled_task = load_balance_newidle(this_cpu, this_rq, | 3772 | pulled_task = load_balance_newidle(this_cpu, this_rq, |
3710 | sd, &tmpmask); | 3773 | sd, tmpmask); |
3711 | 3774 | ||
3712 | interval = msecs_to_jiffies(sd->balance_interval); | 3775 | interval = msecs_to_jiffies(sd->balance_interval); |
3713 | if (time_after(next_balance, sd->last_balance + interval)) | 3776 | if (time_after(next_balance, sd->last_balance + interval)) |
@@ -3722,6 +3785,7 @@ static void idle_balance(int this_cpu, struct rq *this_rq) | |||
3722 | */ | 3785 | */ |
3723 | this_rq->next_balance = next_balance; | 3786 | this_rq->next_balance = next_balance; |
3724 | } | 3787 | } |
3788 | free_cpumask_var(tmpmask); | ||
3725 | } | 3789 | } |
3726 | 3790 | ||
3727 | /* | 3791 | /* |
@@ -3759,7 +3823,7 @@ static void active_load_balance(struct rq *busiest_rq, int busiest_cpu) | |||
3759 | /* Search for an sd spanning us and the target CPU. */ | 3823 | /* Search for an sd spanning us and the target CPU. */ |
3760 | for_each_domain(target_cpu, sd) { | 3824 | for_each_domain(target_cpu, sd) { |
3761 | if ((sd->flags & SD_LOAD_BALANCE) && | 3825 | if ((sd->flags & SD_LOAD_BALANCE) && |
3762 | cpu_isset(busiest_cpu, sd->span)) | 3826 | cpumask_test_cpu(busiest_cpu, sched_domain_span(sd))) |
3763 | break; | 3827 | break; |
3764 | } | 3828 | } |
3765 | 3829 | ||
@@ -3778,10 +3842,9 @@ static void active_load_balance(struct rq *busiest_rq, int busiest_cpu) | |||
3778 | #ifdef CONFIG_NO_HZ | 3842 | #ifdef CONFIG_NO_HZ |
3779 | static struct { | 3843 | static struct { |
3780 | atomic_t load_balancer; | 3844 | atomic_t load_balancer; |
3781 | cpumask_t cpu_mask; | 3845 | cpumask_var_t cpu_mask; |
3782 | } nohz ____cacheline_aligned = { | 3846 | } nohz ____cacheline_aligned = { |
3783 | .load_balancer = ATOMIC_INIT(-1), | 3847 | .load_balancer = ATOMIC_INIT(-1), |
3784 | .cpu_mask = CPU_MASK_NONE, | ||
3785 | }; | 3848 | }; |
3786 | 3849 | ||
3787 | /* | 3850 | /* |
@@ -3809,7 +3872,7 @@ int select_nohz_load_balancer(int stop_tick) | |||
3809 | int cpu = smp_processor_id(); | 3872 | int cpu = smp_processor_id(); |
3810 | 3873 | ||
3811 | if (stop_tick) { | 3874 | if (stop_tick) { |
3812 | cpu_set(cpu, nohz.cpu_mask); | 3875 | cpumask_set_cpu(cpu, nohz.cpu_mask); |
3813 | cpu_rq(cpu)->in_nohz_recently = 1; | 3876 | cpu_rq(cpu)->in_nohz_recently = 1; |
3814 | 3877 | ||
3815 | /* | 3878 | /* |
@@ -3823,7 +3886,7 @@ int select_nohz_load_balancer(int stop_tick) | |||
3823 | } | 3886 | } |
3824 | 3887 | ||
3825 | /* time for ilb owner also to sleep */ | 3888 | /* time for ilb owner also to sleep */ |
3826 | if (cpus_weight(nohz.cpu_mask) == num_online_cpus()) { | 3889 | if (cpumask_weight(nohz.cpu_mask) == num_online_cpus()) { |
3827 | if (atomic_read(&nohz.load_balancer) == cpu) | 3890 | if (atomic_read(&nohz.load_balancer) == cpu) |
3828 | atomic_set(&nohz.load_balancer, -1); | 3891 | atomic_set(&nohz.load_balancer, -1); |
3829 | return 0; | 3892 | return 0; |
@@ -3836,10 +3899,10 @@ int select_nohz_load_balancer(int stop_tick) | |||
3836 | } else if (atomic_read(&nohz.load_balancer) == cpu) | 3899 | } else if (atomic_read(&nohz.load_balancer) == cpu) |
3837 | return 1; | 3900 | return 1; |
3838 | } else { | 3901 | } else { |
3839 | if (!cpu_isset(cpu, nohz.cpu_mask)) | 3902 | if (!cpumask_test_cpu(cpu, nohz.cpu_mask)) |
3840 | return 0; | 3903 | return 0; |
3841 | 3904 | ||
3842 | cpu_clear(cpu, nohz.cpu_mask); | 3905 | cpumask_clear_cpu(cpu, nohz.cpu_mask); |
3843 | 3906 | ||
3844 | if (atomic_read(&nohz.load_balancer) == cpu) | 3907 | if (atomic_read(&nohz.load_balancer) == cpu) |
3845 | if (atomic_cmpxchg(&nohz.load_balancer, cpu, -1) != cpu) | 3908 | if (atomic_cmpxchg(&nohz.load_balancer, cpu, -1) != cpu) |
@@ -3867,7 +3930,11 @@ static void rebalance_domains(int cpu, enum cpu_idle_type idle) | |||
3867 | unsigned long next_balance = jiffies + 60*HZ; | 3930 | unsigned long next_balance = jiffies + 60*HZ; |
3868 | int update_next_balance = 0; | 3931 | int update_next_balance = 0; |
3869 | int need_serialize; | 3932 | int need_serialize; |
3870 | cpumask_t tmp; | 3933 | cpumask_var_t tmp; |
3934 | |||
3935 | /* Fails alloc? Rebalancing probably not a priority right now. */ | ||
3936 | if (!alloc_cpumask_var(&tmp, GFP_ATOMIC)) | ||
3937 | return; | ||
3871 | 3938 | ||
3872 | for_each_domain(cpu, sd) { | 3939 | for_each_domain(cpu, sd) { |
3873 | if (!(sd->flags & SD_LOAD_BALANCE)) | 3940 | if (!(sd->flags & SD_LOAD_BALANCE)) |
@@ -3892,7 +3959,7 @@ static void rebalance_domains(int cpu, enum cpu_idle_type idle) | |||
3892 | } | 3959 | } |
3893 | 3960 | ||
3894 | if (time_after_eq(jiffies, sd->last_balance + interval)) { | 3961 | if (time_after_eq(jiffies, sd->last_balance + interval)) { |
3895 | if (load_balance(cpu, rq, sd, idle, &balance, &tmp)) { | 3962 | if (load_balance(cpu, rq, sd, idle, &balance, tmp)) { |
3896 | /* | 3963 | /* |
3897 | * We've pulled tasks over so either we're no | 3964 | * We've pulled tasks over so either we're no |
3898 | * longer idle, or one of our SMT siblings is | 3965 | * longer idle, or one of our SMT siblings is |
@@ -3926,6 +3993,8 @@ out: | |||
3926 | */ | 3993 | */ |
3927 | if (likely(update_next_balance)) | 3994 | if (likely(update_next_balance)) |
3928 | rq->next_balance = next_balance; | 3995 | rq->next_balance = next_balance; |
3996 | |||
3997 | free_cpumask_var(tmp); | ||
3929 | } | 3998 | } |
3930 | 3999 | ||
3931 | /* | 4000 | /* |
@@ -3950,12 +4019,13 @@ static void run_rebalance_domains(struct softirq_action *h) | |||
3950 | */ | 4019 | */ |
3951 | if (this_rq->idle_at_tick && | 4020 | if (this_rq->idle_at_tick && |
3952 | atomic_read(&nohz.load_balancer) == this_cpu) { | 4021 | atomic_read(&nohz.load_balancer) == this_cpu) { |
3953 | cpumask_t cpus = nohz.cpu_mask; | ||
3954 | struct rq *rq; | 4022 | struct rq *rq; |
3955 | int balance_cpu; | 4023 | int balance_cpu; |
3956 | 4024 | ||
3957 | cpu_clear(this_cpu, cpus); | 4025 | for_each_cpu(balance_cpu, nohz.cpu_mask) { |
3958 | for_each_cpu_mask_nr(balance_cpu, cpus) { | 4026 | if (balance_cpu == this_cpu) |
4027 | continue; | ||
4028 | |||
3959 | /* | 4029 | /* |
3960 | * If this cpu gets work to do, stop the load balancing | 4030 | * If this cpu gets work to do, stop the load balancing |
3961 | * work being done for other cpus. Next load | 4031 | * work being done for other cpus. Next load |
@@ -3993,7 +4063,7 @@ static inline void trigger_load_balance(struct rq *rq, int cpu) | |||
3993 | rq->in_nohz_recently = 0; | 4063 | rq->in_nohz_recently = 0; |
3994 | 4064 | ||
3995 | if (atomic_read(&nohz.load_balancer) == cpu) { | 4065 | if (atomic_read(&nohz.load_balancer) == cpu) { |
3996 | cpu_clear(cpu, nohz.cpu_mask); | 4066 | cpumask_clear_cpu(cpu, nohz.cpu_mask); |
3997 | atomic_set(&nohz.load_balancer, -1); | 4067 | atomic_set(&nohz.load_balancer, -1); |
3998 | } | 4068 | } |
3999 | 4069 | ||
@@ -4006,7 +4076,7 @@ static inline void trigger_load_balance(struct rq *rq, int cpu) | |||
4006 | * TBD: Traverse the sched domains and nominate | 4076 | * TBD: Traverse the sched domains and nominate |
4007 | * the nearest cpu in the nohz.cpu_mask. | 4077 | * the nearest cpu in the nohz.cpu_mask. |
4008 | */ | 4078 | */ |
4009 | int ilb = first_cpu(nohz.cpu_mask); | 4079 | int ilb = cpumask_first(nohz.cpu_mask); |
4010 | 4080 | ||
4011 | if (ilb < nr_cpu_ids) | 4081 | if (ilb < nr_cpu_ids) |
4012 | resched_cpu(ilb); | 4082 | resched_cpu(ilb); |
@@ -4018,7 +4088,7 @@ static inline void trigger_load_balance(struct rq *rq, int cpu) | |||
4018 | * cpus with ticks stopped, is it time for that to stop? | 4088 | * cpus with ticks stopped, is it time for that to stop? |
4019 | */ | 4089 | */ |
4020 | if (rq->idle_at_tick && atomic_read(&nohz.load_balancer) == cpu && | 4090 | if (rq->idle_at_tick && atomic_read(&nohz.load_balancer) == cpu && |
4021 | cpus_weight(nohz.cpu_mask) == num_online_cpus()) { | 4091 | cpumask_weight(nohz.cpu_mask) == num_online_cpus()) { |
4022 | resched_cpu(cpu); | 4092 | resched_cpu(cpu); |
4023 | return; | 4093 | return; |
4024 | } | 4094 | } |
@@ -4028,7 +4098,7 @@ static inline void trigger_load_balance(struct rq *rq, int cpu) | |||
4028 | * someone else, then no need raise the SCHED_SOFTIRQ | 4098 | * someone else, then no need raise the SCHED_SOFTIRQ |
4029 | */ | 4099 | */ |
4030 | if (rq->idle_at_tick && atomic_read(&nohz.load_balancer) != cpu && | 4100 | if (rq->idle_at_tick && atomic_read(&nohz.load_balancer) != cpu && |
4031 | cpu_isset(cpu, nohz.cpu_mask)) | 4101 | cpumask_test_cpu(cpu, nohz.cpu_mask)) |
4032 | return; | 4102 | return; |
4033 | #endif | 4103 | #endif |
4034 | if (time_after_eq(jiffies, rq->next_balance)) | 4104 | if (time_after_eq(jiffies, rq->next_balance)) |
@@ -5401,10 +5471,9 @@ out_unlock: | |||
5401 | return retval; | 5471 | return retval; |
5402 | } | 5472 | } |
5403 | 5473 | ||
5404 | long sched_setaffinity(pid_t pid, const cpumask_t *in_mask) | 5474 | long sched_setaffinity(pid_t pid, const struct cpumask *in_mask) |
5405 | { | 5475 | { |
5406 | cpumask_t cpus_allowed; | 5476 | cpumask_var_t cpus_allowed, new_mask; |
5407 | cpumask_t new_mask = *in_mask; | ||
5408 | struct task_struct *p; | 5477 | struct task_struct *p; |
5409 | int retval; | 5478 | int retval; |
5410 | 5479 | ||
@@ -5426,6 +5495,14 @@ long sched_setaffinity(pid_t pid, const cpumask_t *in_mask) | |||
5426 | get_task_struct(p); | 5495 | get_task_struct(p); |
5427 | read_unlock(&tasklist_lock); | 5496 | read_unlock(&tasklist_lock); |
5428 | 5497 | ||
5498 | if (!alloc_cpumask_var(&cpus_allowed, GFP_KERNEL)) { | ||
5499 | retval = -ENOMEM; | ||
5500 | goto out_put_task; | ||
5501 | } | ||
5502 | if (!alloc_cpumask_var(&new_mask, GFP_KERNEL)) { | ||
5503 | retval = -ENOMEM; | ||
5504 | goto out_free_cpus_allowed; | ||
5505 | } | ||
5429 | retval = -EPERM; | 5506 | retval = -EPERM; |
5430 | if (!check_same_owner(p) && !capable(CAP_SYS_NICE)) | 5507 | if (!check_same_owner(p) && !capable(CAP_SYS_NICE)) |
5431 | goto out_unlock; | 5508 | goto out_unlock; |
@@ -5434,37 +5511,41 @@ long sched_setaffinity(pid_t pid, const cpumask_t *in_mask) | |||
5434 | if (retval) | 5511 | if (retval) |
5435 | goto out_unlock; | 5512 | goto out_unlock; |
5436 | 5513 | ||
5437 | cpuset_cpus_allowed(p, &cpus_allowed); | 5514 | cpuset_cpus_allowed(p, cpus_allowed); |
5438 | cpus_and(new_mask, new_mask, cpus_allowed); | 5515 | cpumask_and(new_mask, in_mask, cpus_allowed); |
5439 | again: | 5516 | again: |
5440 | retval = set_cpus_allowed_ptr(p, &new_mask); | 5517 | retval = set_cpus_allowed_ptr(p, new_mask); |
5441 | 5518 | ||
5442 | if (!retval) { | 5519 | if (!retval) { |
5443 | cpuset_cpus_allowed(p, &cpus_allowed); | 5520 | cpuset_cpus_allowed(p, cpus_allowed); |
5444 | if (!cpus_subset(new_mask, cpus_allowed)) { | 5521 | if (!cpumask_subset(new_mask, cpus_allowed)) { |
5445 | /* | 5522 | /* |
5446 | * We must have raced with a concurrent cpuset | 5523 | * We must have raced with a concurrent cpuset |
5447 | * update. Just reset the cpus_allowed to the | 5524 | * update. Just reset the cpus_allowed to the |
5448 | * cpuset's cpus_allowed | 5525 | * cpuset's cpus_allowed |
5449 | */ | 5526 | */ |
5450 | new_mask = cpus_allowed; | 5527 | cpumask_copy(new_mask, cpus_allowed); |
5451 | goto again; | 5528 | goto again; |
5452 | } | 5529 | } |
5453 | } | 5530 | } |
5454 | out_unlock: | 5531 | out_unlock: |
5532 | free_cpumask_var(new_mask); | ||
5533 | out_free_cpus_allowed: | ||
5534 | free_cpumask_var(cpus_allowed); | ||
5535 | out_put_task: | ||
5455 | put_task_struct(p); | 5536 | put_task_struct(p); |
5456 | put_online_cpus(); | 5537 | put_online_cpus(); |
5457 | return retval; | 5538 | return retval; |
5458 | } | 5539 | } |
5459 | 5540 | ||
5460 | static int get_user_cpu_mask(unsigned long __user *user_mask_ptr, unsigned len, | 5541 | static int get_user_cpu_mask(unsigned long __user *user_mask_ptr, unsigned len, |
5461 | cpumask_t *new_mask) | 5542 | struct cpumask *new_mask) |
5462 | { | 5543 | { |
5463 | if (len < sizeof(cpumask_t)) { | 5544 | if (len < cpumask_size()) |
5464 | memset(new_mask, 0, sizeof(cpumask_t)); | 5545 | cpumask_clear(new_mask); |
5465 | } else if (len > sizeof(cpumask_t)) { | 5546 | else if (len > cpumask_size()) |
5466 | len = sizeof(cpumask_t); | 5547 | len = cpumask_size(); |
5467 | } | 5548 | |
5468 | return copy_from_user(new_mask, user_mask_ptr, len) ? -EFAULT : 0; | 5549 | return copy_from_user(new_mask, user_mask_ptr, len) ? -EFAULT : 0; |
5469 | } | 5550 | } |
5470 | 5551 | ||
@@ -5477,17 +5558,20 @@ static int get_user_cpu_mask(unsigned long __user *user_mask_ptr, unsigned len, | |||
5477 | asmlinkage long sys_sched_setaffinity(pid_t pid, unsigned int len, | 5558 | asmlinkage long sys_sched_setaffinity(pid_t pid, unsigned int len, |
5478 | unsigned long __user *user_mask_ptr) | 5559 | unsigned long __user *user_mask_ptr) |
5479 | { | 5560 | { |
5480 | cpumask_t new_mask; | 5561 | cpumask_var_t new_mask; |
5481 | int retval; | 5562 | int retval; |
5482 | 5563 | ||
5483 | retval = get_user_cpu_mask(user_mask_ptr, len, &new_mask); | 5564 | if (!alloc_cpumask_var(&new_mask, GFP_KERNEL)) |
5484 | if (retval) | 5565 | return -ENOMEM; |
5485 | return retval; | ||
5486 | 5566 | ||
5487 | return sched_setaffinity(pid, &new_mask); | 5567 | retval = get_user_cpu_mask(user_mask_ptr, len, new_mask); |
5568 | if (retval == 0) | ||
5569 | retval = sched_setaffinity(pid, new_mask); | ||
5570 | free_cpumask_var(new_mask); | ||
5571 | return retval; | ||
5488 | } | 5572 | } |
5489 | 5573 | ||
5490 | long sched_getaffinity(pid_t pid, cpumask_t *mask) | 5574 | long sched_getaffinity(pid_t pid, struct cpumask *mask) |
5491 | { | 5575 | { |
5492 | struct task_struct *p; | 5576 | struct task_struct *p; |
5493 | int retval; | 5577 | int retval; |
@@ -5504,7 +5588,7 @@ long sched_getaffinity(pid_t pid, cpumask_t *mask) | |||
5504 | if (retval) | 5588 | if (retval) |
5505 | goto out_unlock; | 5589 | goto out_unlock; |
5506 | 5590 | ||
5507 | cpus_and(*mask, p->cpus_allowed, cpu_online_map); | 5591 | cpumask_and(mask, &p->cpus_allowed, cpu_online_mask); |
5508 | 5592 | ||
5509 | out_unlock: | 5593 | out_unlock: |
5510 | read_unlock(&tasklist_lock); | 5594 | read_unlock(&tasklist_lock); |
@@ -5523,19 +5607,24 @@ asmlinkage long sys_sched_getaffinity(pid_t pid, unsigned int len, | |||
5523 | unsigned long __user *user_mask_ptr) | 5607 | unsigned long __user *user_mask_ptr) |
5524 | { | 5608 | { |
5525 | int ret; | 5609 | int ret; |
5526 | cpumask_t mask; | 5610 | cpumask_var_t mask; |
5527 | 5611 | ||
5528 | if (len < sizeof(cpumask_t)) | 5612 | if (len < cpumask_size()) |
5529 | return -EINVAL; | 5613 | return -EINVAL; |
5530 | 5614 | ||
5531 | ret = sched_getaffinity(pid, &mask); | 5615 | if (!alloc_cpumask_var(&mask, GFP_KERNEL)) |
5532 | if (ret < 0) | 5616 | return -ENOMEM; |
5533 | return ret; | ||
5534 | 5617 | ||
5535 | if (copy_to_user(user_mask_ptr, &mask, sizeof(cpumask_t))) | 5618 | ret = sched_getaffinity(pid, mask); |
5536 | return -EFAULT; | 5619 | if (ret == 0) { |
5620 | if (copy_to_user(user_mask_ptr, mask, cpumask_size())) | ||
5621 | ret = -EFAULT; | ||
5622 | else | ||
5623 | ret = cpumask_size(); | ||
5624 | } | ||
5625 | free_cpumask_var(mask); | ||
5537 | 5626 | ||
5538 | return sizeof(cpumask_t); | 5627 | return ret; |
5539 | } | 5628 | } |
5540 | 5629 | ||
5541 | /** | 5630 | /** |
@@ -5877,7 +5966,7 @@ void __cpuinit init_idle(struct task_struct *idle, int cpu) | |||
5877 | idle->se.exec_start = sched_clock(); | 5966 | idle->se.exec_start = sched_clock(); |
5878 | 5967 | ||
5879 | idle->prio = idle->normal_prio = MAX_PRIO; | 5968 | idle->prio = idle->normal_prio = MAX_PRIO; |
5880 | idle->cpus_allowed = cpumask_of_cpu(cpu); | 5969 | cpumask_copy(&idle->cpus_allowed, cpumask_of(cpu)); |
5881 | __set_task_cpu(idle, cpu); | 5970 | __set_task_cpu(idle, cpu); |
5882 | 5971 | ||
5883 | rq->curr = rq->idle = idle; | 5972 | rq->curr = rq->idle = idle; |
@@ -5904,9 +5993,9 @@ void __cpuinit init_idle(struct task_struct *idle, int cpu) | |||
5904 | * indicates which cpus entered this state. This is used | 5993 | * indicates which cpus entered this state. This is used |
5905 | * in the rcu update to wait only for active cpus. For system | 5994 | * in the rcu update to wait only for active cpus. For system |
5906 | * which do not switch off the HZ timer nohz_cpu_mask should | 5995 | * which do not switch off the HZ timer nohz_cpu_mask should |
5907 | * always be CPU_MASK_NONE. | 5996 | * always be CPU_BITS_NONE. |
5908 | */ | 5997 | */ |
5909 | cpumask_t nohz_cpu_mask = CPU_MASK_NONE; | 5998 | cpumask_var_t nohz_cpu_mask; |
5910 | 5999 | ||
5911 | /* | 6000 | /* |
5912 | * Increase the granularity value when there are more CPUs, | 6001 | * Increase the granularity value when there are more CPUs, |
@@ -5961,7 +6050,7 @@ static inline void sched_init_granularity(void) | |||
5961 | * task must not exit() & deallocate itself prematurely. The | 6050 | * task must not exit() & deallocate itself prematurely. The |
5962 | * call is not atomic; no spinlocks may be held. | 6051 | * call is not atomic; no spinlocks may be held. |
5963 | */ | 6052 | */ |
5964 | int set_cpus_allowed_ptr(struct task_struct *p, const cpumask_t *new_mask) | 6053 | int set_cpus_allowed_ptr(struct task_struct *p, const struct cpumask *new_mask) |
5965 | { | 6054 | { |
5966 | struct migration_req req; | 6055 | struct migration_req req; |
5967 | unsigned long flags; | 6056 | unsigned long flags; |
@@ -5969,13 +6058,13 @@ int set_cpus_allowed_ptr(struct task_struct *p, const cpumask_t *new_mask) | |||
5969 | int ret = 0; | 6058 | int ret = 0; |
5970 | 6059 | ||
5971 | rq = task_rq_lock(p, &flags); | 6060 | rq = task_rq_lock(p, &flags); |
5972 | if (!cpus_intersects(*new_mask, cpu_online_map)) { | 6061 | if (!cpumask_intersects(new_mask, cpu_online_mask)) { |
5973 | ret = -EINVAL; | 6062 | ret = -EINVAL; |
5974 | goto out; | 6063 | goto out; |
5975 | } | 6064 | } |
5976 | 6065 | ||
5977 | if (unlikely((p->flags & PF_THREAD_BOUND) && p != current && | 6066 | if (unlikely((p->flags & PF_THREAD_BOUND) && p != current && |
5978 | !cpus_equal(p->cpus_allowed, *new_mask))) { | 6067 | !cpumask_equal(&p->cpus_allowed, new_mask))) { |
5979 | ret = -EINVAL; | 6068 | ret = -EINVAL; |
5980 | goto out; | 6069 | goto out; |
5981 | } | 6070 | } |
@@ -5983,15 +6072,15 @@ int set_cpus_allowed_ptr(struct task_struct *p, const cpumask_t *new_mask) | |||
5983 | if (p->sched_class->set_cpus_allowed) | 6072 | if (p->sched_class->set_cpus_allowed) |
5984 | p->sched_class->set_cpus_allowed(p, new_mask); | 6073 | p->sched_class->set_cpus_allowed(p, new_mask); |
5985 | else { | 6074 | else { |
5986 | p->cpus_allowed = *new_mask; | 6075 | cpumask_copy(&p->cpus_allowed, new_mask); |
5987 | p->rt.nr_cpus_allowed = cpus_weight(*new_mask); | 6076 | p->rt.nr_cpus_allowed = cpumask_weight(new_mask); |
5988 | } | 6077 | } |
5989 | 6078 | ||
5990 | /* Can the task run on the task's current CPU? If so, we're done */ | 6079 | /* Can the task run on the task's current CPU? If so, we're done */ |
5991 | if (cpu_isset(task_cpu(p), *new_mask)) | 6080 | if (cpumask_test_cpu(task_cpu(p), new_mask)) |
5992 | goto out; | 6081 | goto out; |
5993 | 6082 | ||
5994 | if (migrate_task(p, any_online_cpu(*new_mask), &req)) { | 6083 | if (migrate_task(p, cpumask_any_and(cpu_online_mask, new_mask), &req)) { |
5995 | /* Need help from migration thread: drop lock and wait. */ | 6084 | /* Need help from migration thread: drop lock and wait. */ |
5996 | task_rq_unlock(rq, &flags); | 6085 | task_rq_unlock(rq, &flags); |
5997 | wake_up_process(rq->migration_thread); | 6086 | wake_up_process(rq->migration_thread); |
@@ -6033,7 +6122,7 @@ static int __migrate_task(struct task_struct *p, int src_cpu, int dest_cpu) | |||
6033 | if (task_cpu(p) != src_cpu) | 6122 | if (task_cpu(p) != src_cpu) |
6034 | goto done; | 6123 | goto done; |
6035 | /* Affinity changed (again). */ | 6124 | /* Affinity changed (again). */ |
6036 | if (!cpu_isset(dest_cpu, p->cpus_allowed)) | 6125 | if (!cpumask_test_cpu(dest_cpu, &p->cpus_allowed)) |
6037 | goto fail; | 6126 | goto fail; |
6038 | 6127 | ||
6039 | on_rq = p->se.on_rq; | 6128 | on_rq = p->se.on_rq; |
@@ -6130,50 +6219,43 @@ static int __migrate_task_irq(struct task_struct *p, int src_cpu, int dest_cpu) | |||
6130 | */ | 6219 | */ |
6131 | static void move_task_off_dead_cpu(int dead_cpu, struct task_struct *p) | 6220 | static void move_task_off_dead_cpu(int dead_cpu, struct task_struct *p) |
6132 | { | 6221 | { |
6133 | unsigned long flags; | ||
6134 | cpumask_t mask; | ||
6135 | struct rq *rq; | ||
6136 | int dest_cpu; | 6222 | int dest_cpu; |
6223 | /* FIXME: Use cpumask_of_node here. */ | ||
6224 | cpumask_t _nodemask = node_to_cpumask(cpu_to_node(dead_cpu)); | ||
6225 | const struct cpumask *nodemask = &_nodemask; | ||
6226 | |||
6227 | again: | ||
6228 | /* Look for allowed, online CPU in same node. */ | ||
6229 | for_each_cpu_and(dest_cpu, nodemask, cpu_online_mask) | ||
6230 | if (cpumask_test_cpu(dest_cpu, &p->cpus_allowed)) | ||
6231 | goto move; | ||
6232 | |||
6233 | /* Any allowed, online CPU? */ | ||
6234 | dest_cpu = cpumask_any_and(&p->cpus_allowed, cpu_online_mask); | ||
6235 | if (dest_cpu < nr_cpu_ids) | ||
6236 | goto move; | ||
6237 | |||
6238 | /* No more Mr. Nice Guy. */ | ||
6239 | if (dest_cpu >= nr_cpu_ids) { | ||
6240 | cpuset_cpus_allowed_locked(p, &p->cpus_allowed); | ||
6241 | dest_cpu = cpumask_any_and(cpu_online_mask, &p->cpus_allowed); | ||
6137 | 6242 | ||
6138 | do { | 6243 | /* |
6139 | /* On same node? */ | 6244 | * Don't tell them about moving exiting tasks or |
6140 | mask = node_to_cpumask(cpu_to_node(dead_cpu)); | 6245 | * kernel threads (both mm NULL), since they never |
6141 | cpus_and(mask, mask, p->cpus_allowed); | 6246 | * leave kernel. |
6142 | dest_cpu = any_online_cpu(mask); | 6247 | */ |
6143 | 6248 | if (p->mm && printk_ratelimit()) { | |
6144 | /* On any allowed CPU? */ | 6249 | printk(KERN_INFO "process %d (%s) no " |
6145 | if (dest_cpu >= nr_cpu_ids) | 6250 | "longer affine to cpu%d\n", |
6146 | dest_cpu = any_online_cpu(p->cpus_allowed); | 6251 | task_pid_nr(p), p->comm, dead_cpu); |
6147 | |||
6148 | /* No more Mr. Nice Guy. */ | ||
6149 | if (dest_cpu >= nr_cpu_ids) { | ||
6150 | cpumask_t cpus_allowed; | ||
6151 | |||
6152 | cpuset_cpus_allowed_locked(p, &cpus_allowed); | ||
6153 | /* | ||
6154 | * Try to stay on the same cpuset, where the | ||
6155 | * current cpuset may be a subset of all cpus. | ||
6156 | * The cpuset_cpus_allowed_locked() variant of | ||
6157 | * cpuset_cpus_allowed() will not block. It must be | ||
6158 | * called within calls to cpuset_lock/cpuset_unlock. | ||
6159 | */ | ||
6160 | rq = task_rq_lock(p, &flags); | ||
6161 | p->cpus_allowed = cpus_allowed; | ||
6162 | dest_cpu = any_online_cpu(p->cpus_allowed); | ||
6163 | task_rq_unlock(rq, &flags); | ||
6164 | |||
6165 | /* | ||
6166 | * Don't tell them about moving exiting tasks or | ||
6167 | * kernel threads (both mm NULL), since they never | ||
6168 | * leave kernel. | ||
6169 | */ | ||
6170 | if (p->mm && printk_ratelimit()) { | ||
6171 | printk(KERN_INFO "process %d (%s) no " | ||
6172 | "longer affine to cpu%d\n", | ||
6173 | task_pid_nr(p), p->comm, dead_cpu); | ||
6174 | } | ||
6175 | } | 6252 | } |
6176 | } while (!__migrate_task_irq(p, dead_cpu, dest_cpu)); | 6253 | } |
6254 | |||
6255 | move: | ||
6256 | /* It can have affinity changed while we were choosing. */ | ||
6257 | if (unlikely(!__migrate_task_irq(p, dead_cpu, dest_cpu))) | ||
6258 | goto again; | ||
6177 | } | 6259 | } |
6178 | 6260 | ||
6179 | /* | 6261 | /* |
@@ -6185,7 +6267,7 @@ static void move_task_off_dead_cpu(int dead_cpu, struct task_struct *p) | |||
6185 | */ | 6267 | */ |
6186 | static void migrate_nr_uninterruptible(struct rq *rq_src) | 6268 | static void migrate_nr_uninterruptible(struct rq *rq_src) |
6187 | { | 6269 | { |
6188 | struct rq *rq_dest = cpu_rq(any_online_cpu(*CPU_MASK_ALL_PTR)); | 6270 | struct rq *rq_dest = cpu_rq(cpumask_any(cpu_online_mask)); |
6189 | unsigned long flags; | 6271 | unsigned long flags; |
6190 | 6272 | ||
6191 | local_irq_save(flags); | 6273 | local_irq_save(flags); |
@@ -6475,7 +6557,7 @@ static void set_rq_online(struct rq *rq) | |||
6475 | if (!rq->online) { | 6557 | if (!rq->online) { |
6476 | const struct sched_class *class; | 6558 | const struct sched_class *class; |
6477 | 6559 | ||
6478 | cpu_set(rq->cpu, rq->rd->online); | 6560 | cpumask_set_cpu(rq->cpu, rq->rd->online); |
6479 | rq->online = 1; | 6561 | rq->online = 1; |
6480 | 6562 | ||
6481 | for_each_class(class) { | 6563 | for_each_class(class) { |
@@ -6495,7 +6577,7 @@ static void set_rq_offline(struct rq *rq) | |||
6495 | class->rq_offline(rq); | 6577 | class->rq_offline(rq); |
6496 | } | 6578 | } |
6497 | 6579 | ||
6498 | cpu_clear(rq->cpu, rq->rd->online); | 6580 | cpumask_clear_cpu(rq->cpu, rq->rd->online); |
6499 | rq->online = 0; | 6581 | rq->online = 0; |
6500 | } | 6582 | } |
6501 | } | 6583 | } |
@@ -6536,7 +6618,7 @@ migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu) | |||
6536 | rq = cpu_rq(cpu); | 6618 | rq = cpu_rq(cpu); |
6537 | spin_lock_irqsave(&rq->lock, flags); | 6619 | spin_lock_irqsave(&rq->lock, flags); |
6538 | if (rq->rd) { | 6620 | if (rq->rd) { |
6539 | BUG_ON(!cpu_isset(cpu, rq->rd->span)); | 6621 | BUG_ON(!cpumask_test_cpu(cpu, rq->rd->span)); |
6540 | 6622 | ||
6541 | set_rq_online(rq); | 6623 | set_rq_online(rq); |
6542 | } | 6624 | } |
@@ -6550,7 +6632,7 @@ migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu) | |||
6550 | break; | 6632 | break; |
6551 | /* Unbind it from offline cpu so it can run. Fall thru. */ | 6633 | /* Unbind it from offline cpu so it can run. Fall thru. */ |
6552 | kthread_bind(cpu_rq(cpu)->migration_thread, | 6634 | kthread_bind(cpu_rq(cpu)->migration_thread, |
6553 | any_online_cpu(cpu_online_map)); | 6635 | cpumask_any(cpu_online_mask)); |
6554 | kthread_stop(cpu_rq(cpu)->migration_thread); | 6636 | kthread_stop(cpu_rq(cpu)->migration_thread); |
6555 | cpu_rq(cpu)->migration_thread = NULL; | 6637 | cpu_rq(cpu)->migration_thread = NULL; |
6556 | break; | 6638 | break; |
@@ -6600,7 +6682,7 @@ migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu) | |||
6600 | rq = cpu_rq(cpu); | 6682 | rq = cpu_rq(cpu); |
6601 | spin_lock_irqsave(&rq->lock, flags); | 6683 | spin_lock_irqsave(&rq->lock, flags); |
6602 | if (rq->rd) { | 6684 | if (rq->rd) { |
6603 | BUG_ON(!cpu_isset(cpu, rq->rd->span)); | 6685 | BUG_ON(!cpumask_test_cpu(cpu, rq->rd->span)); |
6604 | set_rq_offline(rq); | 6686 | set_rq_offline(rq); |
6605 | } | 6687 | } |
6606 | spin_unlock_irqrestore(&rq->lock, flags); | 6688 | spin_unlock_irqrestore(&rq->lock, flags); |
@@ -6639,13 +6721,13 @@ early_initcall(migration_init); | |||
6639 | #ifdef CONFIG_SCHED_DEBUG | 6721 | #ifdef CONFIG_SCHED_DEBUG |
6640 | 6722 | ||
6641 | static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level, | 6723 | static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level, |
6642 | cpumask_t *groupmask) | 6724 | struct cpumask *groupmask) |
6643 | { | 6725 | { |
6644 | struct sched_group *group = sd->groups; | 6726 | struct sched_group *group = sd->groups; |
6645 | char str[256]; | 6727 | char str[256]; |
6646 | 6728 | ||
6647 | cpulist_scnprintf(str, sizeof(str), sd->span); | 6729 | cpulist_scnprintf(str, sizeof(str), sched_domain_span(sd)); |
6648 | cpus_clear(*groupmask); | 6730 | cpumask_clear(groupmask); |
6649 | 6731 | ||
6650 | printk(KERN_DEBUG "%*s domain %d: ", level, "", level); | 6732 | printk(KERN_DEBUG "%*s domain %d: ", level, "", level); |
6651 | 6733 | ||
@@ -6659,11 +6741,11 @@ static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level, | |||
6659 | 6741 | ||
6660 | printk(KERN_CONT "span %s level %s\n", str, sd->name); | 6742 | printk(KERN_CONT "span %s level %s\n", str, sd->name); |
6661 | 6743 | ||
6662 | if (!cpu_isset(cpu, sd->span)) { | 6744 | if (!cpumask_test_cpu(cpu, sched_domain_span(sd))) { |
6663 | printk(KERN_ERR "ERROR: domain->span does not contain " | 6745 | printk(KERN_ERR "ERROR: domain->span does not contain " |
6664 | "CPU%d\n", cpu); | 6746 | "CPU%d\n", cpu); |
6665 | } | 6747 | } |
6666 | if (!cpu_isset(cpu, group->cpumask)) { | 6748 | if (!cpumask_test_cpu(cpu, sched_group_cpus(group))) { |
6667 | printk(KERN_ERR "ERROR: domain->groups does not contain" | 6749 | printk(KERN_ERR "ERROR: domain->groups does not contain" |
6668 | " CPU%d\n", cpu); | 6750 | " CPU%d\n", cpu); |
6669 | } | 6751 | } |
@@ -6683,31 +6765,32 @@ static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level, | |||
6683 | break; | 6765 | break; |
6684 | } | 6766 | } |
6685 | 6767 | ||
6686 | if (!cpus_weight(group->cpumask)) { | 6768 | if (!cpumask_weight(sched_group_cpus(group))) { |
6687 | printk(KERN_CONT "\n"); | 6769 | printk(KERN_CONT "\n"); |
6688 | printk(KERN_ERR "ERROR: empty group\n"); | 6770 | printk(KERN_ERR "ERROR: empty group\n"); |
6689 | break; | 6771 | break; |
6690 | } | 6772 | } |
6691 | 6773 | ||
6692 | if (cpus_intersects(*groupmask, group->cpumask)) { | 6774 | if (cpumask_intersects(groupmask, sched_group_cpus(group))) { |
6693 | printk(KERN_CONT "\n"); | 6775 | printk(KERN_CONT "\n"); |
6694 | printk(KERN_ERR "ERROR: repeated CPUs\n"); | 6776 | printk(KERN_ERR "ERROR: repeated CPUs\n"); |
6695 | break; | 6777 | break; |
6696 | } | 6778 | } |
6697 | 6779 | ||
6698 | cpus_or(*groupmask, *groupmask, group->cpumask); | 6780 | cpumask_or(groupmask, groupmask, sched_group_cpus(group)); |
6699 | 6781 | ||
6700 | cpulist_scnprintf(str, sizeof(str), group->cpumask); | 6782 | cpulist_scnprintf(str, sizeof(str), sched_group_cpus(group)); |
6701 | printk(KERN_CONT " %s", str); | 6783 | printk(KERN_CONT " %s", str); |
6702 | 6784 | ||
6703 | group = group->next; | 6785 | group = group->next; |
6704 | } while (group != sd->groups); | 6786 | } while (group != sd->groups); |
6705 | printk(KERN_CONT "\n"); | 6787 | printk(KERN_CONT "\n"); |
6706 | 6788 | ||
6707 | if (!cpus_equal(sd->span, *groupmask)) | 6789 | if (!cpumask_equal(sched_domain_span(sd), groupmask)) |
6708 | printk(KERN_ERR "ERROR: groups don't span domain->span\n"); | 6790 | printk(KERN_ERR "ERROR: groups don't span domain->span\n"); |
6709 | 6791 | ||
6710 | if (sd->parent && !cpus_subset(*groupmask, sd->parent->span)) | 6792 | if (sd->parent && |
6793 | !cpumask_subset(groupmask, sched_domain_span(sd->parent))) | ||
6711 | printk(KERN_ERR "ERROR: parent span is not a superset " | 6794 | printk(KERN_ERR "ERROR: parent span is not a superset " |
6712 | "of domain->span\n"); | 6795 | "of domain->span\n"); |
6713 | return 0; | 6796 | return 0; |
@@ -6715,7 +6798,7 @@ static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level, | |||
6715 | 6798 | ||
6716 | static void sched_domain_debug(struct sched_domain *sd, int cpu) | 6799 | static void sched_domain_debug(struct sched_domain *sd, int cpu) |
6717 | { | 6800 | { |
6718 | cpumask_t *groupmask; | 6801 | cpumask_var_t groupmask; |
6719 | int level = 0; | 6802 | int level = 0; |
6720 | 6803 | ||
6721 | if (!sd) { | 6804 | if (!sd) { |
@@ -6725,8 +6808,7 @@ static void sched_domain_debug(struct sched_domain *sd, int cpu) | |||
6725 | 6808 | ||
6726 | printk(KERN_DEBUG "CPU%d attaching sched-domain:\n", cpu); | 6809 | printk(KERN_DEBUG "CPU%d attaching sched-domain:\n", cpu); |
6727 | 6810 | ||
6728 | groupmask = kmalloc(sizeof(cpumask_t), GFP_KERNEL); | 6811 | if (!alloc_cpumask_var(&groupmask, GFP_KERNEL)) { |
6729 | if (!groupmask) { | ||
6730 | printk(KERN_DEBUG "Cannot load-balance (out of memory)\n"); | 6812 | printk(KERN_DEBUG "Cannot load-balance (out of memory)\n"); |
6731 | return; | 6813 | return; |
6732 | } | 6814 | } |
@@ -6739,7 +6821,7 @@ static void sched_domain_debug(struct sched_domain *sd, int cpu) | |||
6739 | if (!sd) | 6821 | if (!sd) |
6740 | break; | 6822 | break; |
6741 | } | 6823 | } |
6742 | kfree(groupmask); | 6824 | free_cpumask_var(groupmask); |
6743 | } | 6825 | } |
6744 | #else /* !CONFIG_SCHED_DEBUG */ | 6826 | #else /* !CONFIG_SCHED_DEBUG */ |
6745 | # define sched_domain_debug(sd, cpu) do { } while (0) | 6827 | # define sched_domain_debug(sd, cpu) do { } while (0) |
@@ -6747,7 +6829,7 @@ static void sched_domain_debug(struct sched_domain *sd, int cpu) | |||
6747 | 6829 | ||
6748 | static int sd_degenerate(struct sched_domain *sd) | 6830 | static int sd_degenerate(struct sched_domain *sd) |
6749 | { | 6831 | { |
6750 | if (cpus_weight(sd->span) == 1) | 6832 | if (cpumask_weight(sched_domain_span(sd)) == 1) |
6751 | return 1; | 6833 | return 1; |
6752 | 6834 | ||
6753 | /* Following flags need at least 2 groups */ | 6835 | /* Following flags need at least 2 groups */ |
@@ -6778,7 +6860,7 @@ sd_parent_degenerate(struct sched_domain *sd, struct sched_domain *parent) | |||
6778 | if (sd_degenerate(parent)) | 6860 | if (sd_degenerate(parent)) |
6779 | return 1; | 6861 | return 1; |
6780 | 6862 | ||
6781 | if (!cpus_equal(sd->span, parent->span)) | 6863 | if (!cpumask_equal(sched_domain_span(sd), sched_domain_span(parent))) |
6782 | return 0; | 6864 | return 0; |
6783 | 6865 | ||
6784 | /* Does parent contain flags not in child? */ | 6866 | /* Does parent contain flags not in child? */ |
@@ -6802,6 +6884,16 @@ sd_parent_degenerate(struct sched_domain *sd, struct sched_domain *parent) | |||
6802 | return 1; | 6884 | return 1; |
6803 | } | 6885 | } |
6804 | 6886 | ||
6887 | static void free_rootdomain(struct root_domain *rd) | ||
6888 | { | ||
6889 | cpupri_cleanup(&rd->cpupri); | ||
6890 | |||
6891 | free_cpumask_var(rd->rto_mask); | ||
6892 | free_cpumask_var(rd->online); | ||
6893 | free_cpumask_var(rd->span); | ||
6894 | kfree(rd); | ||
6895 | } | ||
6896 | |||
6805 | static void rq_attach_root(struct rq *rq, struct root_domain *rd) | 6897 | static void rq_attach_root(struct rq *rq, struct root_domain *rd) |
6806 | { | 6898 | { |
6807 | unsigned long flags; | 6899 | unsigned long flags; |
@@ -6811,38 +6903,63 @@ static void rq_attach_root(struct rq *rq, struct root_domain *rd) | |||
6811 | if (rq->rd) { | 6903 | if (rq->rd) { |
6812 | struct root_domain *old_rd = rq->rd; | 6904 | struct root_domain *old_rd = rq->rd; |
6813 | 6905 | ||
6814 | if (cpu_isset(rq->cpu, old_rd->online)) | 6906 | if (cpumask_test_cpu(rq->cpu, old_rd->online)) |
6815 | set_rq_offline(rq); | 6907 | set_rq_offline(rq); |
6816 | 6908 | ||
6817 | cpu_clear(rq->cpu, old_rd->span); | 6909 | cpumask_clear_cpu(rq->cpu, old_rd->span); |
6818 | 6910 | ||
6819 | if (atomic_dec_and_test(&old_rd->refcount)) | 6911 | if (atomic_dec_and_test(&old_rd->refcount)) |
6820 | kfree(old_rd); | 6912 | free_rootdomain(old_rd); |
6821 | } | 6913 | } |
6822 | 6914 | ||
6823 | atomic_inc(&rd->refcount); | 6915 | atomic_inc(&rd->refcount); |
6824 | rq->rd = rd; | 6916 | rq->rd = rd; |
6825 | 6917 | ||
6826 | cpu_set(rq->cpu, rd->span); | 6918 | cpumask_set_cpu(rq->cpu, rd->span); |
6827 | if (cpu_isset(rq->cpu, cpu_online_map)) | 6919 | if (cpumask_test_cpu(rq->cpu, cpu_online_mask)) |
6828 | set_rq_online(rq); | 6920 | set_rq_online(rq); |
6829 | 6921 | ||
6830 | spin_unlock_irqrestore(&rq->lock, flags); | 6922 | spin_unlock_irqrestore(&rq->lock, flags); |
6831 | } | 6923 | } |
6832 | 6924 | ||
6833 | static void init_rootdomain(struct root_domain *rd) | 6925 | static int init_rootdomain(struct root_domain *rd, bool bootmem) |
6834 | { | 6926 | { |
6835 | memset(rd, 0, sizeof(*rd)); | 6927 | memset(rd, 0, sizeof(*rd)); |
6836 | 6928 | ||
6837 | cpus_clear(rd->span); | 6929 | if (bootmem) { |
6838 | cpus_clear(rd->online); | 6930 | alloc_bootmem_cpumask_var(&def_root_domain.span); |
6931 | alloc_bootmem_cpumask_var(&def_root_domain.online); | ||
6932 | alloc_bootmem_cpumask_var(&def_root_domain.rto_mask); | ||
6933 | cpupri_init(&rd->cpupri, true); | ||
6934 | return 0; | ||
6935 | } | ||
6936 | |||
6937 | if (!alloc_cpumask_var(&rd->span, GFP_KERNEL)) | ||
6938 | goto free_rd; | ||
6939 | if (!alloc_cpumask_var(&rd->online, GFP_KERNEL)) | ||
6940 | goto free_span; | ||
6941 | if (!alloc_cpumask_var(&rd->rto_mask, GFP_KERNEL)) | ||
6942 | goto free_online; | ||
6943 | |||
6944 | if (cpupri_init(&rd->cpupri, false) != 0) | ||
6945 | goto free_rto_mask; | ||
6946 | return 0; | ||
6839 | 6947 | ||
6840 | cpupri_init(&rd->cpupri); | 6948 | free_rto_mask: |
6949 | free_cpumask_var(rd->rto_mask); | ||
6950 | free_online: | ||
6951 | free_cpumask_var(rd->online); | ||
6952 | free_span: | ||
6953 | free_cpumask_var(rd->span); | ||
6954 | free_rd: | ||
6955 | kfree(rd); | ||
6956 | return -ENOMEM; | ||
6841 | } | 6957 | } |
6842 | 6958 | ||
6843 | static void init_defrootdomain(void) | 6959 | static void init_defrootdomain(void) |
6844 | { | 6960 | { |
6845 | init_rootdomain(&def_root_domain); | 6961 | init_rootdomain(&def_root_domain, true); |
6962 | |||
6846 | atomic_set(&def_root_domain.refcount, 1); | 6963 | atomic_set(&def_root_domain.refcount, 1); |
6847 | } | 6964 | } |
6848 | 6965 | ||
@@ -6854,7 +6971,10 @@ static struct root_domain *alloc_rootdomain(void) | |||
6854 | if (!rd) | 6971 | if (!rd) |
6855 | return NULL; | 6972 | return NULL; |
6856 | 6973 | ||
6857 | init_rootdomain(rd); | 6974 | if (init_rootdomain(rd, false) != 0) { |
6975 | kfree(rd); | ||
6976 | return NULL; | ||
6977 | } | ||
6858 | 6978 | ||
6859 | return rd; | 6979 | return rd; |
6860 | } | 6980 | } |
@@ -6896,19 +7016,12 @@ cpu_attach_domain(struct sched_domain *sd, struct root_domain *rd, int cpu) | |||
6896 | } | 7016 | } |
6897 | 7017 | ||
6898 | /* cpus with isolated domains */ | 7018 | /* cpus with isolated domains */ |
6899 | static cpumask_t cpu_isolated_map = CPU_MASK_NONE; | 7019 | static cpumask_var_t cpu_isolated_map; |
6900 | 7020 | ||
6901 | /* Setup the mask of cpus configured for isolated domains */ | 7021 | /* Setup the mask of cpus configured for isolated domains */ |
6902 | static int __init isolated_cpu_setup(char *str) | 7022 | static int __init isolated_cpu_setup(char *str) |
6903 | { | 7023 | { |
6904 | static int __initdata ints[NR_CPUS]; | 7024 | cpulist_parse(str, cpu_isolated_map); |
6905 | int i; | ||
6906 | |||
6907 | str = get_options(str, ARRAY_SIZE(ints), ints); | ||
6908 | cpus_clear(cpu_isolated_map); | ||
6909 | for (i = 1; i <= ints[0]; i++) | ||
6910 | if (ints[i] < NR_CPUS) | ||
6911 | cpu_set(ints[i], cpu_isolated_map); | ||
6912 | return 1; | 7025 | return 1; |
6913 | } | 7026 | } |
6914 | 7027 | ||
@@ -6917,42 +7030,43 @@ __setup("isolcpus=", isolated_cpu_setup); | |||
6917 | /* | 7030 | /* |
6918 | * init_sched_build_groups takes the cpumask we wish to span, and a pointer | 7031 | * init_sched_build_groups takes the cpumask we wish to span, and a pointer |
6919 | * to a function which identifies what group(along with sched group) a CPU | 7032 | * to a function which identifies what group(along with sched group) a CPU |
6920 | * belongs to. The return value of group_fn must be a >= 0 and < NR_CPUS | 7033 | * belongs to. The return value of group_fn must be a >= 0 and < nr_cpu_ids |
6921 | * (due to the fact that we keep track of groups covered with a cpumask_t). | 7034 | * (due to the fact that we keep track of groups covered with a struct cpumask). |
6922 | * | 7035 | * |
6923 | * init_sched_build_groups will build a circular linked list of the groups | 7036 | * init_sched_build_groups will build a circular linked list of the groups |
6924 | * covered by the given span, and will set each group's ->cpumask correctly, | 7037 | * covered by the given span, and will set each group's ->cpumask correctly, |
6925 | * and ->cpu_power to 0. | 7038 | * and ->cpu_power to 0. |
6926 | */ | 7039 | */ |
6927 | static void | 7040 | static void |
6928 | init_sched_build_groups(const cpumask_t *span, const cpumask_t *cpu_map, | 7041 | init_sched_build_groups(const struct cpumask *span, |
6929 | int (*group_fn)(int cpu, const cpumask_t *cpu_map, | 7042 | const struct cpumask *cpu_map, |
7043 | int (*group_fn)(int cpu, const struct cpumask *cpu_map, | ||
6930 | struct sched_group **sg, | 7044 | struct sched_group **sg, |
6931 | cpumask_t *tmpmask), | 7045 | struct cpumask *tmpmask), |
6932 | cpumask_t *covered, cpumask_t *tmpmask) | 7046 | struct cpumask *covered, struct cpumask *tmpmask) |
6933 | { | 7047 | { |
6934 | struct sched_group *first = NULL, *last = NULL; | 7048 | struct sched_group *first = NULL, *last = NULL; |
6935 | int i; | 7049 | int i; |
6936 | 7050 | ||
6937 | cpus_clear(*covered); | 7051 | cpumask_clear(covered); |
6938 | 7052 | ||
6939 | for_each_cpu_mask_nr(i, *span) { | 7053 | for_each_cpu(i, span) { |
6940 | struct sched_group *sg; | 7054 | struct sched_group *sg; |
6941 | int group = group_fn(i, cpu_map, &sg, tmpmask); | 7055 | int group = group_fn(i, cpu_map, &sg, tmpmask); |
6942 | int j; | 7056 | int j; |
6943 | 7057 | ||
6944 | if (cpu_isset(i, *covered)) | 7058 | if (cpumask_test_cpu(i, covered)) |
6945 | continue; | 7059 | continue; |
6946 | 7060 | ||
6947 | cpus_clear(sg->cpumask); | 7061 | cpumask_clear(sched_group_cpus(sg)); |
6948 | sg->__cpu_power = 0; | 7062 | sg->__cpu_power = 0; |
6949 | 7063 | ||
6950 | for_each_cpu_mask_nr(j, *span) { | 7064 | for_each_cpu(j, span) { |
6951 | if (group_fn(j, cpu_map, NULL, tmpmask) != group) | 7065 | if (group_fn(j, cpu_map, NULL, tmpmask) != group) |
6952 | continue; | 7066 | continue; |
6953 | 7067 | ||
6954 | cpu_set(j, *covered); | 7068 | cpumask_set_cpu(j, covered); |
6955 | cpu_set(j, sg->cpumask); | 7069 | cpumask_set_cpu(j, sched_group_cpus(sg)); |
6956 | } | 7070 | } |
6957 | if (!first) | 7071 | if (!first) |
6958 | first = sg; | 7072 | first = sg; |
@@ -7016,9 +7130,10 @@ static int find_next_best_node(int node, nodemask_t *used_nodes) | |||
7016 | * should be one that prevents unnecessary balancing, but also spreads tasks | 7130 | * should be one that prevents unnecessary balancing, but also spreads tasks |
7017 | * out optimally. | 7131 | * out optimally. |
7018 | */ | 7132 | */ |
7019 | static void sched_domain_node_span(int node, cpumask_t *span) | 7133 | static void sched_domain_node_span(int node, struct cpumask *span) |
7020 | { | 7134 | { |
7021 | nodemask_t used_nodes; | 7135 | nodemask_t used_nodes; |
7136 | /* FIXME: use cpumask_of_node() */ | ||
7022 | node_to_cpumask_ptr(nodemask, node); | 7137 | node_to_cpumask_ptr(nodemask, node); |
7023 | int i; | 7138 | int i; |
7024 | 7139 | ||
@@ -7040,18 +7155,33 @@ static void sched_domain_node_span(int node, cpumask_t *span) | |||
7040 | int sched_smt_power_savings = 0, sched_mc_power_savings = 0; | 7155 | int sched_smt_power_savings = 0, sched_mc_power_savings = 0; |
7041 | 7156 | ||
7042 | /* | 7157 | /* |
7158 | * The cpus mask in sched_group and sched_domain hangs off the end. | ||
7159 | * FIXME: use cpumask_var_t or dynamic percpu alloc to avoid wasting space | ||
7160 | * for nr_cpu_ids < CONFIG_NR_CPUS. | ||
7161 | */ | ||
7162 | struct static_sched_group { | ||
7163 | struct sched_group sg; | ||
7164 | DECLARE_BITMAP(cpus, CONFIG_NR_CPUS); | ||
7165 | }; | ||
7166 | |||
7167 | struct static_sched_domain { | ||
7168 | struct sched_domain sd; | ||
7169 | DECLARE_BITMAP(span, CONFIG_NR_CPUS); | ||
7170 | }; | ||
7171 | |||
7172 | /* | ||
7043 | * SMT sched-domains: | 7173 | * SMT sched-domains: |
7044 | */ | 7174 | */ |
7045 | #ifdef CONFIG_SCHED_SMT | 7175 | #ifdef CONFIG_SCHED_SMT |
7046 | static DEFINE_PER_CPU(struct sched_domain, cpu_domains); | 7176 | static DEFINE_PER_CPU(struct static_sched_domain, cpu_domains); |
7047 | static DEFINE_PER_CPU(struct sched_group, sched_group_cpus); | 7177 | static DEFINE_PER_CPU(struct static_sched_group, sched_group_cpus); |
7048 | 7178 | ||
7049 | static int | 7179 | static int |
7050 | cpu_to_cpu_group(int cpu, const cpumask_t *cpu_map, struct sched_group **sg, | 7180 | cpu_to_cpu_group(int cpu, const struct cpumask *cpu_map, |
7051 | cpumask_t *unused) | 7181 | struct sched_group **sg, struct cpumask *unused) |
7052 | { | 7182 | { |
7053 | if (sg) | 7183 | if (sg) |
7054 | *sg = &per_cpu(sched_group_cpus, cpu); | 7184 | *sg = &per_cpu(sched_group_cpus, cpu).sg; |
7055 | return cpu; | 7185 | return cpu; |
7056 | } | 7186 | } |
7057 | #endif /* CONFIG_SCHED_SMT */ | 7187 | #endif /* CONFIG_SCHED_SMT */ |
@@ -7060,56 +7190,55 @@ cpu_to_cpu_group(int cpu, const cpumask_t *cpu_map, struct sched_group **sg, | |||
7060 | * multi-core sched-domains: | 7190 | * multi-core sched-domains: |
7061 | */ | 7191 | */ |
7062 | #ifdef CONFIG_SCHED_MC | 7192 | #ifdef CONFIG_SCHED_MC |
7063 | static DEFINE_PER_CPU(struct sched_domain, core_domains); | 7193 | static DEFINE_PER_CPU(struct static_sched_domain, core_domains); |
7064 | static DEFINE_PER_CPU(struct sched_group, sched_group_core); | 7194 | static DEFINE_PER_CPU(struct static_sched_group, sched_group_core); |
7065 | #endif /* CONFIG_SCHED_MC */ | 7195 | #endif /* CONFIG_SCHED_MC */ |
7066 | 7196 | ||
7067 | #if defined(CONFIG_SCHED_MC) && defined(CONFIG_SCHED_SMT) | 7197 | #if defined(CONFIG_SCHED_MC) && defined(CONFIG_SCHED_SMT) |
7068 | static int | 7198 | static int |
7069 | cpu_to_core_group(int cpu, const cpumask_t *cpu_map, struct sched_group **sg, | 7199 | cpu_to_core_group(int cpu, const struct cpumask *cpu_map, |
7070 | cpumask_t *mask) | 7200 | struct sched_group **sg, struct cpumask *mask) |
7071 | { | 7201 | { |
7072 | int group; | 7202 | int group; |
7073 | 7203 | ||
7074 | *mask = per_cpu(cpu_sibling_map, cpu); | 7204 | cpumask_and(mask, &per_cpu(cpu_sibling_map, cpu), cpu_map); |
7075 | cpus_and(*mask, *mask, *cpu_map); | 7205 | group = cpumask_first(mask); |
7076 | group = first_cpu(*mask); | ||
7077 | if (sg) | 7206 | if (sg) |
7078 | *sg = &per_cpu(sched_group_core, group); | 7207 | *sg = &per_cpu(sched_group_core, group).sg; |
7079 | return group; | 7208 | return group; |
7080 | } | 7209 | } |
7081 | #elif defined(CONFIG_SCHED_MC) | 7210 | #elif defined(CONFIG_SCHED_MC) |
7082 | static int | 7211 | static int |
7083 | cpu_to_core_group(int cpu, const cpumask_t *cpu_map, struct sched_group **sg, | 7212 | cpu_to_core_group(int cpu, const struct cpumask *cpu_map, |
7084 | cpumask_t *unused) | 7213 | struct sched_group **sg, struct cpumask *unused) |
7085 | { | 7214 | { |
7086 | if (sg) | 7215 | if (sg) |
7087 | *sg = &per_cpu(sched_group_core, cpu); | 7216 | *sg = &per_cpu(sched_group_core, cpu).sg; |
7088 | return cpu; | 7217 | return cpu; |
7089 | } | 7218 | } |
7090 | #endif | 7219 | #endif |
7091 | 7220 | ||
7092 | static DEFINE_PER_CPU(struct sched_domain, phys_domains); | 7221 | static DEFINE_PER_CPU(struct static_sched_domain, phys_domains); |
7093 | static DEFINE_PER_CPU(struct sched_group, sched_group_phys); | 7222 | static DEFINE_PER_CPU(struct static_sched_group, sched_group_phys); |
7094 | 7223 | ||
7095 | static int | 7224 | static int |
7096 | cpu_to_phys_group(int cpu, const cpumask_t *cpu_map, struct sched_group **sg, | 7225 | cpu_to_phys_group(int cpu, const struct cpumask *cpu_map, |
7097 | cpumask_t *mask) | 7226 | struct sched_group **sg, struct cpumask *mask) |
7098 | { | 7227 | { |
7099 | int group; | 7228 | int group; |
7100 | #ifdef CONFIG_SCHED_MC | 7229 | #ifdef CONFIG_SCHED_MC |
7230 | /* FIXME: Use cpu_coregroup_mask. */ | ||
7101 | *mask = cpu_coregroup_map(cpu); | 7231 | *mask = cpu_coregroup_map(cpu); |
7102 | cpus_and(*mask, *mask, *cpu_map); | 7232 | cpus_and(*mask, *mask, *cpu_map); |
7103 | group = first_cpu(*mask); | 7233 | group = cpumask_first(mask); |
7104 | #elif defined(CONFIG_SCHED_SMT) | 7234 | #elif defined(CONFIG_SCHED_SMT) |
7105 | *mask = per_cpu(cpu_sibling_map, cpu); | 7235 | cpumask_and(mask, &per_cpu(cpu_sibling_map, cpu), cpu_map); |
7106 | cpus_and(*mask, *mask, *cpu_map); | 7236 | group = cpumask_first(mask); |
7107 | group = first_cpu(*mask); | ||
7108 | #else | 7237 | #else |
7109 | group = cpu; | 7238 | group = cpu; |
7110 | #endif | 7239 | #endif |
7111 | if (sg) | 7240 | if (sg) |
7112 | *sg = &per_cpu(sched_group_phys, group); | 7241 | *sg = &per_cpu(sched_group_phys, group).sg; |
7113 | return group; | 7242 | return group; |
7114 | } | 7243 | } |
7115 | 7244 | ||
@@ -7123,19 +7252,21 @@ static DEFINE_PER_CPU(struct sched_domain, node_domains); | |||
7123 | static struct sched_group ***sched_group_nodes_bycpu; | 7252 | static struct sched_group ***sched_group_nodes_bycpu; |
7124 | 7253 | ||
7125 | static DEFINE_PER_CPU(struct sched_domain, allnodes_domains); | 7254 | static DEFINE_PER_CPU(struct sched_domain, allnodes_domains); |
7126 | static DEFINE_PER_CPU(struct sched_group, sched_group_allnodes); | 7255 | static DEFINE_PER_CPU(struct static_sched_group, sched_group_allnodes); |
7127 | 7256 | ||
7128 | static int cpu_to_allnodes_group(int cpu, const cpumask_t *cpu_map, | 7257 | static int cpu_to_allnodes_group(int cpu, const struct cpumask *cpu_map, |
7129 | struct sched_group **sg, cpumask_t *nodemask) | 7258 | struct sched_group **sg, |
7259 | struct cpumask *nodemask) | ||
7130 | { | 7260 | { |
7131 | int group; | 7261 | int group; |
7262 | /* FIXME: use cpumask_of_node */ | ||
7263 | node_to_cpumask_ptr(pnodemask, cpu_to_node(cpu)); | ||
7132 | 7264 | ||
7133 | *nodemask = node_to_cpumask(cpu_to_node(cpu)); | 7265 | cpumask_and(nodemask, pnodemask, cpu_map); |
7134 | cpus_and(*nodemask, *nodemask, *cpu_map); | 7266 | group = cpumask_first(nodemask); |
7135 | group = first_cpu(*nodemask); | ||
7136 | 7267 | ||
7137 | if (sg) | 7268 | if (sg) |
7138 | *sg = &per_cpu(sched_group_allnodes, group); | 7269 | *sg = &per_cpu(sched_group_allnodes, group).sg; |
7139 | return group; | 7270 | return group; |
7140 | } | 7271 | } |
7141 | 7272 | ||
@@ -7147,11 +7278,11 @@ static void init_numa_sched_groups_power(struct sched_group *group_head) | |||
7147 | if (!sg) | 7278 | if (!sg) |
7148 | return; | 7279 | return; |
7149 | do { | 7280 | do { |
7150 | for_each_cpu_mask_nr(j, sg->cpumask) { | 7281 | for_each_cpu(j, sched_group_cpus(sg)) { |
7151 | struct sched_domain *sd; | 7282 | struct sched_domain *sd; |
7152 | 7283 | ||
7153 | sd = &per_cpu(phys_domains, j); | 7284 | sd = &per_cpu(phys_domains, j).sd; |
7154 | if (j != first_cpu(sd->groups->cpumask)) { | 7285 | if (j != cpumask_first(sched_group_cpus(sd->groups))) { |
7155 | /* | 7286 | /* |
7156 | * Only add "power" once for each | 7287 | * Only add "power" once for each |
7157 | * physical package. | 7288 | * physical package. |
@@ -7168,11 +7299,12 @@ static void init_numa_sched_groups_power(struct sched_group *group_head) | |||
7168 | 7299 | ||
7169 | #ifdef CONFIG_NUMA | 7300 | #ifdef CONFIG_NUMA |
7170 | /* Free memory allocated for various sched_group structures */ | 7301 | /* Free memory allocated for various sched_group structures */ |
7171 | static void free_sched_groups(const cpumask_t *cpu_map, cpumask_t *nodemask) | 7302 | static void free_sched_groups(const struct cpumask *cpu_map, |
7303 | struct cpumask *nodemask) | ||
7172 | { | 7304 | { |
7173 | int cpu, i; | 7305 | int cpu, i; |
7174 | 7306 | ||
7175 | for_each_cpu_mask_nr(cpu, *cpu_map) { | 7307 | for_each_cpu(cpu, cpu_map) { |
7176 | struct sched_group **sched_group_nodes | 7308 | struct sched_group **sched_group_nodes |
7177 | = sched_group_nodes_bycpu[cpu]; | 7309 | = sched_group_nodes_bycpu[cpu]; |
7178 | 7310 | ||
@@ -7181,10 +7313,11 @@ static void free_sched_groups(const cpumask_t *cpu_map, cpumask_t *nodemask) | |||
7181 | 7313 | ||
7182 | for (i = 0; i < nr_node_ids; i++) { | 7314 | for (i = 0; i < nr_node_ids; i++) { |
7183 | struct sched_group *oldsg, *sg = sched_group_nodes[i]; | 7315 | struct sched_group *oldsg, *sg = sched_group_nodes[i]; |
7316 | /* FIXME: Use cpumask_of_node */ | ||
7317 | node_to_cpumask_ptr(pnodemask, i); | ||
7184 | 7318 | ||
7185 | *nodemask = node_to_cpumask(i); | 7319 | cpus_and(*nodemask, *pnodemask, *cpu_map); |
7186 | cpus_and(*nodemask, *nodemask, *cpu_map); | 7320 | if (cpumask_empty(nodemask)) |
7187 | if (cpus_empty(*nodemask)) | ||
7188 | continue; | 7321 | continue; |
7189 | 7322 | ||
7190 | if (sg == NULL) | 7323 | if (sg == NULL) |
@@ -7202,7 +7335,8 @@ next_sg: | |||
7202 | } | 7335 | } |
7203 | } | 7336 | } |
7204 | #else /* !CONFIG_NUMA */ | 7337 | #else /* !CONFIG_NUMA */ |
7205 | static void free_sched_groups(const cpumask_t *cpu_map, cpumask_t *nodemask) | 7338 | static void free_sched_groups(const struct cpumask *cpu_map, |
7339 | struct cpumask *nodemask) | ||
7206 | { | 7340 | { |
7207 | } | 7341 | } |
7208 | #endif /* CONFIG_NUMA */ | 7342 | #endif /* CONFIG_NUMA */ |
@@ -7228,7 +7362,7 @@ static void init_sched_groups_power(int cpu, struct sched_domain *sd) | |||
7228 | 7362 | ||
7229 | WARN_ON(!sd || !sd->groups); | 7363 | WARN_ON(!sd || !sd->groups); |
7230 | 7364 | ||
7231 | if (cpu != first_cpu(sd->groups->cpumask)) | 7365 | if (cpu != cpumask_first(sched_group_cpus(sd->groups))) |
7232 | return; | 7366 | return; |
7233 | 7367 | ||
7234 | child = sd->child; | 7368 | child = sd->child; |
@@ -7293,48 +7427,6 @@ SD_INIT_FUNC(CPU) | |||
7293 | SD_INIT_FUNC(MC) | 7427 | SD_INIT_FUNC(MC) |
7294 | #endif | 7428 | #endif |
7295 | 7429 | ||
7296 | /* | ||
7297 | * To minimize stack usage kmalloc room for cpumasks and share the | ||
7298 | * space as the usage in build_sched_domains() dictates. Used only | ||
7299 | * if the amount of space is significant. | ||
7300 | */ | ||
7301 | struct allmasks { | ||
7302 | cpumask_t tmpmask; /* make this one first */ | ||
7303 | union { | ||
7304 | cpumask_t nodemask; | ||
7305 | cpumask_t this_sibling_map; | ||
7306 | cpumask_t this_core_map; | ||
7307 | }; | ||
7308 | cpumask_t send_covered; | ||
7309 | |||
7310 | #ifdef CONFIG_NUMA | ||
7311 | cpumask_t domainspan; | ||
7312 | cpumask_t covered; | ||
7313 | cpumask_t notcovered; | ||
7314 | #endif | ||
7315 | }; | ||
7316 | |||
7317 | #if NR_CPUS > 128 | ||
7318 | #define SCHED_CPUMASK_DECLARE(v) struct allmasks *v | ||
7319 | static inline void sched_cpumask_alloc(struct allmasks **masks) | ||
7320 | { | ||
7321 | *masks = kmalloc(sizeof(**masks), GFP_KERNEL); | ||
7322 | } | ||
7323 | static inline void sched_cpumask_free(struct allmasks *masks) | ||
7324 | { | ||
7325 | kfree(masks); | ||
7326 | } | ||
7327 | #else | ||
7328 | #define SCHED_CPUMASK_DECLARE(v) struct allmasks _v, *v = &_v | ||
7329 | static inline void sched_cpumask_alloc(struct allmasks **masks) | ||
7330 | { } | ||
7331 | static inline void sched_cpumask_free(struct allmasks *masks) | ||
7332 | { } | ||
7333 | #endif | ||
7334 | |||
7335 | #define SCHED_CPUMASK_VAR(v, a) cpumask_t *v = (cpumask_t *) \ | ||
7336 | ((unsigned long)(a) + offsetof(struct allmasks, v)) | ||
7337 | |||
7338 | static int default_relax_domain_level = -1; | 7430 | static int default_relax_domain_level = -1; |
7339 | 7431 | ||
7340 | static int __init setup_relax_domain_level(char *str) | 7432 | static int __init setup_relax_domain_level(char *str) |
@@ -7374,17 +7466,38 @@ static void set_domain_attribute(struct sched_domain *sd, | |||
7374 | * Build sched domains for a given set of cpus and attach the sched domains | 7466 | * Build sched domains for a given set of cpus and attach the sched domains |
7375 | * to the individual cpus | 7467 | * to the individual cpus |
7376 | */ | 7468 | */ |
7377 | static int __build_sched_domains(const cpumask_t *cpu_map, | 7469 | static int __build_sched_domains(const struct cpumask *cpu_map, |
7378 | struct sched_domain_attr *attr) | 7470 | struct sched_domain_attr *attr) |
7379 | { | 7471 | { |
7380 | int i; | 7472 | int i, err = -ENOMEM; |
7381 | struct root_domain *rd; | 7473 | struct root_domain *rd; |
7382 | SCHED_CPUMASK_DECLARE(allmasks); | 7474 | cpumask_var_t nodemask, this_sibling_map, this_core_map, send_covered, |
7383 | cpumask_t *tmpmask; | 7475 | tmpmask; |
7384 | #ifdef CONFIG_NUMA | 7476 | #ifdef CONFIG_NUMA |
7477 | cpumask_var_t domainspan, covered, notcovered; | ||
7385 | struct sched_group **sched_group_nodes = NULL; | 7478 | struct sched_group **sched_group_nodes = NULL; |
7386 | int sd_allnodes = 0; | 7479 | int sd_allnodes = 0; |
7387 | 7480 | ||
7481 | if (!alloc_cpumask_var(&domainspan, GFP_KERNEL)) | ||
7482 | goto out; | ||
7483 | if (!alloc_cpumask_var(&covered, GFP_KERNEL)) | ||
7484 | goto free_domainspan; | ||
7485 | if (!alloc_cpumask_var(¬covered, GFP_KERNEL)) | ||
7486 | goto free_covered; | ||
7487 | #endif | ||
7488 | |||
7489 | if (!alloc_cpumask_var(&nodemask, GFP_KERNEL)) | ||
7490 | goto free_notcovered; | ||
7491 | if (!alloc_cpumask_var(&this_sibling_map, GFP_KERNEL)) | ||
7492 | goto free_nodemask; | ||
7493 | if (!alloc_cpumask_var(&this_core_map, GFP_KERNEL)) | ||
7494 | goto free_this_sibling_map; | ||
7495 | if (!alloc_cpumask_var(&send_covered, GFP_KERNEL)) | ||
7496 | goto free_this_core_map; | ||
7497 | if (!alloc_cpumask_var(&tmpmask, GFP_KERNEL)) | ||
7498 | goto free_send_covered; | ||
7499 | |||
7500 | #ifdef CONFIG_NUMA | ||
7388 | /* | 7501 | /* |
7389 | * Allocate the per-node list of sched groups | 7502 | * Allocate the per-node list of sched groups |
7390 | */ | 7503 | */ |
@@ -7392,54 +7505,37 @@ static int __build_sched_domains(const cpumask_t *cpu_map, | |||
7392 | GFP_KERNEL); | 7505 | GFP_KERNEL); |
7393 | if (!sched_group_nodes) { | 7506 | if (!sched_group_nodes) { |
7394 | printk(KERN_WARNING "Can not alloc sched group node list\n"); | 7507 | printk(KERN_WARNING "Can not alloc sched group node list\n"); |
7395 | return -ENOMEM; | 7508 | goto free_tmpmask; |
7396 | } | 7509 | } |
7397 | #endif | 7510 | #endif |
7398 | 7511 | ||
7399 | rd = alloc_rootdomain(); | 7512 | rd = alloc_rootdomain(); |
7400 | if (!rd) { | 7513 | if (!rd) { |
7401 | printk(KERN_WARNING "Cannot alloc root domain\n"); | 7514 | printk(KERN_WARNING "Cannot alloc root domain\n"); |
7402 | #ifdef CONFIG_NUMA | 7515 | goto free_sched_groups; |
7403 | kfree(sched_group_nodes); | ||
7404 | #endif | ||
7405 | return -ENOMEM; | ||
7406 | } | 7516 | } |
7407 | 7517 | ||
7408 | /* get space for all scratch cpumask variables */ | ||
7409 | sched_cpumask_alloc(&allmasks); | ||
7410 | if (!allmasks) { | ||
7411 | printk(KERN_WARNING "Cannot alloc cpumask array\n"); | ||
7412 | kfree(rd); | ||
7413 | #ifdef CONFIG_NUMA | 7518 | #ifdef CONFIG_NUMA |
7414 | kfree(sched_group_nodes); | 7519 | sched_group_nodes_bycpu[cpumask_first(cpu_map)] = sched_group_nodes; |
7415 | #endif | ||
7416 | return -ENOMEM; | ||
7417 | } | ||
7418 | |||
7419 | tmpmask = (cpumask_t *)allmasks; | ||
7420 | |||
7421 | |||
7422 | #ifdef CONFIG_NUMA | ||
7423 | sched_group_nodes_bycpu[first_cpu(*cpu_map)] = sched_group_nodes; | ||
7424 | #endif | 7520 | #endif |
7425 | 7521 | ||
7426 | /* | 7522 | /* |
7427 | * Set up domains for cpus specified by the cpu_map. | 7523 | * Set up domains for cpus specified by the cpu_map. |
7428 | */ | 7524 | */ |
7429 | for_each_cpu_mask_nr(i, *cpu_map) { | 7525 | for_each_cpu(i, cpu_map) { |
7430 | struct sched_domain *sd = NULL, *p; | 7526 | struct sched_domain *sd = NULL, *p; |
7431 | SCHED_CPUMASK_VAR(nodemask, allmasks); | ||
7432 | 7527 | ||
7528 | /* FIXME: use cpumask_of_node */ | ||
7433 | *nodemask = node_to_cpumask(cpu_to_node(i)); | 7529 | *nodemask = node_to_cpumask(cpu_to_node(i)); |
7434 | cpus_and(*nodemask, *nodemask, *cpu_map); | 7530 | cpus_and(*nodemask, *nodemask, *cpu_map); |
7435 | 7531 | ||
7436 | #ifdef CONFIG_NUMA | 7532 | #ifdef CONFIG_NUMA |
7437 | if (cpus_weight(*cpu_map) > | 7533 | if (cpumask_weight(cpu_map) > |
7438 | SD_NODES_PER_DOMAIN*cpus_weight(*nodemask)) { | 7534 | SD_NODES_PER_DOMAIN*cpumask_weight(nodemask)) { |
7439 | sd = &per_cpu(allnodes_domains, i); | 7535 | sd = &per_cpu(allnodes_domains, i); |
7440 | SD_INIT(sd, ALLNODES); | 7536 | SD_INIT(sd, ALLNODES); |
7441 | set_domain_attribute(sd, attr); | 7537 | set_domain_attribute(sd, attr); |
7442 | sd->span = *cpu_map; | 7538 | cpumask_copy(sched_domain_span(sd), cpu_map); |
7443 | cpu_to_allnodes_group(i, cpu_map, &sd->groups, tmpmask); | 7539 | cpu_to_allnodes_group(i, cpu_map, &sd->groups, tmpmask); |
7444 | p = sd; | 7540 | p = sd; |
7445 | sd_allnodes = 1; | 7541 | sd_allnodes = 1; |
@@ -7449,18 +7545,19 @@ static int __build_sched_domains(const cpumask_t *cpu_map, | |||
7449 | sd = &per_cpu(node_domains, i); | 7545 | sd = &per_cpu(node_domains, i); |
7450 | SD_INIT(sd, NODE); | 7546 | SD_INIT(sd, NODE); |
7451 | set_domain_attribute(sd, attr); | 7547 | set_domain_attribute(sd, attr); |
7452 | sched_domain_node_span(cpu_to_node(i), &sd->span); | 7548 | sched_domain_node_span(cpu_to_node(i), sched_domain_span(sd)); |
7453 | sd->parent = p; | 7549 | sd->parent = p; |
7454 | if (p) | 7550 | if (p) |
7455 | p->child = sd; | 7551 | p->child = sd; |
7456 | cpus_and(sd->span, sd->span, *cpu_map); | 7552 | cpumask_and(sched_domain_span(sd), |
7553 | sched_domain_span(sd), cpu_map); | ||
7457 | #endif | 7554 | #endif |
7458 | 7555 | ||
7459 | p = sd; | 7556 | p = sd; |
7460 | sd = &per_cpu(phys_domains, i); | 7557 | sd = &per_cpu(phys_domains, i).sd; |
7461 | SD_INIT(sd, CPU); | 7558 | SD_INIT(sd, CPU); |
7462 | set_domain_attribute(sd, attr); | 7559 | set_domain_attribute(sd, attr); |
7463 | sd->span = *nodemask; | 7560 | cpumask_copy(sched_domain_span(sd), nodemask); |
7464 | sd->parent = p; | 7561 | sd->parent = p; |
7465 | if (p) | 7562 | if (p) |
7466 | p->child = sd; | 7563 | p->child = sd; |
@@ -7468,11 +7565,12 @@ static int __build_sched_domains(const cpumask_t *cpu_map, | |||
7468 | 7565 | ||
7469 | #ifdef CONFIG_SCHED_MC | 7566 | #ifdef CONFIG_SCHED_MC |
7470 | p = sd; | 7567 | p = sd; |
7471 | sd = &per_cpu(core_domains, i); | 7568 | sd = &per_cpu(core_domains, i).sd; |
7472 | SD_INIT(sd, MC); | 7569 | SD_INIT(sd, MC); |
7473 | set_domain_attribute(sd, attr); | 7570 | set_domain_attribute(sd, attr); |
7474 | sd->span = cpu_coregroup_map(i); | 7571 | *sched_domain_span(sd) = cpu_coregroup_map(i); |
7475 | cpus_and(sd->span, sd->span, *cpu_map); | 7572 | cpumask_and(sched_domain_span(sd), |
7573 | sched_domain_span(sd), cpu_map); | ||
7476 | sd->parent = p; | 7574 | sd->parent = p; |
7477 | p->child = sd; | 7575 | p->child = sd; |
7478 | cpu_to_core_group(i, cpu_map, &sd->groups, tmpmask); | 7576 | cpu_to_core_group(i, cpu_map, &sd->groups, tmpmask); |
@@ -7480,11 +7578,11 @@ static int __build_sched_domains(const cpumask_t *cpu_map, | |||
7480 | 7578 | ||
7481 | #ifdef CONFIG_SCHED_SMT | 7579 | #ifdef CONFIG_SCHED_SMT |
7482 | p = sd; | 7580 | p = sd; |
7483 | sd = &per_cpu(cpu_domains, i); | 7581 | sd = &per_cpu(cpu_domains, i).sd; |
7484 | SD_INIT(sd, SIBLING); | 7582 | SD_INIT(sd, SIBLING); |
7485 | set_domain_attribute(sd, attr); | 7583 | set_domain_attribute(sd, attr); |
7486 | sd->span = per_cpu(cpu_sibling_map, i); | 7584 | cpumask_and(sched_domain_span(sd), |
7487 | cpus_and(sd->span, sd->span, *cpu_map); | 7585 | &per_cpu(cpu_sibling_map, i), cpu_map); |
7488 | sd->parent = p; | 7586 | sd->parent = p; |
7489 | p->child = sd; | 7587 | p->child = sd; |
7490 | cpu_to_cpu_group(i, cpu_map, &sd->groups, tmpmask); | 7588 | cpu_to_cpu_group(i, cpu_map, &sd->groups, tmpmask); |
@@ -7493,13 +7591,10 @@ static int __build_sched_domains(const cpumask_t *cpu_map, | |||
7493 | 7591 | ||
7494 | #ifdef CONFIG_SCHED_SMT | 7592 | #ifdef CONFIG_SCHED_SMT |
7495 | /* Set up CPU (sibling) groups */ | 7593 | /* Set up CPU (sibling) groups */ |
7496 | for_each_cpu_mask_nr(i, *cpu_map) { | 7594 | for_each_cpu(i, cpu_map) { |
7497 | SCHED_CPUMASK_VAR(this_sibling_map, allmasks); | 7595 | cpumask_and(this_sibling_map, |
7498 | SCHED_CPUMASK_VAR(send_covered, allmasks); | 7596 | &per_cpu(cpu_sibling_map, i), cpu_map); |
7499 | 7597 | if (i != cpumask_first(this_sibling_map)) | |
7500 | *this_sibling_map = per_cpu(cpu_sibling_map, i); | ||
7501 | cpus_and(*this_sibling_map, *this_sibling_map, *cpu_map); | ||
7502 | if (i != first_cpu(*this_sibling_map)) | ||
7503 | continue; | 7598 | continue; |
7504 | 7599 | ||
7505 | init_sched_build_groups(this_sibling_map, cpu_map, | 7600 | init_sched_build_groups(this_sibling_map, cpu_map, |
@@ -7510,13 +7605,11 @@ static int __build_sched_domains(const cpumask_t *cpu_map, | |||
7510 | 7605 | ||
7511 | #ifdef CONFIG_SCHED_MC | 7606 | #ifdef CONFIG_SCHED_MC |
7512 | /* Set up multi-core groups */ | 7607 | /* Set up multi-core groups */ |
7513 | for_each_cpu_mask_nr(i, *cpu_map) { | 7608 | for_each_cpu(i, cpu_map) { |
7514 | SCHED_CPUMASK_VAR(this_core_map, allmasks); | 7609 | /* FIXME: Use cpu_coregroup_mask */ |
7515 | SCHED_CPUMASK_VAR(send_covered, allmasks); | ||
7516 | |||
7517 | *this_core_map = cpu_coregroup_map(i); | 7610 | *this_core_map = cpu_coregroup_map(i); |
7518 | cpus_and(*this_core_map, *this_core_map, *cpu_map); | 7611 | cpus_and(*this_core_map, *this_core_map, *cpu_map); |
7519 | if (i != first_cpu(*this_core_map)) | 7612 | if (i != cpumask_first(this_core_map)) |
7520 | continue; | 7613 | continue; |
7521 | 7614 | ||
7522 | init_sched_build_groups(this_core_map, cpu_map, | 7615 | init_sched_build_groups(this_core_map, cpu_map, |
@@ -7527,12 +7620,10 @@ static int __build_sched_domains(const cpumask_t *cpu_map, | |||
7527 | 7620 | ||
7528 | /* Set up physical groups */ | 7621 | /* Set up physical groups */ |
7529 | for (i = 0; i < nr_node_ids; i++) { | 7622 | for (i = 0; i < nr_node_ids; i++) { |
7530 | SCHED_CPUMASK_VAR(nodemask, allmasks); | 7623 | /* FIXME: Use cpumask_of_node */ |
7531 | SCHED_CPUMASK_VAR(send_covered, allmasks); | ||
7532 | |||
7533 | *nodemask = node_to_cpumask(i); | 7624 | *nodemask = node_to_cpumask(i); |
7534 | cpus_and(*nodemask, *nodemask, *cpu_map); | 7625 | cpus_and(*nodemask, *nodemask, *cpu_map); |
7535 | if (cpus_empty(*nodemask)) | 7626 | if (cpumask_empty(nodemask)) |
7536 | continue; | 7627 | continue; |
7537 | 7628 | ||
7538 | init_sched_build_groups(nodemask, cpu_map, | 7629 | init_sched_build_groups(nodemask, cpu_map, |
@@ -7543,8 +7634,6 @@ static int __build_sched_domains(const cpumask_t *cpu_map, | |||
7543 | #ifdef CONFIG_NUMA | 7634 | #ifdef CONFIG_NUMA |
7544 | /* Set up node groups */ | 7635 | /* Set up node groups */ |
7545 | if (sd_allnodes) { | 7636 | if (sd_allnodes) { |
7546 | SCHED_CPUMASK_VAR(send_covered, allmasks); | ||
7547 | |||
7548 | init_sched_build_groups(cpu_map, cpu_map, | 7637 | init_sched_build_groups(cpu_map, cpu_map, |
7549 | &cpu_to_allnodes_group, | 7638 | &cpu_to_allnodes_group, |
7550 | send_covered, tmpmask); | 7639 | send_covered, tmpmask); |
@@ -7553,58 +7642,58 @@ static int __build_sched_domains(const cpumask_t *cpu_map, | |||
7553 | for (i = 0; i < nr_node_ids; i++) { | 7642 | for (i = 0; i < nr_node_ids; i++) { |
7554 | /* Set up node groups */ | 7643 | /* Set up node groups */ |
7555 | struct sched_group *sg, *prev; | 7644 | struct sched_group *sg, *prev; |
7556 | SCHED_CPUMASK_VAR(nodemask, allmasks); | ||
7557 | SCHED_CPUMASK_VAR(domainspan, allmasks); | ||
7558 | SCHED_CPUMASK_VAR(covered, allmasks); | ||
7559 | int j; | 7645 | int j; |
7560 | 7646 | ||
7647 | /* FIXME: Use cpumask_of_node */ | ||
7561 | *nodemask = node_to_cpumask(i); | 7648 | *nodemask = node_to_cpumask(i); |
7562 | cpus_clear(*covered); | 7649 | cpumask_clear(covered); |
7563 | 7650 | ||
7564 | cpus_and(*nodemask, *nodemask, *cpu_map); | 7651 | cpus_and(*nodemask, *nodemask, *cpu_map); |
7565 | if (cpus_empty(*nodemask)) { | 7652 | if (cpumask_empty(nodemask)) { |
7566 | sched_group_nodes[i] = NULL; | 7653 | sched_group_nodes[i] = NULL; |
7567 | continue; | 7654 | continue; |
7568 | } | 7655 | } |
7569 | 7656 | ||
7570 | sched_domain_node_span(i, domainspan); | 7657 | sched_domain_node_span(i, domainspan); |
7571 | cpus_and(*domainspan, *domainspan, *cpu_map); | 7658 | cpumask_and(domainspan, domainspan, cpu_map); |
7572 | 7659 | ||
7573 | sg = kmalloc_node(sizeof(struct sched_group), GFP_KERNEL, i); | 7660 | sg = kmalloc_node(sizeof(struct sched_group) + cpumask_size(), |
7661 | GFP_KERNEL, i); | ||
7574 | if (!sg) { | 7662 | if (!sg) { |
7575 | printk(KERN_WARNING "Can not alloc domain group for " | 7663 | printk(KERN_WARNING "Can not alloc domain group for " |
7576 | "node %d\n", i); | 7664 | "node %d\n", i); |
7577 | goto error; | 7665 | goto error; |
7578 | } | 7666 | } |
7579 | sched_group_nodes[i] = sg; | 7667 | sched_group_nodes[i] = sg; |
7580 | for_each_cpu_mask_nr(j, *nodemask) { | 7668 | for_each_cpu(j, nodemask) { |
7581 | struct sched_domain *sd; | 7669 | struct sched_domain *sd; |
7582 | 7670 | ||
7583 | sd = &per_cpu(node_domains, j); | 7671 | sd = &per_cpu(node_domains, j); |
7584 | sd->groups = sg; | 7672 | sd->groups = sg; |
7585 | } | 7673 | } |
7586 | sg->__cpu_power = 0; | 7674 | sg->__cpu_power = 0; |
7587 | sg->cpumask = *nodemask; | 7675 | cpumask_copy(sched_group_cpus(sg), nodemask); |
7588 | sg->next = sg; | 7676 | sg->next = sg; |
7589 | cpus_or(*covered, *covered, *nodemask); | 7677 | cpumask_or(covered, covered, nodemask); |
7590 | prev = sg; | 7678 | prev = sg; |
7591 | 7679 | ||
7592 | for (j = 0; j < nr_node_ids; j++) { | 7680 | for (j = 0; j < nr_node_ids; j++) { |
7593 | SCHED_CPUMASK_VAR(notcovered, allmasks); | ||
7594 | int n = (i + j) % nr_node_ids; | 7681 | int n = (i + j) % nr_node_ids; |
7682 | /* FIXME: Use cpumask_of_node */ | ||
7595 | node_to_cpumask_ptr(pnodemask, n); | 7683 | node_to_cpumask_ptr(pnodemask, n); |
7596 | 7684 | ||
7597 | cpus_complement(*notcovered, *covered); | 7685 | cpumask_complement(notcovered, covered); |
7598 | cpus_and(*tmpmask, *notcovered, *cpu_map); | 7686 | cpumask_and(tmpmask, notcovered, cpu_map); |
7599 | cpus_and(*tmpmask, *tmpmask, *domainspan); | 7687 | cpumask_and(tmpmask, tmpmask, domainspan); |
7600 | if (cpus_empty(*tmpmask)) | 7688 | if (cpumask_empty(tmpmask)) |
7601 | break; | 7689 | break; |
7602 | 7690 | ||
7603 | cpus_and(*tmpmask, *tmpmask, *pnodemask); | 7691 | cpumask_and(tmpmask, tmpmask, pnodemask); |
7604 | if (cpus_empty(*tmpmask)) | 7692 | if (cpumask_empty(tmpmask)) |
7605 | continue; | 7693 | continue; |
7606 | 7694 | ||
7607 | sg = kmalloc_node(sizeof(struct sched_group), | 7695 | sg = kmalloc_node(sizeof(struct sched_group) + |
7696 | cpumask_size(), | ||
7608 | GFP_KERNEL, i); | 7697 | GFP_KERNEL, i); |
7609 | if (!sg) { | 7698 | if (!sg) { |
7610 | printk(KERN_WARNING | 7699 | printk(KERN_WARNING |
@@ -7612,9 +7701,9 @@ static int __build_sched_domains(const cpumask_t *cpu_map, | |||
7612 | goto error; | 7701 | goto error; |
7613 | } | 7702 | } |
7614 | sg->__cpu_power = 0; | 7703 | sg->__cpu_power = 0; |
7615 | sg->cpumask = *tmpmask; | 7704 | cpumask_copy(sched_group_cpus(sg), tmpmask); |
7616 | sg->next = prev->next; | 7705 | sg->next = prev->next; |
7617 | cpus_or(*covered, *covered, *tmpmask); | 7706 | cpumask_or(covered, covered, tmpmask); |
7618 | prev->next = sg; | 7707 | prev->next = sg; |
7619 | prev = sg; | 7708 | prev = sg; |
7620 | } | 7709 | } |
@@ -7623,22 +7712,22 @@ static int __build_sched_domains(const cpumask_t *cpu_map, | |||
7623 | 7712 | ||
7624 | /* Calculate CPU power for physical packages and nodes */ | 7713 | /* Calculate CPU power for physical packages and nodes */ |
7625 | #ifdef CONFIG_SCHED_SMT | 7714 | #ifdef CONFIG_SCHED_SMT |
7626 | for_each_cpu_mask_nr(i, *cpu_map) { | 7715 | for_each_cpu(i, cpu_map) { |
7627 | struct sched_domain *sd = &per_cpu(cpu_domains, i); | 7716 | struct sched_domain *sd = &per_cpu(cpu_domains, i).sd; |
7628 | 7717 | ||
7629 | init_sched_groups_power(i, sd); | 7718 | init_sched_groups_power(i, sd); |
7630 | } | 7719 | } |
7631 | #endif | 7720 | #endif |
7632 | #ifdef CONFIG_SCHED_MC | 7721 | #ifdef CONFIG_SCHED_MC |
7633 | for_each_cpu_mask_nr(i, *cpu_map) { | 7722 | for_each_cpu(i, cpu_map) { |
7634 | struct sched_domain *sd = &per_cpu(core_domains, i); | 7723 | struct sched_domain *sd = &per_cpu(core_domains, i).sd; |
7635 | 7724 | ||
7636 | init_sched_groups_power(i, sd); | 7725 | init_sched_groups_power(i, sd); |
7637 | } | 7726 | } |
7638 | #endif | 7727 | #endif |
7639 | 7728 | ||
7640 | for_each_cpu_mask_nr(i, *cpu_map) { | 7729 | for_each_cpu(i, cpu_map) { |
7641 | struct sched_domain *sd = &per_cpu(phys_domains, i); | 7730 | struct sched_domain *sd = &per_cpu(phys_domains, i).sd; |
7642 | 7731 | ||
7643 | init_sched_groups_power(i, sd); | 7732 | init_sched_groups_power(i, sd); |
7644 | } | 7733 | } |
@@ -7650,53 +7739,78 @@ static int __build_sched_domains(const cpumask_t *cpu_map, | |||
7650 | if (sd_allnodes) { | 7739 | if (sd_allnodes) { |
7651 | struct sched_group *sg; | 7740 | struct sched_group *sg; |
7652 | 7741 | ||
7653 | cpu_to_allnodes_group(first_cpu(*cpu_map), cpu_map, &sg, | 7742 | cpu_to_allnodes_group(cpumask_first(cpu_map), cpu_map, &sg, |
7654 | tmpmask); | 7743 | tmpmask); |
7655 | init_numa_sched_groups_power(sg); | 7744 | init_numa_sched_groups_power(sg); |
7656 | } | 7745 | } |
7657 | #endif | 7746 | #endif |
7658 | 7747 | ||
7659 | /* Attach the domains */ | 7748 | /* Attach the domains */ |
7660 | for_each_cpu_mask_nr(i, *cpu_map) { | 7749 | for_each_cpu(i, cpu_map) { |
7661 | struct sched_domain *sd; | 7750 | struct sched_domain *sd; |
7662 | #ifdef CONFIG_SCHED_SMT | 7751 | #ifdef CONFIG_SCHED_SMT |
7663 | sd = &per_cpu(cpu_domains, i); | 7752 | sd = &per_cpu(cpu_domains, i).sd; |
7664 | #elif defined(CONFIG_SCHED_MC) | 7753 | #elif defined(CONFIG_SCHED_MC) |
7665 | sd = &per_cpu(core_domains, i); | 7754 | sd = &per_cpu(core_domains, i).sd; |
7666 | #else | 7755 | #else |
7667 | sd = &per_cpu(phys_domains, i); | 7756 | sd = &per_cpu(phys_domains, i).sd; |
7668 | #endif | 7757 | #endif |
7669 | cpu_attach_domain(sd, rd, i); | 7758 | cpu_attach_domain(sd, rd, i); |
7670 | } | 7759 | } |
7671 | 7760 | ||
7672 | sched_cpumask_free(allmasks); | 7761 | err = 0; |
7673 | return 0; | 7762 | |
7763 | free_tmpmask: | ||
7764 | free_cpumask_var(tmpmask); | ||
7765 | free_send_covered: | ||
7766 | free_cpumask_var(send_covered); | ||
7767 | free_this_core_map: | ||
7768 | free_cpumask_var(this_core_map); | ||
7769 | free_this_sibling_map: | ||
7770 | free_cpumask_var(this_sibling_map); | ||
7771 | free_nodemask: | ||
7772 | free_cpumask_var(nodemask); | ||
7773 | free_notcovered: | ||
7774 | #ifdef CONFIG_NUMA | ||
7775 | free_cpumask_var(notcovered); | ||
7776 | free_covered: | ||
7777 | free_cpumask_var(covered); | ||
7778 | free_domainspan: | ||
7779 | free_cpumask_var(domainspan); | ||
7780 | out: | ||
7781 | #endif | ||
7782 | return err; | ||
7783 | |||
7784 | free_sched_groups: | ||
7785 | #ifdef CONFIG_NUMA | ||
7786 | kfree(sched_group_nodes); | ||
7787 | #endif | ||
7788 | goto free_tmpmask; | ||
7674 | 7789 | ||
7675 | #ifdef CONFIG_NUMA | 7790 | #ifdef CONFIG_NUMA |
7676 | error: | 7791 | error: |
7677 | free_sched_groups(cpu_map, tmpmask); | 7792 | free_sched_groups(cpu_map, tmpmask); |
7678 | sched_cpumask_free(allmasks); | 7793 | free_rootdomain(rd); |
7679 | kfree(rd); | 7794 | goto free_tmpmask; |
7680 | return -ENOMEM; | ||
7681 | #endif | 7795 | #endif |
7682 | } | 7796 | } |
7683 | 7797 | ||
7684 | static int build_sched_domains(const cpumask_t *cpu_map) | 7798 | static int build_sched_domains(const struct cpumask *cpu_map) |
7685 | { | 7799 | { |
7686 | return __build_sched_domains(cpu_map, NULL); | 7800 | return __build_sched_domains(cpu_map, NULL); |
7687 | } | 7801 | } |
7688 | 7802 | ||
7689 | static cpumask_t *doms_cur; /* current sched domains */ | 7803 | static struct cpumask *doms_cur; /* current sched domains */ |
7690 | static int ndoms_cur; /* number of sched domains in 'doms_cur' */ | 7804 | static int ndoms_cur; /* number of sched domains in 'doms_cur' */ |
7691 | static struct sched_domain_attr *dattr_cur; | 7805 | static struct sched_domain_attr *dattr_cur; |
7692 | /* attribues of custom domains in 'doms_cur' */ | 7806 | /* attribues of custom domains in 'doms_cur' */ |
7693 | 7807 | ||
7694 | /* | 7808 | /* |
7695 | * Special case: If a kmalloc of a doms_cur partition (array of | 7809 | * Special case: If a kmalloc of a doms_cur partition (array of |
7696 | * cpumask_t) fails, then fallback to a single sched domain, | 7810 | * cpumask) fails, then fallback to a single sched domain, |
7697 | * as determined by the single cpumask_t fallback_doms. | 7811 | * as determined by the single cpumask fallback_doms. |
7698 | */ | 7812 | */ |
7699 | static cpumask_t fallback_doms; | 7813 | static cpumask_var_t fallback_doms; |
7700 | 7814 | ||
7701 | /* | 7815 | /* |
7702 | * arch_update_cpu_topology lets virtualized architectures update the | 7816 | * arch_update_cpu_topology lets virtualized architectures update the |
@@ -7713,16 +7827,16 @@ int __attribute__((weak)) arch_update_cpu_topology(void) | |||
7713 | * For now this just excludes isolated cpus, but could be used to | 7827 | * For now this just excludes isolated cpus, but could be used to |
7714 | * exclude other special cases in the future. | 7828 | * exclude other special cases in the future. |
7715 | */ | 7829 | */ |
7716 | static int arch_init_sched_domains(const cpumask_t *cpu_map) | 7830 | static int arch_init_sched_domains(const struct cpumask *cpu_map) |
7717 | { | 7831 | { |
7718 | int err; | 7832 | int err; |
7719 | 7833 | ||
7720 | arch_update_cpu_topology(); | 7834 | arch_update_cpu_topology(); |
7721 | ndoms_cur = 1; | 7835 | ndoms_cur = 1; |
7722 | doms_cur = kmalloc(sizeof(cpumask_t), GFP_KERNEL); | 7836 | doms_cur = kmalloc(cpumask_size(), GFP_KERNEL); |
7723 | if (!doms_cur) | 7837 | if (!doms_cur) |
7724 | doms_cur = &fallback_doms; | 7838 | doms_cur = fallback_doms; |
7725 | cpus_andnot(*doms_cur, *cpu_map, cpu_isolated_map); | 7839 | cpumask_andnot(doms_cur, cpu_map, cpu_isolated_map); |
7726 | dattr_cur = NULL; | 7840 | dattr_cur = NULL; |
7727 | err = build_sched_domains(doms_cur); | 7841 | err = build_sched_domains(doms_cur); |
7728 | register_sched_domain_sysctl(); | 7842 | register_sched_domain_sysctl(); |
@@ -7730,8 +7844,8 @@ static int arch_init_sched_domains(const cpumask_t *cpu_map) | |||
7730 | return err; | 7844 | return err; |
7731 | } | 7845 | } |
7732 | 7846 | ||
7733 | static void arch_destroy_sched_domains(const cpumask_t *cpu_map, | 7847 | static void arch_destroy_sched_domains(const struct cpumask *cpu_map, |
7734 | cpumask_t *tmpmask) | 7848 | struct cpumask *tmpmask) |
7735 | { | 7849 | { |
7736 | free_sched_groups(cpu_map, tmpmask); | 7850 | free_sched_groups(cpu_map, tmpmask); |
7737 | } | 7851 | } |
@@ -7740,15 +7854,16 @@ static void arch_destroy_sched_domains(const cpumask_t *cpu_map, | |||
7740 | * Detach sched domains from a group of cpus specified in cpu_map | 7854 | * Detach sched domains from a group of cpus specified in cpu_map |
7741 | * These cpus will now be attached to the NULL domain | 7855 | * These cpus will now be attached to the NULL domain |
7742 | */ | 7856 | */ |
7743 | static void detach_destroy_domains(const cpumask_t *cpu_map) | 7857 | static void detach_destroy_domains(const struct cpumask *cpu_map) |
7744 | { | 7858 | { |
7745 | cpumask_t tmpmask; | 7859 | /* Save because hotplug lock held. */ |
7860 | static DECLARE_BITMAP(tmpmask, CONFIG_NR_CPUS); | ||
7746 | int i; | 7861 | int i; |
7747 | 7862 | ||
7748 | for_each_cpu_mask_nr(i, *cpu_map) | 7863 | for_each_cpu(i, cpu_map) |
7749 | cpu_attach_domain(NULL, &def_root_domain, i); | 7864 | cpu_attach_domain(NULL, &def_root_domain, i); |
7750 | synchronize_sched(); | 7865 | synchronize_sched(); |
7751 | arch_destroy_sched_domains(cpu_map, &tmpmask); | 7866 | arch_destroy_sched_domains(cpu_map, to_cpumask(tmpmask)); |
7752 | } | 7867 | } |
7753 | 7868 | ||
7754 | /* handle null as "default" */ | 7869 | /* handle null as "default" */ |
@@ -7773,7 +7888,7 @@ static int dattrs_equal(struct sched_domain_attr *cur, int idx_cur, | |||
7773 | * doms_new[] to the current sched domain partitioning, doms_cur[]. | 7888 | * doms_new[] to the current sched domain partitioning, doms_cur[]. |
7774 | * It destroys each deleted domain and builds each new domain. | 7889 | * It destroys each deleted domain and builds each new domain. |
7775 | * | 7890 | * |
7776 | * 'doms_new' is an array of cpumask_t's of length 'ndoms_new'. | 7891 | * 'doms_new' is an array of cpumask's of length 'ndoms_new'. |
7777 | * The masks don't intersect (don't overlap.) We should setup one | 7892 | * The masks don't intersect (don't overlap.) We should setup one |
7778 | * sched domain for each mask. CPUs not in any of the cpumasks will | 7893 | * sched domain for each mask. CPUs not in any of the cpumasks will |
7779 | * not be load balanced. If the same cpumask appears both in the | 7894 | * not be load balanced. If the same cpumask appears both in the |
@@ -7787,13 +7902,14 @@ static int dattrs_equal(struct sched_domain_attr *cur, int idx_cur, | |||
7787 | * the single partition 'fallback_doms', it also forces the domains | 7902 | * the single partition 'fallback_doms', it also forces the domains |
7788 | * to be rebuilt. | 7903 | * to be rebuilt. |
7789 | * | 7904 | * |
7790 | * If doms_new == NULL it will be replaced with cpu_online_map. | 7905 | * If doms_new == NULL it will be replaced with cpu_online_mask. |
7791 | * ndoms_new == 0 is a special case for destroying existing domains, | 7906 | * ndoms_new == 0 is a special case for destroying existing domains, |
7792 | * and it will not create the default domain. | 7907 | * and it will not create the default domain. |
7793 | * | 7908 | * |
7794 | * Call with hotplug lock held | 7909 | * Call with hotplug lock held |
7795 | */ | 7910 | */ |
7796 | void partition_sched_domains(int ndoms_new, cpumask_t *doms_new, | 7911 | /* FIXME: Change to struct cpumask *doms_new[] */ |
7912 | void partition_sched_domains(int ndoms_new, struct cpumask *doms_new, | ||
7797 | struct sched_domain_attr *dattr_new) | 7913 | struct sched_domain_attr *dattr_new) |
7798 | { | 7914 | { |
7799 | int i, j, n; | 7915 | int i, j, n; |
@@ -7812,7 +7928,7 @@ void partition_sched_domains(int ndoms_new, cpumask_t *doms_new, | |||
7812 | /* Destroy deleted domains */ | 7928 | /* Destroy deleted domains */ |
7813 | for (i = 0; i < ndoms_cur; i++) { | 7929 | for (i = 0; i < ndoms_cur; i++) { |
7814 | for (j = 0; j < n && !new_topology; j++) { | 7930 | for (j = 0; j < n && !new_topology; j++) { |
7815 | if (cpus_equal(doms_cur[i], doms_new[j]) | 7931 | if (cpumask_equal(&doms_cur[i], &doms_new[j]) |
7816 | && dattrs_equal(dattr_cur, i, dattr_new, j)) | 7932 | && dattrs_equal(dattr_cur, i, dattr_new, j)) |
7817 | goto match1; | 7933 | goto match1; |
7818 | } | 7934 | } |
@@ -7824,15 +7940,15 @@ match1: | |||
7824 | 7940 | ||
7825 | if (doms_new == NULL) { | 7941 | if (doms_new == NULL) { |
7826 | ndoms_cur = 0; | 7942 | ndoms_cur = 0; |
7827 | doms_new = &fallback_doms; | 7943 | doms_new = fallback_doms; |
7828 | cpus_andnot(doms_new[0], cpu_online_map, cpu_isolated_map); | 7944 | cpumask_andnot(&doms_new[0], cpu_online_mask, cpu_isolated_map); |
7829 | WARN_ON_ONCE(dattr_new); | 7945 | WARN_ON_ONCE(dattr_new); |
7830 | } | 7946 | } |
7831 | 7947 | ||
7832 | /* Build new domains */ | 7948 | /* Build new domains */ |
7833 | for (i = 0; i < ndoms_new; i++) { | 7949 | for (i = 0; i < ndoms_new; i++) { |
7834 | for (j = 0; j < ndoms_cur && !new_topology; j++) { | 7950 | for (j = 0; j < ndoms_cur && !new_topology; j++) { |
7835 | if (cpus_equal(doms_new[i], doms_cur[j]) | 7951 | if (cpumask_equal(&doms_new[i], &doms_cur[j]) |
7836 | && dattrs_equal(dattr_new, i, dattr_cur, j)) | 7952 | && dattrs_equal(dattr_new, i, dattr_cur, j)) |
7837 | goto match2; | 7953 | goto match2; |
7838 | } | 7954 | } |
@@ -7844,7 +7960,7 @@ match2: | |||
7844 | } | 7960 | } |
7845 | 7961 | ||
7846 | /* Remember the new sched domains */ | 7962 | /* Remember the new sched domains */ |
7847 | if (doms_cur != &fallback_doms) | 7963 | if (doms_cur != fallback_doms) |
7848 | kfree(doms_cur); | 7964 | kfree(doms_cur); |
7849 | kfree(dattr_cur); /* kfree(NULL) is safe */ | 7965 | kfree(dattr_cur); /* kfree(NULL) is safe */ |
7850 | doms_cur = doms_new; | 7966 | doms_cur = doms_new; |
@@ -7873,14 +7989,25 @@ int arch_reinit_sched_domains(void) | |||
7873 | static ssize_t sched_power_savings_store(const char *buf, size_t count, int smt) | 7989 | static ssize_t sched_power_savings_store(const char *buf, size_t count, int smt) |
7874 | { | 7990 | { |
7875 | int ret; | 7991 | int ret; |
7992 | unsigned int level = 0; | ||
7876 | 7993 | ||
7877 | if (buf[0] != '0' && buf[0] != '1') | 7994 | if (sscanf(buf, "%u", &level) != 1) |
7995 | return -EINVAL; | ||
7996 | |||
7997 | /* | ||
7998 | * level is always be positive so don't check for | ||
7999 | * level < POWERSAVINGS_BALANCE_NONE which is 0 | ||
8000 | * What happens on 0 or 1 byte write, | ||
8001 | * need to check for count as well? | ||
8002 | */ | ||
8003 | |||
8004 | if (level >= MAX_POWERSAVINGS_BALANCE_LEVELS) | ||
7878 | return -EINVAL; | 8005 | return -EINVAL; |
7879 | 8006 | ||
7880 | if (smt) | 8007 | if (smt) |
7881 | sched_smt_power_savings = (buf[0] == '1'); | 8008 | sched_smt_power_savings = level; |
7882 | else | 8009 | else |
7883 | sched_mc_power_savings = (buf[0] == '1'); | 8010 | sched_mc_power_savings = level; |
7884 | 8011 | ||
7885 | ret = arch_reinit_sched_domains(); | 8012 | ret = arch_reinit_sched_domains(); |
7886 | 8013 | ||
@@ -7984,7 +8111,9 @@ static int update_runtime(struct notifier_block *nfb, | |||
7984 | 8111 | ||
7985 | void __init sched_init_smp(void) | 8112 | void __init sched_init_smp(void) |
7986 | { | 8113 | { |
7987 | cpumask_t non_isolated_cpus; | 8114 | cpumask_var_t non_isolated_cpus; |
8115 | |||
8116 | alloc_cpumask_var(&non_isolated_cpus, GFP_KERNEL); | ||
7988 | 8117 | ||
7989 | #if defined(CONFIG_NUMA) | 8118 | #if defined(CONFIG_NUMA) |
7990 | sched_group_nodes_bycpu = kzalloc(nr_cpu_ids * sizeof(void **), | 8119 | sched_group_nodes_bycpu = kzalloc(nr_cpu_ids * sizeof(void **), |
@@ -7993,10 +8122,10 @@ void __init sched_init_smp(void) | |||
7993 | #endif | 8122 | #endif |
7994 | get_online_cpus(); | 8123 | get_online_cpus(); |
7995 | mutex_lock(&sched_domains_mutex); | 8124 | mutex_lock(&sched_domains_mutex); |
7996 | arch_init_sched_domains(&cpu_online_map); | 8125 | arch_init_sched_domains(cpu_online_mask); |
7997 | cpus_andnot(non_isolated_cpus, cpu_possible_map, cpu_isolated_map); | 8126 | cpumask_andnot(non_isolated_cpus, cpu_possible_mask, cpu_isolated_map); |
7998 | if (cpus_empty(non_isolated_cpus)) | 8127 | if (cpumask_empty(non_isolated_cpus)) |
7999 | cpu_set(smp_processor_id(), non_isolated_cpus); | 8128 | cpumask_set_cpu(smp_processor_id(), non_isolated_cpus); |
8000 | mutex_unlock(&sched_domains_mutex); | 8129 | mutex_unlock(&sched_domains_mutex); |
8001 | put_online_cpus(); | 8130 | put_online_cpus(); |
8002 | 8131 | ||
@@ -8011,9 +8140,13 @@ void __init sched_init_smp(void) | |||
8011 | init_hrtick(); | 8140 | init_hrtick(); |
8012 | 8141 | ||
8013 | /* Move init over to a non-isolated CPU */ | 8142 | /* Move init over to a non-isolated CPU */ |
8014 | if (set_cpus_allowed_ptr(current, &non_isolated_cpus) < 0) | 8143 | if (set_cpus_allowed_ptr(current, non_isolated_cpus) < 0) |
8015 | BUG(); | 8144 | BUG(); |
8016 | sched_init_granularity(); | 8145 | sched_init_granularity(); |
8146 | free_cpumask_var(non_isolated_cpus); | ||
8147 | |||
8148 | alloc_cpumask_var(&fallback_doms, GFP_KERNEL); | ||
8149 | init_sched_rt_class(); | ||
8017 | } | 8150 | } |
8018 | #else | 8151 | #else |
8019 | void __init sched_init_smp(void) | 8152 | void __init sched_init_smp(void) |
@@ -8328,6 +8461,15 @@ void __init sched_init(void) | |||
8328 | */ | 8461 | */ |
8329 | current->sched_class = &fair_sched_class; | 8462 | current->sched_class = &fair_sched_class; |
8330 | 8463 | ||
8464 | /* Allocate the nohz_cpu_mask if CONFIG_CPUMASK_OFFSTACK */ | ||
8465 | alloc_bootmem_cpumask_var(&nohz_cpu_mask); | ||
8466 | #ifdef CONFIG_SMP | ||
8467 | #ifdef CONFIG_NO_HZ | ||
8468 | alloc_bootmem_cpumask_var(&nohz.cpu_mask); | ||
8469 | #endif | ||
8470 | alloc_bootmem_cpumask_var(&cpu_isolated_map); | ||
8471 | #endif /* SMP */ | ||
8472 | |||
8331 | scheduler_running = 1; | 8473 | scheduler_running = 1; |
8332 | } | 8474 | } |
8333 | 8475 | ||
diff --git a/kernel/sched_cpupri.c b/kernel/sched_cpupri.c index 52154fefab7e..018b7be1db2e 100644 --- a/kernel/sched_cpupri.c +++ b/kernel/sched_cpupri.c | |||
@@ -67,24 +67,21 @@ static int convert_prio(int prio) | |||
67 | * Returns: (int)bool - CPUs were found | 67 | * Returns: (int)bool - CPUs were found |
68 | */ | 68 | */ |
69 | int cpupri_find(struct cpupri *cp, struct task_struct *p, | 69 | int cpupri_find(struct cpupri *cp, struct task_struct *p, |
70 | cpumask_t *lowest_mask) | 70 | struct cpumask *lowest_mask) |
71 | { | 71 | { |
72 | int idx = 0; | 72 | int idx = 0; |
73 | int task_pri = convert_prio(p->prio); | 73 | int task_pri = convert_prio(p->prio); |
74 | 74 | ||
75 | for_each_cpupri_active(cp->pri_active, idx) { | 75 | for_each_cpupri_active(cp->pri_active, idx) { |
76 | struct cpupri_vec *vec = &cp->pri_to_cpu[idx]; | 76 | struct cpupri_vec *vec = &cp->pri_to_cpu[idx]; |
77 | cpumask_t mask; | ||
78 | 77 | ||
79 | if (idx >= task_pri) | 78 | if (idx >= task_pri) |
80 | break; | 79 | break; |
81 | 80 | ||
82 | cpus_and(mask, p->cpus_allowed, vec->mask); | 81 | if (cpumask_any_and(&p->cpus_allowed, vec->mask) >= nr_cpu_ids) |
83 | |||
84 | if (cpus_empty(mask)) | ||
85 | continue; | 82 | continue; |
86 | 83 | ||
87 | *lowest_mask = mask; | 84 | cpumask_and(lowest_mask, &p->cpus_allowed, vec->mask); |
88 | return 1; | 85 | return 1; |
89 | } | 86 | } |
90 | 87 | ||
@@ -126,7 +123,7 @@ void cpupri_set(struct cpupri *cp, int cpu, int newpri) | |||
126 | vec->count--; | 123 | vec->count--; |
127 | if (!vec->count) | 124 | if (!vec->count) |
128 | clear_bit(oldpri, cp->pri_active); | 125 | clear_bit(oldpri, cp->pri_active); |
129 | cpu_clear(cpu, vec->mask); | 126 | cpumask_clear_cpu(cpu, vec->mask); |
130 | 127 | ||
131 | spin_unlock_irqrestore(&vec->lock, flags); | 128 | spin_unlock_irqrestore(&vec->lock, flags); |
132 | } | 129 | } |
@@ -136,7 +133,7 @@ void cpupri_set(struct cpupri *cp, int cpu, int newpri) | |||
136 | 133 | ||
137 | spin_lock_irqsave(&vec->lock, flags); | 134 | spin_lock_irqsave(&vec->lock, flags); |
138 | 135 | ||
139 | cpu_set(cpu, vec->mask); | 136 | cpumask_set_cpu(cpu, vec->mask); |
140 | vec->count++; | 137 | vec->count++; |
141 | if (vec->count == 1) | 138 | if (vec->count == 1) |
142 | set_bit(newpri, cp->pri_active); | 139 | set_bit(newpri, cp->pri_active); |
@@ -150,10 +147,11 @@ void cpupri_set(struct cpupri *cp, int cpu, int newpri) | |||
150 | /** | 147 | /** |
151 | * cpupri_init - initialize the cpupri structure | 148 | * cpupri_init - initialize the cpupri structure |
152 | * @cp: The cpupri context | 149 | * @cp: The cpupri context |
150 | * @bootmem: true if allocations need to use bootmem | ||
153 | * | 151 | * |
154 | * Returns: (void) | 152 | * Returns: -ENOMEM if memory fails. |
155 | */ | 153 | */ |
156 | void cpupri_init(struct cpupri *cp) | 154 | int cpupri_init(struct cpupri *cp, bool bootmem) |
157 | { | 155 | { |
158 | int i; | 156 | int i; |
159 | 157 | ||
@@ -164,11 +162,30 @@ void cpupri_init(struct cpupri *cp) | |||
164 | 162 | ||
165 | spin_lock_init(&vec->lock); | 163 | spin_lock_init(&vec->lock); |
166 | vec->count = 0; | 164 | vec->count = 0; |
167 | cpus_clear(vec->mask); | 165 | if (bootmem) |
166 | alloc_bootmem_cpumask_var(&vec->mask); | ||
167 | else if (!alloc_cpumask_var(&vec->mask, GFP_KERNEL)) | ||
168 | goto cleanup; | ||
168 | } | 169 | } |
169 | 170 | ||
170 | for_each_possible_cpu(i) | 171 | for_each_possible_cpu(i) |
171 | cp->cpu_to_pri[i] = CPUPRI_INVALID; | 172 | cp->cpu_to_pri[i] = CPUPRI_INVALID; |
173 | return 0; | ||
174 | |||
175 | cleanup: | ||
176 | for (i--; i >= 0; i--) | ||
177 | free_cpumask_var(cp->pri_to_cpu[i].mask); | ||
178 | return -ENOMEM; | ||
172 | } | 179 | } |
173 | 180 | ||
181 | /** | ||
182 | * cpupri_cleanup - clean up the cpupri structure | ||
183 | * @cp: The cpupri context | ||
184 | */ | ||
185 | void cpupri_cleanup(struct cpupri *cp) | ||
186 | { | ||
187 | int i; | ||
174 | 188 | ||
189 | for (i = 0; i < CPUPRI_NR_PRIORITIES; i++) | ||
190 | free_cpumask_var(cp->pri_to_cpu[i].mask); | ||
191 | } | ||
diff --git a/kernel/sched_cpupri.h b/kernel/sched_cpupri.h index f25811b0f931..642a94ef8a0a 100644 --- a/kernel/sched_cpupri.h +++ b/kernel/sched_cpupri.h | |||
@@ -14,7 +14,7 @@ | |||
14 | struct cpupri_vec { | 14 | struct cpupri_vec { |
15 | spinlock_t lock; | 15 | spinlock_t lock; |
16 | int count; | 16 | int count; |
17 | cpumask_t mask; | 17 | cpumask_var_t mask; |
18 | }; | 18 | }; |
19 | 19 | ||
20 | struct cpupri { | 20 | struct cpupri { |
@@ -27,7 +27,8 @@ struct cpupri { | |||
27 | int cpupri_find(struct cpupri *cp, | 27 | int cpupri_find(struct cpupri *cp, |
28 | struct task_struct *p, cpumask_t *lowest_mask); | 28 | struct task_struct *p, cpumask_t *lowest_mask); |
29 | void cpupri_set(struct cpupri *cp, int cpu, int pri); | 29 | void cpupri_set(struct cpupri *cp, int cpu, int pri); |
30 | void cpupri_init(struct cpupri *cp); | 30 | int cpupri_init(struct cpupri *cp, bool bootmem); |
31 | void cpupri_cleanup(struct cpupri *cp); | ||
31 | #else | 32 | #else |
32 | #define cpupri_set(cp, cpu, pri) do { } while (0) | 33 | #define cpupri_set(cp, cpu, pri) do { } while (0) |
33 | #define cpupri_init() do { } while (0) | 34 | #define cpupri_init() do { } while (0) |
diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c index 5ad4440f0fc4..56c0efe902a7 100644 --- a/kernel/sched_fair.c +++ b/kernel/sched_fair.c | |||
@@ -1019,16 +1019,33 @@ static void yield_task_fair(struct rq *rq) | |||
1019 | * search starts with cpus closest then further out as needed, | 1019 | * search starts with cpus closest then further out as needed, |
1020 | * so we always favor a closer, idle cpu. | 1020 | * so we always favor a closer, idle cpu. |
1021 | * Domains may include CPUs that are not usable for migration, | 1021 | * Domains may include CPUs that are not usable for migration, |
1022 | * hence we need to mask them out (cpu_active_map) | 1022 | * hence we need to mask them out (cpu_active_mask) |
1023 | * | 1023 | * |
1024 | * Returns the CPU we should wake onto. | 1024 | * Returns the CPU we should wake onto. |
1025 | */ | 1025 | */ |
1026 | #if defined(ARCH_HAS_SCHED_WAKE_IDLE) | 1026 | #if defined(ARCH_HAS_SCHED_WAKE_IDLE) |
1027 | static int wake_idle(int cpu, struct task_struct *p) | 1027 | static int wake_idle(int cpu, struct task_struct *p) |
1028 | { | 1028 | { |
1029 | cpumask_t tmp; | ||
1030 | struct sched_domain *sd; | 1029 | struct sched_domain *sd; |
1031 | int i; | 1030 | int i; |
1031 | unsigned int chosen_wakeup_cpu; | ||
1032 | int this_cpu; | ||
1033 | |||
1034 | /* | ||
1035 | * At POWERSAVINGS_BALANCE_WAKEUP level, if both this_cpu and prev_cpu | ||
1036 | * are idle and this is not a kernel thread and this task's affinity | ||
1037 | * allows it to be moved to preferred cpu, then just move! | ||
1038 | */ | ||
1039 | |||
1040 | this_cpu = smp_processor_id(); | ||
1041 | chosen_wakeup_cpu = | ||
1042 | cpu_rq(this_cpu)->rd->sched_mc_preferred_wakeup_cpu; | ||
1043 | |||
1044 | if (sched_mc_power_savings >= POWERSAVINGS_BALANCE_WAKEUP && | ||
1045 | idle_cpu(cpu) && idle_cpu(this_cpu) && | ||
1046 | p->mm && !(p->flags & PF_KTHREAD) && | ||
1047 | cpu_isset(chosen_wakeup_cpu, p->cpus_allowed)) | ||
1048 | return chosen_wakeup_cpu; | ||
1032 | 1049 | ||
1033 | /* | 1050 | /* |
1034 | * If it is idle, then it is the best cpu to run this task. | 1051 | * If it is idle, then it is the best cpu to run this task. |
@@ -1046,10 +1063,9 @@ static int wake_idle(int cpu, struct task_struct *p) | |||
1046 | if ((sd->flags & SD_WAKE_IDLE) | 1063 | if ((sd->flags & SD_WAKE_IDLE) |
1047 | || ((sd->flags & SD_WAKE_IDLE_FAR) | 1064 | || ((sd->flags & SD_WAKE_IDLE_FAR) |
1048 | && !task_hot(p, task_rq(p)->clock, sd))) { | 1065 | && !task_hot(p, task_rq(p)->clock, sd))) { |
1049 | cpus_and(tmp, sd->span, p->cpus_allowed); | 1066 | for_each_cpu_and(i, sched_domain_span(sd), |
1050 | cpus_and(tmp, tmp, cpu_active_map); | 1067 | &p->cpus_allowed) { |
1051 | for_each_cpu_mask_nr(i, tmp) { | 1068 | if (cpu_active(i) && idle_cpu(i)) { |
1052 | if (idle_cpu(i)) { | ||
1053 | if (i != task_cpu(p)) { | 1069 | if (i != task_cpu(p)) { |
1054 | schedstat_inc(p, | 1070 | schedstat_inc(p, |
1055 | se.nr_wakeups_idle); | 1071 | se.nr_wakeups_idle); |
@@ -1242,13 +1258,13 @@ static int select_task_rq_fair(struct task_struct *p, int sync) | |||
1242 | * this_cpu and prev_cpu are present in: | 1258 | * this_cpu and prev_cpu are present in: |
1243 | */ | 1259 | */ |
1244 | for_each_domain(this_cpu, sd) { | 1260 | for_each_domain(this_cpu, sd) { |
1245 | if (cpu_isset(prev_cpu, sd->span)) { | 1261 | if (cpumask_test_cpu(prev_cpu, sched_domain_span(sd))) { |
1246 | this_sd = sd; | 1262 | this_sd = sd; |
1247 | break; | 1263 | break; |
1248 | } | 1264 | } |
1249 | } | 1265 | } |
1250 | 1266 | ||
1251 | if (unlikely(!cpu_isset(this_cpu, p->cpus_allowed))) | 1267 | if (unlikely(!cpumask_test_cpu(this_cpu, &p->cpus_allowed))) |
1252 | goto out; | 1268 | goto out; |
1253 | 1269 | ||
1254 | /* | 1270 | /* |
diff --git a/kernel/sched_rt.c b/kernel/sched_rt.c index 51d2af3e6191..833b6d44483c 100644 --- a/kernel/sched_rt.c +++ b/kernel/sched_rt.c | |||
@@ -15,7 +15,7 @@ static inline void rt_set_overload(struct rq *rq) | |||
15 | if (!rq->online) | 15 | if (!rq->online) |
16 | return; | 16 | return; |
17 | 17 | ||
18 | cpu_set(rq->cpu, rq->rd->rto_mask); | 18 | cpumask_set_cpu(rq->cpu, rq->rd->rto_mask); |
19 | /* | 19 | /* |
20 | * Make sure the mask is visible before we set | 20 | * Make sure the mask is visible before we set |
21 | * the overload count. That is checked to determine | 21 | * the overload count. That is checked to determine |
@@ -34,7 +34,7 @@ static inline void rt_clear_overload(struct rq *rq) | |||
34 | 34 | ||
35 | /* the order here really doesn't matter */ | 35 | /* the order here really doesn't matter */ |
36 | atomic_dec(&rq->rd->rto_count); | 36 | atomic_dec(&rq->rd->rto_count); |
37 | cpu_clear(rq->cpu, rq->rd->rto_mask); | 37 | cpumask_clear_cpu(rq->cpu, rq->rd->rto_mask); |
38 | } | 38 | } |
39 | 39 | ||
40 | static void update_rt_migration(struct rq *rq) | 40 | static void update_rt_migration(struct rq *rq) |
@@ -139,14 +139,14 @@ static int rt_se_boosted(struct sched_rt_entity *rt_se) | |||
139 | } | 139 | } |
140 | 140 | ||
141 | #ifdef CONFIG_SMP | 141 | #ifdef CONFIG_SMP |
142 | static inline cpumask_t sched_rt_period_mask(void) | 142 | static inline const struct cpumask *sched_rt_period_mask(void) |
143 | { | 143 | { |
144 | return cpu_rq(smp_processor_id())->rd->span; | 144 | return cpu_rq(smp_processor_id())->rd->span; |
145 | } | 145 | } |
146 | #else | 146 | #else |
147 | static inline cpumask_t sched_rt_period_mask(void) | 147 | static inline const struct cpumask *sched_rt_period_mask(void) |
148 | { | 148 | { |
149 | return cpu_online_map; | 149 | return cpu_online_mask; |
150 | } | 150 | } |
151 | #endif | 151 | #endif |
152 | 152 | ||
@@ -212,9 +212,9 @@ static inline int rt_rq_throttled(struct rt_rq *rt_rq) | |||
212 | return rt_rq->rt_throttled; | 212 | return rt_rq->rt_throttled; |
213 | } | 213 | } |
214 | 214 | ||
215 | static inline cpumask_t sched_rt_period_mask(void) | 215 | static inline const struct cpumask *sched_rt_period_mask(void) |
216 | { | 216 | { |
217 | return cpu_online_map; | 217 | return cpu_online_mask; |
218 | } | 218 | } |
219 | 219 | ||
220 | static inline | 220 | static inline |
@@ -241,11 +241,11 @@ static int do_balance_runtime(struct rt_rq *rt_rq) | |||
241 | int i, weight, more = 0; | 241 | int i, weight, more = 0; |
242 | u64 rt_period; | 242 | u64 rt_period; |
243 | 243 | ||
244 | weight = cpus_weight(rd->span); | 244 | weight = cpumask_weight(rd->span); |
245 | 245 | ||
246 | spin_lock(&rt_b->rt_runtime_lock); | 246 | spin_lock(&rt_b->rt_runtime_lock); |
247 | rt_period = ktime_to_ns(rt_b->rt_period); | 247 | rt_period = ktime_to_ns(rt_b->rt_period); |
248 | for_each_cpu_mask_nr(i, rd->span) { | 248 | for_each_cpu(i, rd->span) { |
249 | struct rt_rq *iter = sched_rt_period_rt_rq(rt_b, i); | 249 | struct rt_rq *iter = sched_rt_period_rt_rq(rt_b, i); |
250 | s64 diff; | 250 | s64 diff; |
251 | 251 | ||
@@ -324,7 +324,7 @@ static void __disable_runtime(struct rq *rq) | |||
324 | /* | 324 | /* |
325 | * Greedy reclaim, take back as much as we can. | 325 | * Greedy reclaim, take back as much as we can. |
326 | */ | 326 | */ |
327 | for_each_cpu_mask(i, rd->span) { | 327 | for_each_cpu(i, rd->span) { |
328 | struct rt_rq *iter = sched_rt_period_rt_rq(rt_b, i); | 328 | struct rt_rq *iter = sched_rt_period_rt_rq(rt_b, i); |
329 | s64 diff; | 329 | s64 diff; |
330 | 330 | ||
@@ -429,13 +429,13 @@ static inline int balance_runtime(struct rt_rq *rt_rq) | |||
429 | static int do_sched_rt_period_timer(struct rt_bandwidth *rt_b, int overrun) | 429 | static int do_sched_rt_period_timer(struct rt_bandwidth *rt_b, int overrun) |
430 | { | 430 | { |
431 | int i, idle = 1; | 431 | int i, idle = 1; |
432 | cpumask_t span; | 432 | const struct cpumask *span; |
433 | 433 | ||
434 | if (!rt_bandwidth_enabled() || rt_b->rt_runtime == RUNTIME_INF) | 434 | if (!rt_bandwidth_enabled() || rt_b->rt_runtime == RUNTIME_INF) |
435 | return 1; | 435 | return 1; |
436 | 436 | ||
437 | span = sched_rt_period_mask(); | 437 | span = sched_rt_period_mask(); |
438 | for_each_cpu_mask(i, span) { | 438 | for_each_cpu(i, span) { |
439 | int enqueue = 0; | 439 | int enqueue = 0; |
440 | struct rt_rq *rt_rq = sched_rt_period_rt_rq(rt_b, i); | 440 | struct rt_rq *rt_rq = sched_rt_period_rt_rq(rt_b, i); |
441 | struct rq *rq = rq_of_rt_rq(rt_rq); | 441 | struct rq *rq = rq_of_rt_rq(rt_rq); |
@@ -805,17 +805,20 @@ static int select_task_rq_rt(struct task_struct *p, int sync) | |||
805 | 805 | ||
806 | static void check_preempt_equal_prio(struct rq *rq, struct task_struct *p) | 806 | static void check_preempt_equal_prio(struct rq *rq, struct task_struct *p) |
807 | { | 807 | { |
808 | cpumask_t mask; | 808 | cpumask_var_t mask; |
809 | 809 | ||
810 | if (rq->curr->rt.nr_cpus_allowed == 1) | 810 | if (rq->curr->rt.nr_cpus_allowed == 1) |
811 | return; | 811 | return; |
812 | 812 | ||
813 | if (p->rt.nr_cpus_allowed != 1 | 813 | if (!alloc_cpumask_var(&mask, GFP_ATOMIC)) |
814 | && cpupri_find(&rq->rd->cpupri, p, &mask)) | ||
815 | return; | 814 | return; |
816 | 815 | ||
817 | if (!cpupri_find(&rq->rd->cpupri, rq->curr, &mask)) | 816 | if (p->rt.nr_cpus_allowed != 1 |
818 | return; | 817 | && cpupri_find(&rq->rd->cpupri, p, mask)) |
818 | goto free; | ||
819 | |||
820 | if (!cpupri_find(&rq->rd->cpupri, rq->curr, mask)) | ||
821 | goto free; | ||
819 | 822 | ||
820 | /* | 823 | /* |
821 | * There appears to be other cpus that can accept | 824 | * There appears to be other cpus that can accept |
@@ -824,6 +827,8 @@ static void check_preempt_equal_prio(struct rq *rq, struct task_struct *p) | |||
824 | */ | 827 | */ |
825 | requeue_task_rt(rq, p, 1); | 828 | requeue_task_rt(rq, p, 1); |
826 | resched_task(rq->curr); | 829 | resched_task(rq->curr); |
830 | free: | ||
831 | free_cpumask_var(mask); | ||
827 | } | 832 | } |
828 | 833 | ||
829 | #endif /* CONFIG_SMP */ | 834 | #endif /* CONFIG_SMP */ |
@@ -914,7 +919,7 @@ static void deactivate_task(struct rq *rq, struct task_struct *p, int sleep); | |||
914 | static int pick_rt_task(struct rq *rq, struct task_struct *p, int cpu) | 919 | static int pick_rt_task(struct rq *rq, struct task_struct *p, int cpu) |
915 | { | 920 | { |
916 | if (!task_running(rq, p) && | 921 | if (!task_running(rq, p) && |
917 | (cpu < 0 || cpu_isset(cpu, p->cpus_allowed)) && | 922 | (cpu < 0 || cpumask_test_cpu(cpu, &p->cpus_allowed)) && |
918 | (p->rt.nr_cpus_allowed > 1)) | 923 | (p->rt.nr_cpus_allowed > 1)) |
919 | return 1; | 924 | return 1; |
920 | return 0; | 925 | return 0; |
@@ -953,7 +958,7 @@ static struct task_struct *pick_next_highest_task_rt(struct rq *rq, int cpu) | |||
953 | return next; | 958 | return next; |
954 | } | 959 | } |
955 | 960 | ||
956 | static DEFINE_PER_CPU(cpumask_t, local_cpu_mask); | 961 | static DEFINE_PER_CPU(cpumask_var_t, local_cpu_mask); |
957 | 962 | ||
958 | static inline int pick_optimal_cpu(int this_cpu, cpumask_t *mask) | 963 | static inline int pick_optimal_cpu(int this_cpu, cpumask_t *mask) |
959 | { | 964 | { |
@@ -973,7 +978,7 @@ static inline int pick_optimal_cpu(int this_cpu, cpumask_t *mask) | |||
973 | static int find_lowest_rq(struct task_struct *task) | 978 | static int find_lowest_rq(struct task_struct *task) |
974 | { | 979 | { |
975 | struct sched_domain *sd; | 980 | struct sched_domain *sd; |
976 | cpumask_t *lowest_mask = &__get_cpu_var(local_cpu_mask); | 981 | struct cpumask *lowest_mask = __get_cpu_var(local_cpu_mask); |
977 | int this_cpu = smp_processor_id(); | 982 | int this_cpu = smp_processor_id(); |
978 | int cpu = task_cpu(task); | 983 | int cpu = task_cpu(task); |
979 | 984 | ||
@@ -988,7 +993,7 @@ static int find_lowest_rq(struct task_struct *task) | |||
988 | * I guess we might want to change cpupri_find() to ignore those | 993 | * I guess we might want to change cpupri_find() to ignore those |
989 | * in the first place. | 994 | * in the first place. |
990 | */ | 995 | */ |
991 | cpus_and(*lowest_mask, *lowest_mask, cpu_active_map); | 996 | cpumask_and(lowest_mask, lowest_mask, cpu_active_mask); |
992 | 997 | ||
993 | /* | 998 | /* |
994 | * At this point we have built a mask of cpus representing the | 999 | * At this point we have built a mask of cpus representing the |
@@ -998,7 +1003,7 @@ static int find_lowest_rq(struct task_struct *task) | |||
998 | * We prioritize the last cpu that the task executed on since | 1003 | * We prioritize the last cpu that the task executed on since |
999 | * it is most likely cache-hot in that location. | 1004 | * it is most likely cache-hot in that location. |
1000 | */ | 1005 | */ |
1001 | if (cpu_isset(cpu, *lowest_mask)) | 1006 | if (cpumask_test_cpu(cpu, lowest_mask)) |
1002 | return cpu; | 1007 | return cpu; |
1003 | 1008 | ||
1004 | /* | 1009 | /* |
@@ -1013,7 +1018,8 @@ static int find_lowest_rq(struct task_struct *task) | |||
1013 | cpumask_t domain_mask; | 1018 | cpumask_t domain_mask; |
1014 | int best_cpu; | 1019 | int best_cpu; |
1015 | 1020 | ||
1016 | cpus_and(domain_mask, sd->span, *lowest_mask); | 1021 | cpumask_and(&domain_mask, sched_domain_span(sd), |
1022 | lowest_mask); | ||
1017 | 1023 | ||
1018 | best_cpu = pick_optimal_cpu(this_cpu, | 1024 | best_cpu = pick_optimal_cpu(this_cpu, |
1019 | &domain_mask); | 1025 | &domain_mask); |
@@ -1054,8 +1060,8 @@ static struct rq *find_lock_lowest_rq(struct task_struct *task, struct rq *rq) | |||
1054 | * Also make sure that it wasn't scheduled on its rq. | 1060 | * Also make sure that it wasn't scheduled on its rq. |
1055 | */ | 1061 | */ |
1056 | if (unlikely(task_rq(task) != rq || | 1062 | if (unlikely(task_rq(task) != rq || |
1057 | !cpu_isset(lowest_rq->cpu, | 1063 | !cpumask_test_cpu(lowest_rq->cpu, |
1058 | task->cpus_allowed) || | 1064 | &task->cpus_allowed) || |
1059 | task_running(rq, task) || | 1065 | task_running(rq, task) || |
1060 | !task->se.on_rq)) { | 1066 | !task->se.on_rq)) { |
1061 | 1067 | ||
@@ -1176,7 +1182,7 @@ static int pull_rt_task(struct rq *this_rq) | |||
1176 | 1182 | ||
1177 | next = pick_next_task_rt(this_rq); | 1183 | next = pick_next_task_rt(this_rq); |
1178 | 1184 | ||
1179 | for_each_cpu_mask_nr(cpu, this_rq->rd->rto_mask) { | 1185 | for_each_cpu(cpu, this_rq->rd->rto_mask) { |
1180 | if (this_cpu == cpu) | 1186 | if (this_cpu == cpu) |
1181 | continue; | 1187 | continue; |
1182 | 1188 | ||
@@ -1305,9 +1311,9 @@ move_one_task_rt(struct rq *this_rq, int this_cpu, struct rq *busiest, | |||
1305 | } | 1311 | } |
1306 | 1312 | ||
1307 | static void set_cpus_allowed_rt(struct task_struct *p, | 1313 | static void set_cpus_allowed_rt(struct task_struct *p, |
1308 | const cpumask_t *new_mask) | 1314 | const struct cpumask *new_mask) |
1309 | { | 1315 | { |
1310 | int weight = cpus_weight(*new_mask); | 1316 | int weight = cpumask_weight(new_mask); |
1311 | 1317 | ||
1312 | BUG_ON(!rt_task(p)); | 1318 | BUG_ON(!rt_task(p)); |
1313 | 1319 | ||
@@ -1328,7 +1334,7 @@ static void set_cpus_allowed_rt(struct task_struct *p, | |||
1328 | update_rt_migration(rq); | 1334 | update_rt_migration(rq); |
1329 | } | 1335 | } |
1330 | 1336 | ||
1331 | p->cpus_allowed = *new_mask; | 1337 | cpumask_copy(&p->cpus_allowed, new_mask); |
1332 | p->rt.nr_cpus_allowed = weight; | 1338 | p->rt.nr_cpus_allowed = weight; |
1333 | } | 1339 | } |
1334 | 1340 | ||
@@ -1371,6 +1377,14 @@ static void switched_from_rt(struct rq *rq, struct task_struct *p, | |||
1371 | if (!rq->rt.rt_nr_running) | 1377 | if (!rq->rt.rt_nr_running) |
1372 | pull_rt_task(rq); | 1378 | pull_rt_task(rq); |
1373 | } | 1379 | } |
1380 | |||
1381 | static inline void init_sched_rt_class(void) | ||
1382 | { | ||
1383 | unsigned int i; | ||
1384 | |||
1385 | for_each_possible_cpu(i) | ||
1386 | alloc_cpumask_var(&per_cpu(local_cpu_mask, i), GFP_KERNEL); | ||
1387 | } | ||
1374 | #endif /* CONFIG_SMP */ | 1388 | #endif /* CONFIG_SMP */ |
1375 | 1389 | ||
1376 | /* | 1390 | /* |
@@ -1541,3 +1555,4 @@ static void print_rt_stats(struct seq_file *m, int cpu) | |||
1541 | rcu_read_unlock(); | 1555 | rcu_read_unlock(); |
1542 | } | 1556 | } |
1543 | #endif /* CONFIG_SCHED_DEBUG */ | 1557 | #endif /* CONFIG_SCHED_DEBUG */ |
1558 | |||
diff --git a/kernel/sched_stats.h b/kernel/sched_stats.h index 3b01098164c8..f2773b5d1226 100644 --- a/kernel/sched_stats.h +++ b/kernel/sched_stats.h | |||
@@ -42,7 +42,8 @@ static int show_schedstat(struct seq_file *seq, void *v) | |||
42 | for_each_domain(cpu, sd) { | 42 | for_each_domain(cpu, sd) { |
43 | enum cpu_idle_type itype; | 43 | enum cpu_idle_type itype; |
44 | 44 | ||
45 | cpumask_scnprintf(mask_str, mask_len, sd->span); | 45 | cpumask_scnprintf(mask_str, mask_len, |
46 | sched_domain_span(sd)); | ||
46 | seq_printf(seq, "domain%d %s", dcount++, mask_str); | 47 | seq_printf(seq, "domain%d %s", dcount++, mask_str); |
47 | for (itype = CPU_IDLE; itype < CPU_MAX_IDLE_TYPES; | 48 | for (itype = CPU_IDLE; itype < CPU_MAX_IDLE_TYPES; |
48 | itype++) { | 49 | itype++) { |
diff --git a/kernel/taskstats.c b/kernel/taskstats.c index bd6be76303cf..6d7dc4ec4aa5 100644 --- a/kernel/taskstats.c +++ b/kernel/taskstats.c | |||
@@ -352,7 +352,7 @@ static int parse(struct nlattr *na, cpumask_t *mask) | |||
352 | if (!data) | 352 | if (!data) |
353 | return -ENOMEM; | 353 | return -ENOMEM; |
354 | nla_strlcpy(data, na, len); | 354 | nla_strlcpy(data, na, len); |
355 | ret = cpulist_parse(data, *mask); | 355 | ret = cpulist_parse(data, mask); |
356 | kfree(data); | 356 | kfree(data); |
357 | return ret; | 357 | return ret; |
358 | } | 358 | } |
diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c index f8d968063cea..ea2f48af83cf 100644 --- a/kernel/time/clockevents.c +++ b/kernel/time/clockevents.c | |||
@@ -166,6 +166,8 @@ static void clockevents_notify_released(void) | |||
166 | void clockevents_register_device(struct clock_event_device *dev) | 166 | void clockevents_register_device(struct clock_event_device *dev) |
167 | { | 167 | { |
168 | BUG_ON(dev->mode != CLOCK_EVT_MODE_UNUSED); | 168 | BUG_ON(dev->mode != CLOCK_EVT_MODE_UNUSED); |
169 | BUG_ON(!dev->cpumask); | ||
170 | |||
169 | /* | 171 | /* |
170 | * A nsec2cyc multiplicator of 0 is invalid and we'd crash | 172 | * A nsec2cyc multiplicator of 0 is invalid and we'd crash |
171 | * on it, so fix it up and emit a warning: | 173 | * on it, so fix it up and emit a warning: |
diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c index f98a1b7b16e9..9590af2327be 100644 --- a/kernel/time/tick-broadcast.c +++ b/kernel/time/tick-broadcast.c | |||
@@ -150,7 +150,7 @@ static void tick_do_broadcast(cpumask_t mask) | |||
150 | */ | 150 | */ |
151 | cpu = first_cpu(mask); | 151 | cpu = first_cpu(mask); |
152 | td = &per_cpu(tick_cpu_device, cpu); | 152 | td = &per_cpu(tick_cpu_device, cpu); |
153 | td->evtdev->broadcast(mask); | 153 | td->evtdev->broadcast(&mask); |
154 | } | 154 | } |
155 | } | 155 | } |
156 | 156 | ||
diff --git a/kernel/time/tick-common.c b/kernel/time/tick-common.c index df12434b43ca..f8372be74122 100644 --- a/kernel/time/tick-common.c +++ b/kernel/time/tick-common.c | |||
@@ -136,7 +136,7 @@ void tick_setup_periodic(struct clock_event_device *dev, int broadcast) | |||
136 | */ | 136 | */ |
137 | static void tick_setup_device(struct tick_device *td, | 137 | static void tick_setup_device(struct tick_device *td, |
138 | struct clock_event_device *newdev, int cpu, | 138 | struct clock_event_device *newdev, int cpu, |
139 | const cpumask_t *cpumask) | 139 | const struct cpumask *cpumask) |
140 | { | 140 | { |
141 | ktime_t next_event; | 141 | ktime_t next_event; |
142 | void (*handler)(struct clock_event_device *) = NULL; | 142 | void (*handler)(struct clock_event_device *) = NULL; |
@@ -171,8 +171,8 @@ static void tick_setup_device(struct tick_device *td, | |||
171 | * When the device is not per cpu, pin the interrupt to the | 171 | * When the device is not per cpu, pin the interrupt to the |
172 | * current cpu: | 172 | * current cpu: |
173 | */ | 173 | */ |
174 | if (!cpus_equal(newdev->cpumask, *cpumask)) | 174 | if (!cpumask_equal(newdev->cpumask, cpumask)) |
175 | irq_set_affinity(newdev->irq, *cpumask); | 175 | irq_set_affinity(newdev->irq, cpumask); |
176 | 176 | ||
177 | /* | 177 | /* |
178 | * When global broadcasting is active, check if the current | 178 | * When global broadcasting is active, check if the current |
@@ -202,14 +202,14 @@ static int tick_check_new_device(struct clock_event_device *newdev) | |||
202 | spin_lock_irqsave(&tick_device_lock, flags); | 202 | spin_lock_irqsave(&tick_device_lock, flags); |
203 | 203 | ||
204 | cpu = smp_processor_id(); | 204 | cpu = smp_processor_id(); |
205 | if (!cpu_isset(cpu, newdev->cpumask)) | 205 | if (!cpumask_test_cpu(cpu, newdev->cpumask)) |
206 | goto out_bc; | 206 | goto out_bc; |
207 | 207 | ||
208 | td = &per_cpu(tick_cpu_device, cpu); | 208 | td = &per_cpu(tick_cpu_device, cpu); |
209 | curdev = td->evtdev; | 209 | curdev = td->evtdev; |
210 | 210 | ||
211 | /* cpu local device ? */ | 211 | /* cpu local device ? */ |
212 | if (!cpus_equal(newdev->cpumask, cpumask_of_cpu(cpu))) { | 212 | if (!cpumask_equal(newdev->cpumask, cpumask_of(cpu))) { |
213 | 213 | ||
214 | /* | 214 | /* |
215 | * If the cpu affinity of the device interrupt can not | 215 | * If the cpu affinity of the device interrupt can not |
@@ -222,7 +222,7 @@ static int tick_check_new_device(struct clock_event_device *newdev) | |||
222 | * If we have a cpu local device already, do not replace it | 222 | * If we have a cpu local device already, do not replace it |
223 | * by a non cpu local device | 223 | * by a non cpu local device |
224 | */ | 224 | */ |
225 | if (curdev && cpus_equal(curdev->cpumask, cpumask_of_cpu(cpu))) | 225 | if (curdev && cpumask_equal(curdev->cpumask, cpumask_of(cpu))) |
226 | goto out_bc; | 226 | goto out_bc; |
227 | } | 227 | } |
228 | 228 | ||
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index 8f3fc2582d38..76a574bbef97 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c | |||
@@ -144,7 +144,7 @@ void tick_nohz_update_jiffies(void) | |||
144 | if (!ts->tick_stopped) | 144 | if (!ts->tick_stopped) |
145 | return; | 145 | return; |
146 | 146 | ||
147 | cpu_clear(cpu, nohz_cpu_mask); | 147 | cpumask_clear_cpu(cpu, nohz_cpu_mask); |
148 | now = ktime_get(); | 148 | now = ktime_get(); |
149 | ts->idle_waketime = now; | 149 | ts->idle_waketime = now; |
150 | 150 | ||
@@ -301,7 +301,7 @@ void tick_nohz_stop_sched_tick(int inidle) | |||
301 | tick_do_timer_cpu = TICK_DO_TIMER_NONE; | 301 | tick_do_timer_cpu = TICK_DO_TIMER_NONE; |
302 | 302 | ||
303 | if (delta_jiffies > 1) | 303 | if (delta_jiffies > 1) |
304 | cpu_set(cpu, nohz_cpu_mask); | 304 | cpumask_set_cpu(cpu, nohz_cpu_mask); |
305 | 305 | ||
306 | /* Skip reprogram of event if its not changed */ | 306 | /* Skip reprogram of event if its not changed */ |
307 | if (ts->tick_stopped && ktime_equal(expires, dev->next_event)) | 307 | if (ts->tick_stopped && ktime_equal(expires, dev->next_event)) |
@@ -319,7 +319,7 @@ void tick_nohz_stop_sched_tick(int inidle) | |||
319 | /* | 319 | /* |
320 | * sched tick not stopped! | 320 | * sched tick not stopped! |
321 | */ | 321 | */ |
322 | cpu_clear(cpu, nohz_cpu_mask); | 322 | cpumask_clear_cpu(cpu, nohz_cpu_mask); |
323 | goto out; | 323 | goto out; |
324 | } | 324 | } |
325 | 325 | ||
@@ -361,7 +361,7 @@ void tick_nohz_stop_sched_tick(int inidle) | |||
361 | * softirq. | 361 | * softirq. |
362 | */ | 362 | */ |
363 | tick_do_update_jiffies64(ktime_get()); | 363 | tick_do_update_jiffies64(ktime_get()); |
364 | cpu_clear(cpu, nohz_cpu_mask); | 364 | cpumask_clear_cpu(cpu, nohz_cpu_mask); |
365 | } | 365 | } |
366 | raise_softirq_irqoff(TIMER_SOFTIRQ); | 366 | raise_softirq_irqoff(TIMER_SOFTIRQ); |
367 | out: | 367 | out: |
@@ -439,7 +439,7 @@ void tick_nohz_restart_sched_tick(void) | |||
439 | select_nohz_load_balancer(0); | 439 | select_nohz_load_balancer(0); |
440 | now = ktime_get(); | 440 | now = ktime_get(); |
441 | tick_do_update_jiffies64(now); | 441 | tick_do_update_jiffies64(now); |
442 | cpu_clear(cpu, nohz_cpu_mask); | 442 | cpumask_clear_cpu(cpu, nohz_cpu_mask); |
443 | 443 | ||
444 | /* | 444 | /* |
445 | * We stopped the tick in idle. Update process times would miss the | 445 | * We stopped the tick in idle. Update process times would miss the |
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 4185d5221633..0e91f43b6baf 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -2674,7 +2674,7 @@ tracing_cpumask_read(struct file *filp, char __user *ubuf, | |||
2674 | 2674 | ||
2675 | mutex_lock(&tracing_cpumask_update_lock); | 2675 | mutex_lock(&tracing_cpumask_update_lock); |
2676 | 2676 | ||
2677 | len = cpumask_scnprintf(mask_str, count, tracing_cpumask); | 2677 | len = cpumask_scnprintf(mask_str, count, &tracing_cpumask); |
2678 | if (count - len < 2) { | 2678 | if (count - len < 2) { |
2679 | count = -EINVAL; | 2679 | count = -EINVAL; |
2680 | goto out_err; | 2680 | goto out_err; |
@@ -2695,7 +2695,7 @@ tracing_cpumask_write(struct file *filp, const char __user *ubuf, | |||
2695 | int err, cpu; | 2695 | int err, cpu; |
2696 | 2696 | ||
2697 | mutex_lock(&tracing_cpumask_update_lock); | 2697 | mutex_lock(&tracing_cpumask_update_lock); |
2698 | err = cpumask_parse_user(ubuf, count, tracing_cpumask_new); | 2698 | err = cpumask_parse_user(ubuf, count, &tracing_cpumask_new); |
2699 | if (err) | 2699 | if (err) |
2700 | goto err_unlock; | 2700 | goto err_unlock; |
2701 | 2701 | ||