Re: [PATCH 2/2] irq/matrix: Spread managed interrupts on allocation

From: Thomas Gleixner
Date: Fri Sep 07 2018 - 08:47:34 EST


On Fri, 7 Sep 2018, Dou Liyang wrote:
> -int irq_matrix_alloc_managed(struct irq_matrix *m, unsigned int cpu)
> +int irq_matrix_alloc_managed(struct irq_matrix *m, const struct cpumask *msk,
> + unsigned int *mapped_cpu)
> {
> - struct cpumap *cm = per_cpu_ptr(m->maps, cpu);
> unsigned int bit, end = m->alloc_end;
> + unsigned int best_cpu = UINT_MAX;
> + struct cpumap *cm;
>
> - /* Get managed bit which are not allocated */
> - bitmap_andnot(m->scratch_map, cm->managed_map, cm->alloc_map, end);
> - bit = find_first_bit(m->scratch_map, end);
> - if (bit >= end)
> - return -ENOSPC;
> - set_bit(bit, cm->alloc_map);
> - cm->allocated++;
> - m->total_allocated++;
> - trace_irq_matrix_alloc_managed(bit, cpu, m, cm);
> - return bit;
> + if (matrix_find_best_cpu(m, msk, &best_cpu)) {

You can avoid that churn and the extra indentation by simply doing:

if (!matrix_find_best_cpu(m, msk, &best_cpu))
return -ENOSPC;

Hmm?

Thanks,

tglx