[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAPhsuW5Oh-Z3kZWh=+pD1ERdCmQjAauDuoAm8C4PxH7g5BSXFw@mail.gmail.com>
Date: Fri, 1 Mar 2019 15:31:11 -0800
From: Song Liu <liu.song.a23@...il.com>
To: Eric Dumazet <edumazet@...gle.com>
Cc: Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
netdev <netdev@...r.kernel.org>,
Eric Dumazet <eric.dumazet@...il.com>,
Martin KaFai Lau <kafai@...com>,
Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
bpf <bpf@...r.kernel.org>, Guenter Roeck <linux@...ck-us.net>
Subject: Re: [PATCH net] bpf: fix u64_stats_init() usage in bpf_prog_alloc()
On Fri, Mar 1, 2019 at 2:34 PM Eric Dumazet <edumazet@...gle.com> wrote:
>
> We need to iterate through all possible cpus.
>
> Fixes: 492ecee892c2 ("bpf: enable program stats")
> Signed-off-by: Eric Dumazet <edumazet@...gle.com>
> Reported-by: Guenter Roeck <linux@...ck-us.net>
> Tested-by: Guenter Roeck <linux@...ck-us.net>
Acked-by: Song Liu <songliubraving@...com>
> ---
> kernel/bpf/core.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
> index 1c14c347f3cfe1f7c0cf8a7eccff8135b16df81f..3f08c257858e1570339cd64a6351824bcc332ee3 100644
> --- a/kernel/bpf/core.c
> +++ b/kernel/bpf/core.c
> @@ -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
>
Powered by blists - more mailing lists