diff options
author | Ming Lei <ming.lei@redhat.com> | 2019-01-25 04:53:43 -0500 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2019-02-10 13:53:55 -0500 |
commit | 347253c42d7c673aa2a659d756bc7ff893459247 (patch) | |
tree | d35cf74694af51929f509bc1b8c5c7d16314c488 | |
parent | 434537bbd50fefc89c1e29170bf4030ae3ec445a (diff) |
genirq/affinity: Move allocation of 'node_to_cpumask' to irq_build_affinity_masks()
'node_to_cpumask' is just one temparay variable for irq_build_affinity_masks(),
so move it into irq_build_affinity_masks().
No functioanl change.
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org
Cc: Sagi Grimberg <sagi@grimberg.me>
Cc: linux-nvme@lists.infradead.org
Cc: linux-pci@vger.kernel.org
Link: https://lkml.kernel.org/r/20190125095347.17950-2-ming.lei@redhat.com
-rw-r--r-- | kernel/irq/affinity.c | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/kernel/irq/affinity.c b/kernel/irq/affinity.c index 45b68b4ea48b..118b66d64a53 100644 --- a/kernel/irq/affinity.c +++ b/kernel/irq/affinity.c | |||
@@ -175,18 +175,22 @@ out: | |||
175 | */ | 175 | */ |
176 | static int irq_build_affinity_masks(const struct irq_affinity *affd, | 176 | static int irq_build_affinity_masks(const struct irq_affinity *affd, |
177 | int startvec, int numvecs, int firstvec, | 177 | int startvec, int numvecs, int firstvec, |
178 | cpumask_var_t *node_to_cpumask, | ||
179 | struct irq_affinity_desc *masks) | 178 | struct irq_affinity_desc *masks) |
180 | { | 179 | { |
181 | int curvec = startvec, nr_present, nr_others; | 180 | int curvec = startvec, nr_present, nr_others; |
182 | int ret = -ENOMEM; | 181 | int ret = -ENOMEM; |
183 | cpumask_var_t nmsk, npresmsk; | 182 | cpumask_var_t nmsk, npresmsk; |
183 | cpumask_var_t *node_to_cpumask; | ||
184 | 184 | ||
185 | if (!zalloc_cpumask_var(&nmsk, GFP_KERNEL)) | 185 | if (!zalloc_cpumask_var(&nmsk, GFP_KERNEL)) |
186 | return ret; | 186 | return ret; |
187 | 187 | ||
188 | if (!zalloc_cpumask_var(&npresmsk, GFP_KERNEL)) | 188 | if (!zalloc_cpumask_var(&npresmsk, GFP_KERNEL)) |
189 | goto fail; | 189 | goto fail_nmsk; |
190 | |||
191 | node_to_cpumask = alloc_node_to_cpumask(); | ||
192 | if (!node_to_cpumask) | ||
193 | goto fail_npresmsk; | ||
190 | 194 | ||
191 | ret = 0; | 195 | ret = 0; |
192 | /* Stabilize the cpumasks */ | 196 | /* Stabilize the cpumasks */ |
@@ -217,9 +221,12 @@ static int irq_build_affinity_masks(const struct irq_affinity *affd, | |||
217 | if (nr_present < numvecs) | 221 | if (nr_present < numvecs) |
218 | WARN_ON(nr_present + nr_others < numvecs); | 222 | WARN_ON(nr_present + nr_others < numvecs); |
219 | 223 | ||
224 | free_node_to_cpumask(node_to_cpumask); | ||
225 | |||
226 | fail_npresmsk: | ||
220 | free_cpumask_var(npresmsk); | 227 | free_cpumask_var(npresmsk); |
221 | 228 | ||
222 | fail: | 229 | fail_nmsk: |
223 | free_cpumask_var(nmsk); | 230 | free_cpumask_var(nmsk); |
224 | return ret; | 231 | return ret; |
225 | } | 232 | } |
@@ -236,7 +243,6 @@ irq_create_affinity_masks(int nvecs, const struct irq_affinity *affd) | |||
236 | { | 243 | { |
237 | int affvecs = nvecs - affd->pre_vectors - affd->post_vectors; | 244 | int affvecs = nvecs - affd->pre_vectors - affd->post_vectors; |
238 | int curvec, usedvecs; | 245 | int curvec, usedvecs; |
239 | cpumask_var_t *node_to_cpumask; | ||
240 | struct irq_affinity_desc *masks = NULL; | 246 | struct irq_affinity_desc *masks = NULL; |
241 | int i, nr_sets; | 247 | int i, nr_sets; |
242 | 248 | ||
@@ -247,13 +253,9 @@ irq_create_affinity_masks(int nvecs, const struct irq_affinity *affd) | |||
247 | if (nvecs == affd->pre_vectors + affd->post_vectors) | 253 | if (nvecs == affd->pre_vectors + affd->post_vectors) |
248 | return NULL; | 254 | return NULL; |
249 | 255 | ||
250 | node_to_cpumask = alloc_node_to_cpumask(); | ||
251 | if (!node_to_cpumask) | ||
252 | return NULL; | ||
253 | |||
254 | masks = kcalloc(nvecs, sizeof(*masks), GFP_KERNEL); | 256 | masks = kcalloc(nvecs, sizeof(*masks), GFP_KERNEL); |
255 | if (!masks) | 257 | if (!masks) |
256 | goto outnodemsk; | 258 | return NULL; |
257 | 259 | ||
258 | /* Fill out vectors at the beginning that don't need affinity */ | 260 | /* Fill out vectors at the beginning that don't need affinity */ |
259 | for (curvec = 0; curvec < affd->pre_vectors; curvec++) | 261 | for (curvec = 0; curvec < affd->pre_vectors; curvec++) |
@@ -271,11 +273,10 @@ irq_create_affinity_masks(int nvecs, const struct irq_affinity *affd) | |||
271 | int ret; | 273 | int ret; |
272 | 274 | ||
273 | ret = irq_build_affinity_masks(affd, curvec, this_vecs, | 275 | ret = irq_build_affinity_masks(affd, curvec, this_vecs, |
274 | curvec, node_to_cpumask, masks); | 276 | curvec, masks); |
275 | if (ret) { | 277 | if (ret) { |
276 | kfree(masks); | 278 | kfree(masks); |
277 | masks = NULL; | 279 | return NULL; |
278 | goto outnodemsk; | ||
279 | } | 280 | } |
280 | curvec += this_vecs; | 281 | curvec += this_vecs; |
281 | usedvecs += this_vecs; | 282 | usedvecs += this_vecs; |
@@ -293,8 +294,6 @@ irq_create_affinity_masks(int nvecs, const struct irq_affinity *affd) | |||
293 | for (i = affd->pre_vectors; i < nvecs - affd->post_vectors; i++) | 294 | for (i = affd->pre_vectors; i < nvecs - affd->post_vectors; i++) |
294 | masks[i].is_managed = 1; | 295 | masks[i].is_managed = 1; |
295 | 296 | ||
296 | outnodemsk: | ||
297 | free_node_to_cpumask(node_to_cpumask); | ||
298 | return masks; | 297 | return masks; |
299 | } | 298 | } |
300 | 299 | ||