Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bpf: Replace get_next_cpu() with cpumask_next_wrap()

The get_next_cpu() function was only used in one place to find
the next possible CPU, which can be replaced by cpumask_next_wrap().

Signed-off-by: Fushuai Wang <wangfushuai@baidu.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20250818032344.23229-1-wangfushuai@baidu.com

authored by

Fushuai Wang and committed by
Daniel Borkmann
d87fdb1f 12741630

+1 -9
+1 -9
kernel/bpf/bpf_lru_list.c
··· 19 19 #define LOCAL_PENDING_LIST_IDX LOCAL_LIST_IDX(BPF_LRU_LOCAL_LIST_T_PENDING) 20 20 #define IS_LOCAL_LIST_TYPE(t) ((t) >= BPF_LOCAL_LIST_T_OFFSET) 21 21 22 - static int get_next_cpu(int cpu) 23 - { 24 - cpu = cpumask_next(cpu, cpu_possible_mask); 25 - if (cpu >= nr_cpu_ids) 26 - cpu = cpumask_first(cpu_possible_mask); 27 - return cpu; 28 - } 29 - 30 22 /* Local list helpers */ 31 23 static struct list_head *local_free_list(struct bpf_lru_locallist *loc_l) 32 24 { ··· 474 482 475 483 raw_spin_unlock_irqrestore(&steal_loc_l->lock, flags); 476 484 477 - steal = get_next_cpu(steal); 485 + steal = cpumask_next_wrap(steal, cpu_possible_mask); 478 486 } while (!node && steal != first_steal); 479 487 480 488 loc_l->next_steal = steal;