Skip to content

Commit 9ddf872

Browse files
Yonghong SongAlexei Starovoitov
Yonghong Song
authored and
Alexei Starovoitov
committed
bpf: Remove unnecessary cpu == 0 check in memalloc
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/[email protected]/ [2] https://lore.kernel.org/all/[email protected]/ Signed-off-by: Yonghong Song <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent c040e90 commit 9ddf872

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/bpf/memalloc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ int bpf_mem_alloc_percpu_unit_init(struct bpf_mem_alloc *ma, int size)
613613
for_each_possible_cpu(cpu) {
614614
cc = per_cpu_ptr(pcc, cpu);
615615
c = &cc->cache[i];
616-
if (cpu == 0 && c->unit_size)
616+
if (c->unit_size)
617617
break;
618618

619619
c->unit_size = unit_size;

0 commit comments

Comments
 (0)