bpf: fix u64_stats_init() usage in bpf_prog_alloc()
Subsystems (4)
PATCH 1/1 bpf: fix u64_stats_init() usage in bpf_prog_alloc()
We need to iterate through all possible cpus.
Fixes 492ecee892c2 ("bpf: enable program stats")
Signed-off-by Eric Dumazet <[email protected]>
Reported-by Guenter Roeck <[email protected]>
Tested-by Guenter Roeck <[email protected]>
--- kernel/bpf/core.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
kernel/bpf/core.c +7 -1
@@ -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;struct bpf_prog *prog; +int cpu; prog =bpf_prog_alloc_no_stats (size, gfp_extra_flags);if (!prog)
@@ -121,7 +122,12 @@ struct bpf_prog *bpf_prog_alloc(unsigned int size, gfp_t gfp_extra_flags)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; }EXPORT_SYMBOL_GPL (bpf_prog_alloc);
Signature · 1 line
2.21.0.352.gf09ad66450-goog
Quoted 7 lines · Eric Dumazet
We need to iterate through all possible cpus.
Fixes 492ecee892c2 ("bpf: enable program stats")Signed-off-by Eric Dumazet <[email protected]>Reported-by Guenter Roeck <[email protected]>Tested-by Guenter Roeck <[email protected]>
Acked-by Song Liu <[email protected]>
Quoted 33 lines
--- kernel/bpf/core.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)kernel/bpf/core.c +7
-2@@ -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;struct bpf_prog *prog; +int cpu; prog =bpf_prog_alloc_no_stats (size, gfp_extra_flags);if (!prog)@@ -121,7 +122,12 @@ struct bpf_prog *bpf_prog_alloc(unsigned int size, gfp_t gfp_extra_flags)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; }EXPORT_SYMBOL_GPL (bpf_prog_alloc); --2.21.0.352.gf09ad66450-goog
Quoted 6 lines · Eric Dumazet
We need to iterate through all possible cpus.
Fixes 492ecee892c2 ("bpf: enable program stats")Signed-off-by Eric Dumazet <[email protected]>Reported-by Guenter Roeck <[email protected]>Tested-by Guenter Roeck <[email protected]>
Applied, thanks! Issue is only in bpf-next, not net, therefore I've applied it there.