Commit b1beed72 authored by Yury Norov's avatar Yury Norov Committed by Jakub Kicinski
Browse files

lib/cpumask: reorganize cpumask_local_spread() logic



Now after moving all NUMA logic into sched_numa_find_nth_cpu(),
else-branch of cpumask_local_spread() is just a function call, and
we can simplify logic by using ternary operator.

While here, replace BUG() with WARN_ON().

Signed-off-by: default avatarYury Norov <yury.norov@gmail.com>
Acked-by: default avatarTariq Toukan <tariqt@nvidia.com>
Reviewed-by: default avatarJacob Keller <jacob.e.keller@intel.com>
Reviewed-by: default avatarPeter Lafreniere <peter@n8pjl.ca>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 406d394a
Loading
Loading
Loading
Loading
+6 −10
Original line number Diff line number Diff line
@@ -127,17 +127,13 @@ unsigned int cpumask_local_spread(unsigned int i, int node)
	/* Wrap: we always want a cpu. */
	i %= num_online_cpus();

	if (node == NUMA_NO_NODE) {
		cpu = cpumask_nth(i, cpu_online_mask);
		if (cpu < nr_cpu_ids)
			return cpu;
	} else {
		cpu = sched_numa_find_nth_cpu(cpu_online_mask, i, node);
		if (cpu < nr_cpu_ids)
	cpu = (node == NUMA_NO_NODE) ?
		cpumask_nth(i, cpu_online_mask) :
		sched_numa_find_nth_cpu(cpu_online_mask, i, node);

	WARN_ON(cpu >= nr_cpu_ids);
	return cpu;
}
	BUG();
}
EXPORT_SYMBOL(cpumask_local_spread);

static DEFINE_PER_CPU(int, distribute_cpu_mask_prev);