On Sat, 8 Sep 2018, Dou Liyang wrote:
> +/* Find the best CPU which has the lowest vector allocation count */
> +static int matrix_find_best_cpu(struct irq_matrix *m,
> +                             const struct cpumask *msk, int *best_cpu)
> +{
> +     unsigned int cpu, maxavl = 0;
> +     struct cpumap *cm;
> +
> +     for_each_cpu(cpu, msk) {
> +             cm = per_cpu_ptr(m->maps, cpu);
> +
> +             if (!cm->online || cm->available <= maxavl)
> +                     continue;
> +
> +             *best_cpu = cpu;
> +             maxavl = cm->available;
> +     }
> +
> +     return maxavl;

This return value makes no sense whatsoever. Why not doing the obvious

static unsigned int matrix_find_best_cpu(struct irq_matrix *m,
                                         const struct cpumask *msk)
{
        unsigned int cpu, best_cpu, maxavl = 0;

        best_cpu = UINT_MAX;
        .....
        return best_cpu;
}

and at the call site:

       cpu = matrix_find_best_cpu();
       if (cpu == UINT_MAX)
                return -ENOSPC;

Hmm?

> +     cm = per_cpu_ptr(m->maps, best_cpu);
> +     bit = matrix_alloc_area(m, cm, 1, false);
> +     if (bit < m->alloc_end) {

So if you're removing one indentation level, then it'd be consequent to
remove this one as well while at it :)

Thanks,

        tglx

Reply via email to