diff options
Diffstat (limited to 'kernel/irq/affinity.c')
-rw-r--r-- | kernel/irq/affinity.c | 56 |
1 files changed, 27 insertions, 29 deletions
diff --git a/kernel/irq/affinity.c b/kernel/irq/affinity.c index 118b66d64a53..82e8799374e9 100644 --- a/kernel/irq/affinity.c +++ b/kernel/irq/affinity.c | |||
@@ -9,7 +9,7 @@ | |||
9 | #include <linux/cpu.h> | 9 | #include <linux/cpu.h> |
10 | 10 | ||
11 | static void irq_spread_init_one(struct cpumask *irqmsk, struct cpumask *nmsk, | 11 | static void irq_spread_init_one(struct cpumask *irqmsk, struct cpumask *nmsk, |
12 | int cpus_per_vec) | 12 | unsigned int cpus_per_vec) |
13 | { | 13 | { |
14 | const struct cpumask *siblmsk; | 14 | const struct cpumask *siblmsk; |
15 | int cpu, sibl; | 15 | int cpu, sibl; |
@@ -95,15 +95,17 @@ static int get_nodes_in_cpumask(cpumask_var_t *node_to_cpumask, | |||
95 | } | 95 | } |
96 | 96 | ||
97 | static int __irq_build_affinity_masks(const struct irq_affinity *affd, | 97 | static int __irq_build_affinity_masks(const struct irq_affinity *affd, |
98 | int startvec, int numvecs, int firstvec, | 98 | unsigned int startvec, |
99 | unsigned int numvecs, | ||
100 | unsigned int firstvec, | ||
99 | cpumask_var_t *node_to_cpumask, | 101 | cpumask_var_t *node_to_cpumask, |
100 | const struct cpumask *cpu_mask, | 102 | const struct cpumask *cpu_mask, |
101 | struct cpumask *nmsk, | 103 | struct cpumask *nmsk, |
102 | struct irq_affinity_desc *masks) | 104 | struct irq_affinity_desc *masks) |
103 | { | 105 | { |
104 | int n, nodes, cpus_per_vec, extra_vecs, done = 0; | 106 | unsigned int n, nodes, cpus_per_vec, extra_vecs, done = 0; |
105 | int last_affv = firstvec + numvecs; | 107 | unsigned int last_affv = firstvec + numvecs; |
106 | int curvec = startvec; | 108 | unsigned int curvec = startvec; |
107 | nodemask_t nodemsk = NODE_MASK_NONE; | 109 | nodemask_t nodemsk = NODE_MASK_NONE; |
108 | 110 | ||
109 | if (!cpumask_weight(cpu_mask)) | 111 | if (!cpumask_weight(cpu_mask)) |
@@ -117,18 +119,16 @@ static int __irq_build_affinity_masks(const struct irq_affinity *affd, | |||
117 | */ | 119 | */ |
118 | if (numvecs <= nodes) { | 120 | if (numvecs <= nodes) { |
119 | for_each_node_mask(n, nodemsk) { | 121 | for_each_node_mask(n, nodemsk) { |
120 | cpumask_or(&masks[curvec].mask, | 122 | cpumask_or(&masks[curvec].mask, &masks[curvec].mask, |
121 | &masks[curvec].mask, | 123 | node_to_cpumask[n]); |
122 | node_to_cpumask[n]); | ||
123 | if (++curvec == last_affv) | 124 | if (++curvec == last_affv) |
124 | curvec = firstvec; | 125 | curvec = firstvec; |
125 | } | 126 | } |
126 | done = numvecs; | 127 | return numvecs; |
127 | goto out; | ||
128 | } | 128 | } |
129 | 129 | ||
130 | for_each_node_mask(n, nodemsk) { | 130 | for_each_node_mask(n, nodemsk) { |
131 | int ncpus, v, vecs_to_assign, vecs_per_node; | 131 | unsigned int ncpus, v, vecs_to_assign, vecs_per_node; |
132 | 132 | ||
133 | /* Spread the vectors per node */ | 133 | /* Spread the vectors per node */ |
134 | vecs_per_node = (numvecs - (curvec - firstvec)) / nodes; | 134 | vecs_per_node = (numvecs - (curvec - firstvec)) / nodes; |
@@ -163,8 +163,6 @@ static int __irq_build_affinity_masks(const struct irq_affinity *affd, | |||
163 | curvec = firstvec; | 163 | curvec = firstvec; |
164 | --nodes; | 164 | --nodes; |
165 | } | 165 | } |
166 | |||
167 | out: | ||
168 | return done; | 166 | return done; |
169 | } | 167 | } |
170 | 168 | ||
@@ -174,13 +172,14 @@ out: | |||
174 | * 2) spread other possible CPUs on these vectors | 172 | * 2) spread other possible CPUs on these vectors |
175 | */ | 173 | */ |
176 | static int irq_build_affinity_masks(const struct irq_affinity *affd, | 174 | static int irq_build_affinity_masks(const struct irq_affinity *affd, |
177 | int startvec, int numvecs, int firstvec, | 175 | unsigned int startvec, unsigned int numvecs, |
176 | unsigned int firstvec, | ||
178 | struct irq_affinity_desc *masks) | 177 | struct irq_affinity_desc *masks) |
179 | { | 178 | { |
180 | int curvec = startvec, nr_present, nr_others; | 179 | unsigned int curvec = startvec, nr_present, nr_others; |
181 | int ret = -ENOMEM; | ||
182 | cpumask_var_t nmsk, npresmsk; | ||
183 | cpumask_var_t *node_to_cpumask; | 180 | cpumask_var_t *node_to_cpumask; |
181 | cpumask_var_t nmsk, npresmsk; | ||
182 | int ret = -ENOMEM; | ||
184 | 183 | ||
185 | if (!zalloc_cpumask_var(&nmsk, GFP_KERNEL)) | 184 | if (!zalloc_cpumask_var(&nmsk, GFP_KERNEL)) |
186 | return ret; | 185 | return ret; |
@@ -239,12 +238,10 @@ static int irq_build_affinity_masks(const struct irq_affinity *affd, | |||
239 | * Returns the irq_affinity_desc pointer or NULL if allocation failed. | 238 | * Returns the irq_affinity_desc pointer or NULL if allocation failed. |
240 | */ | 239 | */ |
241 | struct irq_affinity_desc * | 240 | struct irq_affinity_desc * |
242 | irq_create_affinity_masks(int nvecs, const struct irq_affinity *affd) | 241 | irq_create_affinity_masks(unsigned int nvecs, const struct irq_affinity *affd) |
243 | { | 242 | { |
244 | int affvecs = nvecs - affd->pre_vectors - affd->post_vectors; | 243 | unsigned int affvecs, curvec, usedvecs, nr_sets, i; |
245 | int curvec, usedvecs; | ||
246 | struct irq_affinity_desc *masks = NULL; | 244 | struct irq_affinity_desc *masks = NULL; |
247 | int i, nr_sets; | ||
248 | 245 | ||
249 | /* | 246 | /* |
250 | * If there aren't any vectors left after applying the pre/post | 247 | * If there aren't any vectors left after applying the pre/post |
@@ -264,16 +261,17 @@ irq_create_affinity_masks(int nvecs, const struct irq_affinity *affd) | |||
264 | * Spread on present CPUs starting from affd->pre_vectors. If we | 261 | * Spread on present CPUs starting from affd->pre_vectors. If we |
265 | * have multiple sets, build each sets affinity mask separately. | 262 | * have multiple sets, build each sets affinity mask separately. |
266 | */ | 263 | */ |
264 | affvecs = nvecs - affd->pre_vectors - affd->post_vectors; | ||
267 | nr_sets = affd->nr_sets; | 265 | nr_sets = affd->nr_sets; |
268 | if (!nr_sets) | 266 | if (!nr_sets) |
269 | nr_sets = 1; | 267 | nr_sets = 1; |
270 | 268 | ||
271 | for (i = 0, usedvecs = 0; i < nr_sets; i++) { | 269 | for (i = 0, usedvecs = 0; i < nr_sets; i++) { |
272 | int this_vecs = affd->sets ? affd->sets[i] : affvecs; | 270 | unsigned int this_vecs = affd->sets ? affd->sets[i] : affvecs; |
273 | int ret; | 271 | int ret; |
274 | 272 | ||
275 | ret = irq_build_affinity_masks(affd, curvec, this_vecs, | 273 | ret = irq_build_affinity_masks(affd, curvec, this_vecs, |
276 | curvec, masks); | 274 | curvec, masks); |
277 | if (ret) { | 275 | if (ret) { |
278 | kfree(masks); | 276 | kfree(masks); |
279 | return NULL; | 277 | return NULL; |
@@ -303,17 +301,17 @@ irq_create_affinity_masks(int nvecs, const struct irq_affinity *affd) | |||
303 | * @maxvec: The maximum number of vectors available | 301 | * @maxvec: The maximum number of vectors available |
304 | * @affd: Description of the affinity requirements | 302 | * @affd: Description of the affinity requirements |
305 | */ | 303 | */ |
306 | int irq_calc_affinity_vectors(int minvec, int maxvec, const struct irq_affinity *affd) | 304 | unsigned int irq_calc_affinity_vectors(unsigned int minvec, unsigned int maxvec, |
305 | const struct irq_affinity *affd) | ||
307 | { | 306 | { |
308 | int resv = affd->pre_vectors + affd->post_vectors; | 307 | unsigned int resv = affd->pre_vectors + affd->post_vectors; |
309 | int vecs = maxvec - resv; | 308 | unsigned int set_vecs; |
310 | int set_vecs; | ||
311 | 309 | ||
312 | if (resv > minvec) | 310 | if (resv > minvec) |
313 | return 0; | 311 | return 0; |
314 | 312 | ||
315 | if (affd->nr_sets) { | 313 | if (affd->nr_sets) { |
316 | int i; | 314 | unsigned int i; |
317 | 315 | ||
318 | for (i = 0, set_vecs = 0; i < affd->nr_sets; i++) | 316 | for (i = 0, set_vecs = 0; i < affd->nr_sets; i++) |
319 | set_vecs += affd->sets[i]; | 317 | set_vecs += affd->sets[i]; |
@@ -323,5 +321,5 @@ int irq_calc_affinity_vectors(int minvec, int maxvec, const struct irq_affinity | |||
323 | put_online_cpus(); | 321 | put_online_cpus(); |
324 | } | 322 | } |
325 | 323 | ||
326 | return resv + min(set_vecs, vecs); | 324 | return resv + min(set_vecs, maxvec - resv); |
327 | } | 325 | } |