[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1cf255a3-e48b-0a90-28ce-1a9c47095fc2@huaweicloud.com>
Date: Sat, 9 Sep 2023 10:49:09 +0800
From: Hou Tao <houtao@...weicloud.com>
To: Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
netdev@...r.kernel.org, bpf@...r.kernel.org
Cc: "David S. Miller" <davem@...emloft.net>,
Alexei Starovoitov <ast@...nel.org>, Daniel Borkmann <daniel@...earbox.net>,
Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>,
Jesper Dangaard Brouer <hawk@...nel.org>,
John Fastabend <john.fastabend@...il.com>, Paolo Abeni <pabeni@...hat.com>,
Thomas Gleixner <tglx@...utronix.de>, Andrii Nakryiko <andrii@...nel.org>,
Hao Luo <haoluo@...gle.com>, Jiri Olsa <jolsa@...nel.org>,
KP Singh <kpsingh@...nel.org>, Martin KaFai Lau <martin.lau@...ux.dev>,
Song Liu <song@...nel.org>, Stanislav Fomichev <sdf@...gle.com>,
Yonghong Song <yonghong.song@...ux.dev>
Subject: Re: [PATCH net 4/4] bpf, cpumap: Flush xdp after
cpu_map_bpf_prog_run_skb().
Hi,
On 9/8/2023 9:57 PM, Sebastian Andrzej Siewior wrote:
> xdp_do_flush() should be invoked before leaving the NAPI poll function
> if XDP-redirect has been performed.
>
> There are two possible XDP invocations in cpu_map_bpf_prog_run():
> - cpu_map_bpf_prog_run_xdp()
> - cpu_map_bpf_prog_run_skb()
>
> Both functions update stats->redirect if a redirect is performed but
> xdp_do_flush() is only invoked after the former.
>
> Invoke xdp_do_flush() after both functions run and a redirect was
> performed.
>
> Cc: Andrii Nakryiko <andrii@...nel.org>
> Cc: Hao Luo <haoluo@...gle.com>
> Cc: Jiri Olsa <jolsa@...nel.org>
> Cc: KP Singh <kpsingh@...nel.org>
> Cc: Martin KaFai Lau <martin.lau@...ux.dev>
> Cc: Song Liu <song@...nel.org>
> Cc: Stanislav Fomichev <sdf@...gle.com>
> Cc: Yonghong Song <yonghong.song@...ux.dev>
> Fixes: 11941f8a85362 ("bpf: cpumap: Implement generic cpumap")
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
> ---
> kernel/bpf/cpumap.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/kernel/bpf/cpumap.c b/kernel/bpf/cpumap.c
> index e42a1bdb7f536..f3ba11b4a732b 100644
> --- a/kernel/bpf/cpumap.c
> +++ b/kernel/bpf/cpumap.c
> @@ -248,12 +248,12 @@ static int cpu_map_bpf_prog_run(struct bpf_cpu_map_entry *rcpu, void **frames,
>
> nframes = cpu_map_bpf_prog_run_xdp(rcpu, frames, xdp_n, stats);
>
> - if (stats->redirect)
> - xdp_do_flush();
> -
> if (unlikely(!list_empty(list)))
> cpu_map_bpf_prog_run_skb(rcpu, list, stats);
>
> + if (stats->redirect)
> + xdp_do_flush();
> +
The purpose of xdp_do_flush() is to flush xdp frames stashed in per-cpu
cpu_map_flush list into xdp_bulk_queue. But for redirected skbs, these
skbs will be directly added into xdp_bulk_queue() in
cpu_map_generic_redirect(), so I think xdp_do_flush() is not needed for
redirected skbs.
> rcu_read_unlock_bh(); /* resched point, may call do_softirq() */
>
> return nframes;
Powered by blists - more mailing lists