* [PATCH bpf-next] bpf: Remove unnecessary cpu == 0 check in memalloc
@ 2024-01-04 16:57 Yonghong Song
2024-01-04 18:20 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Yonghong Song @ 2024-01-04 16:57 UTC (permalink / raw)
To: bpf
Cc: Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann, kernel-team,
Martin KaFai Lau
After merging the patch set [1] to reduce memory usage
for bpf_global_percpu_ma, Alexei found a redundant check (cpu == 0)
in function bpf_mem_alloc_percpu_unit_init() ([2]).
Indeed, the check is unnecessary since c->unit_size will
be all NULL or all non-NULL for all cpus before
for_each_possible_cpu() loop.
Removing the check makes code less confusing.
[1] https://lore.kernel.org/all/20231222031729.1287957-1-yonghong.song@linux.dev/
[2] https://lore.kernel.org/all/20231222031745.1289082-1-yonghong.song@linux.dev/
Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
---
kernel/bpf/memalloc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/bpf/memalloc.c b/kernel/bpf/memalloc.c
index 460c8f38fed6..550f02e2cb13 100644
--- a/kernel/bpf/memalloc.c
+++ b/kernel/bpf/memalloc.c
@@ -613,7 +613,7 @@ int bpf_mem_alloc_percpu_unit_init(struct bpf_mem_alloc *ma, int size)
for_each_possible_cpu(cpu) {
cc = per_cpu_ptr(pcc, cpu);
c = &cc->cache[i];
- if (cpu == 0 && c->unit_size)
+ if (c->unit_size)
break;
c->unit_size = unit_size;
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH bpf-next] bpf: Remove unnecessary cpu == 0 check in memalloc
2024-01-04 16:57 [PATCH bpf-next] bpf: Remove unnecessary cpu == 0 check in memalloc Yonghong Song
@ 2024-01-04 18:20 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-01-04 18:20 UTC (permalink / raw)
To: Yonghong Song; +Cc: bpf, ast, andrii, daniel, kernel-team, martin.lau
Hello:
This patch was applied to bpf/bpf-next.git (master)
by Alexei Starovoitov <ast@kernel.org>:
On Thu, 4 Jan 2024 08:57:44 -0800 you wrote:
> After merging the patch set [1] to reduce memory usage
> for bpf_global_percpu_ma, Alexei found a redundant check (cpu == 0)
> in function bpf_mem_alloc_percpu_unit_init() ([2]).
> Indeed, the check is unnecessary since c->unit_size will
> be all NULL or all non-NULL for all cpus before
> for_each_possible_cpu() loop.
> Removing the check makes code less confusing.
>
> [...]
Here is the summary with links:
- [bpf-next] bpf: Remove unnecessary cpu == 0 check in memalloc
https://git.kernel.org/bpf/bpf-next/c/9ddf872b47e3
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-01-04 18:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-04 16:57 [PATCH bpf-next] bpf: Remove unnecessary cpu == 0 check in memalloc Yonghong Song
2024-01-04 18:20 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox