* [PATCH bpf] bpf: Use cpumask_next_wrap() in get_next_cpu()
@ 2025-08-07 2:48 Fushuai Wang
2025-08-07 17:56 ` Yonghong Song
2025-08-15 9:03 ` Daniel Borkmann
0 siblings, 2 replies; 4+ messages in thread
From: Fushuai Wang @ 2025-08-07 2:48 UTC (permalink / raw)
To: linux-kernel, bpf
Cc: martin.lau, ast, daniel, andrii, eddyz87, song, yonghong.song,
john.fastabend, kpsingh, sdf, haoluo, jolsa, Fushuai Wang
Replace the manual sequence of cpumask_next() and cpumask_first()
with a single call to cpumask_next_wrap() in get_next_cpu().
Signed-off-by: Fushuai Wang <wangfushuai@baidu.com>
---
kernel/bpf/bpf_lru_list.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/kernel/bpf/bpf_lru_list.c b/kernel/bpf/bpf_lru_list.c
index 2d6e1c98d8ad..34881f4da8ae 100644
--- a/kernel/bpf/bpf_lru_list.c
+++ b/kernel/bpf/bpf_lru_list.c
@@ -21,10 +21,7 @@
static int get_next_cpu(int cpu)
{
- cpu = cpumask_next(cpu, cpu_possible_mask);
- if (cpu >= nr_cpu_ids)
- cpu = cpumask_first(cpu_possible_mask);
- return cpu;
+ return cpumask_next_wrap(cpu, cpu_possible_mask);
}
/* Local list helpers */
--
2.36.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH bpf] bpf: Use cpumask_next_wrap() in get_next_cpu()
2025-08-07 2:48 [PATCH bpf] bpf: Use cpumask_next_wrap() in get_next_cpu() Fushuai Wang
@ 2025-08-07 17:56 ` Yonghong Song
2025-08-15 9:03 ` Daniel Borkmann
1 sibling, 0 replies; 4+ messages in thread
From: Yonghong Song @ 2025-08-07 17:56 UTC (permalink / raw)
To: Fushuai Wang, linux-kernel, bpf
Cc: martin.lau, ast, daniel, andrii, eddyz87, song, john.fastabend,
kpsingh, sdf, haoluo, jolsa
On 8/6/25 7:48 PM, Fushuai Wang wrote:
> Replace the manual sequence of cpumask_next() and cpumask_first()
> with a single call to cpumask_next_wrap() in get_next_cpu().
>
> Signed-off-by: Fushuai Wang <wangfushuai@baidu.com>
Acked-by: Yonghong Song <yonghong.song@linux.dev>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH bpf] bpf: Use cpumask_next_wrap() in get_next_cpu()
2025-08-07 2:48 [PATCH bpf] bpf: Use cpumask_next_wrap() in get_next_cpu() Fushuai Wang
2025-08-07 17:56 ` Yonghong Song
@ 2025-08-15 9:03 ` Daniel Borkmann
2025-08-18 2:58 ` Fushuai Wang
1 sibling, 1 reply; 4+ messages in thread
From: Daniel Borkmann @ 2025-08-15 9:03 UTC (permalink / raw)
To: Fushuai Wang, linux-kernel, bpf
Cc: martin.lau, ast, andrii, eddyz87, song, yonghong.song,
john.fastabend, kpsingh, sdf, haoluo, jolsa
On 8/7/25 4:48 AM, Fushuai Wang wrote:
> Replace the manual sequence of cpumask_next() and cpumask_first()
> with a single call to cpumask_next_wrap() in get_next_cpu().
>
> Signed-off-by: Fushuai Wang <wangfushuai@baidu.com>
> ---
> kernel/bpf/bpf_lru_list.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/kernel/bpf/bpf_lru_list.c b/kernel/bpf/bpf_lru_list.c
> index 2d6e1c98d8ad..34881f4da8ae 100644
> --- a/kernel/bpf/bpf_lru_list.c
> +++ b/kernel/bpf/bpf_lru_list.c
> @@ -21,10 +21,7 @@
>
> static int get_next_cpu(int cpu)
> {
> - cpu = cpumask_next(cpu, cpu_possible_mask);
> - if (cpu >= nr_cpu_ids)
> - cpu = cpumask_first(cpu_possible_mask);
> - return cpu;
> + return cpumask_next_wrap(cpu, cpu_possible_mask);
> }
Lets then get rid of the get_next_cpu() function since its only used
once, and just use the cpumask_next_wrap() at call site ?
[...]
raw_spin_unlock_irqrestore(&steal_loc_l->lock, flags);
steal = cpumask_next_wrap(steal, cpu_possible_mask);
} while (!node && steal != first_steal);
[...]
Btw, in $subj please target [PATCH bpf-next] given its a cleanup,
not a fix.
Thanks,
Daniel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH bpf] bpf: Use cpumask_next_wrap() in get_next_cpu()
2025-08-15 9:03 ` Daniel Borkmann
@ 2025-08-18 2:58 ` Fushuai Wang
0 siblings, 0 replies; 4+ messages in thread
From: Fushuai Wang @ 2025-08-18 2:58 UTC (permalink / raw)
To: daniel
Cc: andrii, ast, bpf, eddyz87, haoluo, john.fastabend, jolsa, kpsingh,
linux-kernel, martin.lau, sdf, song, wangfushuai, yonghong.song
>> Replace the manual sequence of cpumask_next() and cpumask_first()
>> with a single call to cpumask_next_wrap() in get_next_cpu().
>>
>> Signed-off-by: Fushuai Wang <wangfushuai@baidu.com>
>> ---
>> kernel/bpf/bpf_lru_list.c | 5 +----
>> 1 file changed, 1 insertion(+), 4 deletions(-)
>>
>> diff --git a/kernel/bpf/bpf_lru_list.c b/kernel/bpf/bpf_lru_list.c
>> index 2d6e1c98d8ad..34881f4da8ae 100644
>> --- a/kernel/bpf/bpf_lru_list.c
>> +++ b/kernel/bpf/bpf_lru_list.c
>> @@ -21,10 +21,7 @@
>>
>> static int get_next_cpu(int cpu)
>> {
>> - cpu = cpumask_next(cpu, cpu_possible_mask);
>> - if (cpu >= nr_cpu_ids)
>> - cpu = cpumask_first(cpu_possible_mask);
>> - return cpu;
>> + return cpumask_next_wrap(cpu, cpu_possible_mask);
>> }
>
> Lets then get rid of the get_next_cpu() function since its only used
> once, and just use the cpumask_next_wrap() at call site ?
>
> [...]
> raw_spin_unlock_irqrestore(&steal_loc_l->lock, flags);
>
> steal = cpumask_next_wrap(steal, cpu_possible_mask);
> } while (!node && steal != first_steal);
> [...]
>
Thank you for your suggestion.
> Btw, in $subj please target [PATCH bpf-next] given its a cleanup,
> not a fix.
I will send a v2 shortly.
Regards,
Wang.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-08-18 3:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-07 2:48 [PATCH bpf] bpf: Use cpumask_next_wrap() in get_next_cpu() Fushuai Wang
2025-08-07 17:56 ` Yonghong Song
2025-08-15 9:03 ` Daniel Borkmann
2025-08-18 2:58 ` Fushuai Wang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).