lkml.org 
[lkml]   [2018]   [Sep]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 1/2] irq/matrix: Split out the CPU finding code into a helper
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

\
 
 \ /
  Last update: 2018-09-08 12:00    [W:0.084 / U:0.208 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site