[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAADnVQJcJz9stNyjck4AukQ_T=DJcFszp_cH0r_spju_Oxd5ZQ@mail.gmail.com>
Date: Wed, 22 Jan 2025 16:29:35 -0800
From: Alexei Starovoitov <alexei.starovoitov@...il.com>
To: Daniel Xu <dxu@...uu.xyz>
Cc: Paolo Abeni <pabeni@...hat.com>, Jakub Kicinski <kuba@...nel.org>,
Jesper Dangaard Brouer <hawk@...nel.org>, "Fijalkowski, Maciej" <maciej.fijalkowski@...el.com>,
Alexei Starovoitov <ast@...nel.org>, Eric Dumazet <edumazet@...gle.com>,
Daniel Borkmann <daniel@...earbox.net>, "David S. Miller" <davem@...emloft.net>,
Björn Töpel <bjorn@...nel.org>,
John Fastabend <john.fastabend@...il.com>, "Karlsson, Magnus" <magnus.karlsson@...el.com>,
Andrii Nakryiko <andrii@...nel.org>, Martin KaFai Lau <martin.lau@...ux.dev>, Eddy Z <eddyz87@...il.com>,
Song Liu <song@...nel.org>, Yonghong Song <yonghong.song@...ux.dev>, KP Singh <kpsingh@...nel.org>,
Stanislav Fomichev <sdf@...ichev.me>, Hao Luo <haoluo@...gle.com>, Jiri Olsa <jolsa@...nel.org>,
Jonathan Lemon <jonathan.lemon@...il.com>, Simon Horman <horms@...nel.org>, bpf <bpf@...r.kernel.org>,
LKML <linux-kernel@...r.kernel.org>, Network Development <netdev@...r.kernel.org>
Subject: Re: [PATCH bpf-next 2/3] bpf: map: Thread null elision metadata to map_gen_lookup
On Mon, Jan 20, 2025 at 8:35 PM Daniel Xu <dxu@...uu.xyz> wrote:
>
> Add an extra parameter to map_gen_lookup callback so that if the lookup
> is known to be inbounds, the bounds check can be omitted.
>
> The next commit will take advantage of this new information.
>
> Signed-off-by: Daniel Xu <dxu@...uu.xyz>
> ---
> include/linux/bpf.h | 2 +-
> kernel/bpf/arraymap.c | 11 ++++++++---
> kernel/bpf/hashtab.c | 14 ++++++++++----
> kernel/bpf/verifier.c | 2 +-
> net/xdp/xskmap.c | 4 +++-
> 5 files changed, 23 insertions(+), 10 deletions(-)
>
> diff --git a/include/linux/bpf.h b/include/linux/bpf.h
> index feda0ce90f5a..da8b420095c9 100644
> --- a/include/linux/bpf.h
> +++ b/include/linux/bpf.h
> @@ -117,7 +117,7 @@ struct bpf_map_ops {
> * may manipulate it, exists.
> */
> void (*map_fd_put_ptr)(struct bpf_map *map, void *ptr, bool need_defer);
> - int (*map_gen_lookup)(struct bpf_map *map, struct bpf_insn *insn_buf);
> + int (*map_gen_lookup)(struct bpf_map *map, struct bpf_insn *insn_buf, bool inbounds);
The next time around we'd need another bool and more churn.
Let's use 'enum map_gen_flags flags' right away.
Also don't you want to pass an actual const_map_key
since its already known?
And the whole array_map_gen_lookup will become
single ld_imm64 insn.
Powered by blists - more mailing lists