Skip to content

Commit 1f962d9

Browse files
Ming LeiKAGA-KOKO
authored andcommitted
genirq/affinity: Pass affinity managed mask array to irq_build_affinity_masks
Pass affinity managed mask array to irq_build_affinity_masks() so that the index of the first affinity managed vector is always zero. This allows to simplify the implementation a bit. Signed-off-by: Ming Lei <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: John Garry <[email protected]> Reviewed-by: Jens Axboe <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent cdf07f0 commit 1f962d9

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

kernel/irq/affinity.c

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -246,14 +246,13 @@ static void alloc_nodes_vectors(unsigned int numvecs,
246246

247247
static int __irq_build_affinity_masks(unsigned int startvec,
248248
unsigned int numvecs,
249-
unsigned int firstvec,
250249
cpumask_var_t *node_to_cpumask,
251250
const struct cpumask *cpu_mask,
252251
struct cpumask *nmsk,
253252
struct irq_affinity_desc *masks)
254253
{
255254
unsigned int i, n, nodes, cpus_per_vec, extra_vecs, done = 0;
256-
unsigned int last_affv = firstvec + numvecs;
255+
unsigned int last_affv = numvecs;
257256
unsigned int curvec = startvec;
258257
nodemask_t nodemsk = NODE_MASK_NONE;
259258
struct node_vectors *node_vectors;
@@ -273,7 +272,7 @@ static int __irq_build_affinity_masks(unsigned int startvec,
273272
cpumask_and(nmsk, cpu_mask, node_to_cpumask[n]);
274273
cpumask_or(&masks[curvec].mask, &masks[curvec].mask, nmsk);
275274
if (++curvec == last_affv)
276-
curvec = firstvec;
275+
curvec = 0;
277276
}
278277
return numvecs;
279278
}
@@ -321,7 +320,7 @@ static int __irq_build_affinity_masks(unsigned int startvec,
321320
* may start anywhere
322321
*/
323322
if (curvec >= last_affv)
324-
curvec = firstvec;
323+
curvec = 0;
325324
irq_spread_init_one(&masks[curvec].mask, nmsk,
326325
cpus_per_vec);
327326
}
@@ -336,11 +335,10 @@ static int __irq_build_affinity_masks(unsigned int startvec,
336335
* 1) spread present CPU on these vectors
337336
* 2) spread other possible CPUs on these vectors
338337
*/
339-
static int irq_build_affinity_masks(unsigned int startvec, unsigned int numvecs,
338+
static int irq_build_affinity_masks(unsigned int numvecs,
340339
struct irq_affinity_desc *masks)
341340
{
342-
unsigned int curvec = startvec, nr_present = 0, nr_others = 0;
343-
unsigned int firstvec = startvec;
341+
unsigned int curvec = 0, nr_present = 0, nr_others = 0;
344342
cpumask_var_t *node_to_cpumask;
345343
cpumask_var_t nmsk, npresmsk;
346344
int ret = -ENOMEM;
@@ -360,9 +358,8 @@ static int irq_build_affinity_masks(unsigned int startvec, unsigned int numvecs,
360358
build_node_to_cpumask(node_to_cpumask);
361359

362360
/* Spread on present CPUs starting from affd->pre_vectors */
363-
ret = __irq_build_affinity_masks(curvec, numvecs, firstvec,
364-
node_to_cpumask, cpu_present_mask,
365-
nmsk, masks);
361+
ret = __irq_build_affinity_masks(curvec, numvecs, node_to_cpumask,
362+
cpu_present_mask, nmsk, masks);
366363
if (ret < 0)
367364
goto fail_build_affinity;
368365
nr_present = ret;
@@ -374,13 +371,12 @@ static int irq_build_affinity_masks(unsigned int startvec, unsigned int numvecs,
374371
* out vectors.
375372
*/
376373
if (nr_present >= numvecs)
377-
curvec = firstvec;
374+
curvec = 0;
378375
else
379-
curvec = firstvec + nr_present;
376+
curvec = nr_present;
380377
cpumask_andnot(npresmsk, cpu_possible_mask, cpu_present_mask);
381-
ret = __irq_build_affinity_masks(curvec, numvecs, firstvec,
382-
node_to_cpumask, npresmsk, nmsk,
383-
masks);
378+
ret = __irq_build_affinity_masks(curvec, numvecs, node_to_cpumask,
379+
npresmsk, nmsk, masks);
384380
if (ret >= 0)
385381
nr_others = ret;
386382

@@ -463,7 +459,7 @@ irq_create_affinity_masks(unsigned int nvecs, struct irq_affinity *affd)
463459
unsigned int this_vecs = affd->set_size[i];
464460
int ret;
465461

466-
ret = irq_build_affinity_masks(curvec, this_vecs, masks);
462+
ret = irq_build_affinity_masks(this_vecs, &masks[curvec]);
467463
if (ret) {
468464
kfree(masks);
469465
return NULL;

0 commit comments

Comments
 (0)