Commit d036e67b40f52bdd95392390108defbac7e53837
1 parent
6b954823c2
cpumask: convert kernel/irq
Impact: Reduce stack usage, use new cpumask API. ALPHA mod! Main change is that irq_default_affinity becomes a cpumask_var_t, so treat it as a pointer (this effects alpha). Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Showing 4 changed files with 33 additions and 15 deletions Side-by-side Diff
arch/alpha/kernel/irq.c
... | ... | @@ -50,7 +50,8 @@ |
50 | 50 | if (!irq_desc[irq].chip->set_affinity || irq_user_affinity[irq]) |
51 | 51 | return 1; |
52 | 52 | |
53 | - while (!cpu_possible(cpu) || !cpu_isset(cpu, irq_default_affinity)) | |
53 | + while (!cpu_possible(cpu) || | |
54 | + !cpumask_test_cpu(cpu, irq_default_affinity)) | |
54 | 55 | cpu = (cpu < (NR_CPUS-1) ? cpu + 1 : 0); |
55 | 56 | last_cpu = cpu; |
56 | 57 |
include/linux/interrupt.h
... | ... | @@ -109,7 +109,7 @@ |
109 | 109 | |
110 | 110 | #if defined(CONFIG_SMP) && defined(CONFIG_GENERIC_HARDIRQS) |
111 | 111 | |
112 | -extern cpumask_t irq_default_affinity; | |
112 | +extern cpumask_var_t irq_default_affinity; | |
113 | 113 | |
114 | 114 | extern int irq_set_affinity(unsigned int irq, const struct cpumask *cpumask); |
115 | 115 | extern int irq_can_set_affinity(unsigned int irq); |
kernel/irq/manage.c
... | ... | @@ -16,8 +16,15 @@ |
16 | 16 | #include "internals.h" |
17 | 17 | |
18 | 18 | #ifdef CONFIG_SMP |
19 | +cpumask_var_t irq_default_affinity; | |
19 | 20 | |
20 | -cpumask_t irq_default_affinity = CPU_MASK_ALL; | |
21 | +static int init_irq_default_affinity(void) | |
22 | +{ | |
23 | + alloc_cpumask_var(&irq_default_affinity, GFP_KERNEL); | |
24 | + cpumask_setall(irq_default_affinity); | |
25 | + return 0; | |
26 | +} | |
27 | +core_initcall(init_irq_default_affinity); | |
21 | 28 | |
22 | 29 | /** |
23 | 30 | * synchronize_irq - wait for pending IRQ handlers (on other CPUs) |
... | ... | @@ -127,7 +134,7 @@ |
127 | 134 | desc->status &= ~IRQ_AFFINITY_SET; |
128 | 135 | } |
129 | 136 | |
130 | - cpumask_and(&desc->affinity, cpu_online_mask, &irq_default_affinity); | |
137 | + cpumask_and(&desc->affinity, cpu_online_mask, irq_default_affinity); | |
131 | 138 | set_affinity: |
132 | 139 | desc->chip->set_affinity(irq, &desc->affinity); |
133 | 140 |
kernel/irq/proc.c
... | ... | @@ -20,7 +20,7 @@ |
20 | 20 | static int irq_affinity_proc_show(struct seq_file *m, void *v) |
21 | 21 | { |
22 | 22 | struct irq_desc *desc = irq_to_desc((long)m->private); |
23 | - cpumask_t *mask = &desc->affinity; | |
23 | + const struct cpumask *mask = &desc->affinity; | |
24 | 24 | |
25 | 25 | #ifdef CONFIG_GENERIC_PENDING_IRQ |
26 | 26 | if (desc->status & IRQ_MOVE_PENDING) |
... | ... | @@ -93,7 +93,7 @@ |
93 | 93 | |
94 | 94 | static int default_affinity_show(struct seq_file *m, void *v) |
95 | 95 | { |
96 | - seq_cpumask(m, &irq_default_affinity); | |
96 | + seq_cpumask(m, irq_default_affinity); | |
97 | 97 | seq_putc(m, '\n'); |
98 | 98 | return 0; |
99 | 99 | } |
100 | 100 | |
101 | 101 | |
102 | 102 | |
103 | 103 | |
104 | 104 | |
105 | 105 | |
... | ... | @@ -101,27 +101,37 @@ |
101 | 101 | static ssize_t default_affinity_write(struct file *file, |
102 | 102 | const char __user *buffer, size_t count, loff_t *ppos) |
103 | 103 | { |
104 | - cpumask_t new_value; | |
104 | + cpumask_var_t new_value; | |
105 | 105 | int err; |
106 | 106 | |
107 | - err = cpumask_parse_user(buffer, count, &new_value); | |
107 | + if (!alloc_cpumask_var(&new_value, GFP_KERNEL)) | |
108 | + return -ENOMEM; | |
109 | + | |
110 | + err = cpumask_parse_user(buffer, count, new_value); | |
108 | 111 | if (err) |
109 | - return err; | |
112 | + goto out; | |
110 | 113 | |
111 | - if (!is_affinity_mask_valid(new_value)) | |
112 | - return -EINVAL; | |
114 | + if (!is_affinity_mask_valid(new_value)) { | |
115 | + err = -EINVAL; | |
116 | + goto out; | |
117 | + } | |
113 | 118 | |
114 | 119 | /* |
115 | 120 | * Do not allow disabling IRQs completely - it's a too easy |
116 | 121 | * way to make the system unusable accidentally :-) At least |
117 | 122 | * one online CPU still has to be targeted. |
118 | 123 | */ |
119 | - if (!cpus_intersects(new_value, cpu_online_map)) | |
120 | - return -EINVAL; | |
124 | + if (!cpumask_intersects(new_value, cpu_online_mask)) { | |
125 | + err = -EINVAL; | |
126 | + goto out; | |
127 | + } | |
121 | 128 | |
122 | - irq_default_affinity = new_value; | |
129 | + cpumask_copy(irq_default_affinity, new_value); | |
130 | + err = count; | |
123 | 131 | |
124 | - return count; | |
132 | +out: | |
133 | + free_cpumask_var(new_value); | |
134 | + return err; | |
125 | 135 | } |
126 | 136 | |
127 | 137 | static int default_affinity_open(struct inode *inode, struct file *file) |