diff options
author | Yury Norov <yury.norov@gmail.com> | 2023-01-20 20:24:32 -0800 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2023-02-07 18:20:00 -0800 |
commit | b1beed72b8b75d365fdbc925da856c212195051b (patch) | |
tree | e8f5aca99400b2b3840388983df01f9c73e76fe2 /lib/cpumask.c | |
parent | 406d394abfcd8f16dc1dbcc8fc1b828252befb6d (diff) |
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: Yury Norov <yury.norov@gmail.com>
Acked-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Reviewed-by: Peter Lafreniere <peter@n8pjl.ca>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'lib/cpumask.c')
-rw-r--r-- | lib/cpumask.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/lib/cpumask.c b/lib/cpumask.c index 255974cd6734..10aa15715c0d 100644 --- a/lib/cpumask.c +++ b/lib/cpumask.c @@ -127,16 +127,12 @@ 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) - return cpu; - } - BUG(); + 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; } EXPORT_SYMBOL(cpumask_local_spread); |