[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230306160651.2016767-3-vernon2gm@gmail.com>
Date: Tue, 7 Mar 2023 00:06:48 +0800
From: Vernon Yang <vernon2gm@...il.com>
To: torvalds@...ux-foundation.org, tytso@....edu, Jason@...c4.com,
davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org,
pabeni@...hat.com, jejb@...ux.ibm.com, martin.petersen@...cle.com,
yury.norov@...il.com, andriy.shevchenko@...ux.intel.com,
linux@...musvillemoes.dk, james.smart@...adcom.com,
dick.kennedy@...adcom.com
Cc: linux-kernel@...r.kernel.org, wireguard@...ts.zx2c4.com,
netdev@...r.kernel.org, linux-scsi@...r.kernel.org,
Vernon Yang <vernon2gm@...il.com>
Subject: [PATCH 2/5] wireguard: fix wg_cpumask_choose_online() if no further cpus set
After commit 596ff4a09b89 ("cpumask: re-introduce constant-sized cpumask
optimizations"), when NR_CPUS <= BITS_PER_LONG, small_cpumask_bits used
a macro instead of variable-sized for efficient.
If no further cpus set, the cpumask_next() returns small_cpumask_bits,
it must greater than or equal to nr_cpumask_bits, so fix it to correctly.
Signed-off-by: Vernon Yang <vernon2gm@...il.com>
---
drivers/net/wireguard/queueing.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/wireguard/queueing.h b/drivers/net/wireguard/queueing.h
index 583adb37ee1e..41adeac3ee0b 100644
--- a/drivers/net/wireguard/queueing.h
+++ b/drivers/net/wireguard/queueing.h
@@ -106,7 +106,7 @@ static inline int wg_cpumask_choose_online(int *stored_cpu, unsigned int id)
{
unsigned int cpu = *stored_cpu, cpu_index, i;
- if (unlikely(cpu == nr_cpumask_bits ||
+ if (unlikely(cpu >= nr_cpumask_bits ||
!cpumask_test_cpu(cpu, cpu_online_mask))) {
cpu_index = id % cpumask_weight(cpu_online_mask);
cpu = cpumask_first(cpu_online_mask);
--
2.34.1
Powered by blists - more mailing lists