Commit 4b911304 authored by Eric Dumazet's avatar Eric Dumazet Committed by Daniel Borkmann

bpf: fix u64_stats_init() usage in bpf_prog_alloc()

We need to iterate through all possible cpus.

Fixes: 492ecee8 ("bpf: enable program stats")
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Reported-by: default avatarGuenter Roeck <linux@roeck-us.net>
Tested-by: default avatarGuenter Roeck <linux@roeck-us.net>
Acked-by: default avatarSong Liu <songliubraving@fb.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
parent 3860d38f
...@@ -109,6 +109,7 @@ struct bpf_prog *bpf_prog_alloc(unsigned int size, gfp_t gfp_extra_flags) ...@@ -109,6 +109,7 @@ struct bpf_prog *bpf_prog_alloc(unsigned int size, gfp_t gfp_extra_flags)
{ {
gfp_t gfp_flags = GFP_KERNEL | __GFP_ZERO | gfp_extra_flags; gfp_t gfp_flags = GFP_KERNEL | __GFP_ZERO | gfp_extra_flags;
struct bpf_prog *prog; struct bpf_prog *prog;
int cpu;
prog = bpf_prog_alloc_no_stats(size, gfp_extra_flags); prog = bpf_prog_alloc_no_stats(size, gfp_extra_flags);
if (!prog) if (!prog)
...@@ -121,7 +122,12 @@ struct bpf_prog *bpf_prog_alloc(unsigned int size, gfp_t gfp_extra_flags) ...@@ -121,7 +122,12 @@ struct bpf_prog *bpf_prog_alloc(unsigned int size, gfp_t gfp_extra_flags)
return NULL; return NULL;
} }
u64_stats_init(&prog->aux->stats->syncp); for_each_possible_cpu(cpu) {
struct bpf_prog_stats *pstats;
pstats = per_cpu_ptr(prog->aux->stats, cpu);
u64_stats_init(&pstats->syncp);
}
return prog; return prog;
} }
EXPORT_SYMBOL_GPL(bpf_prog_alloc); EXPORT_SYMBOL_GPL(bpf_prog_alloc);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment