[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJ8uoz11tOSUK0+45K=L9q-yj3gyMCDJVPsOjawE+Wjbe2FSTQ@mail.gmail.com>
Date: Wed, 12 Apr 2023 14:23:34 +0200
From: Magnus Karlsson <magnus.karlsson@...il.com>
To: Kal Conley <kal.conley@...tris.com>
Cc: Björn Töpel <bjorn@...nel.org>,
Magnus Karlsson <magnus.karlsson@...el.com>,
Maciej Fijalkowski <maciej.fijalkowski@...el.com>,
Jonathan Lemon <jonathan.lemon@...il.com>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Jesper Dangaard Brouer <hawk@...nel.org>,
John Fastabend <john.fastabend@...il.com>,
netdev@...r.kernel.org, bpf@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH bpf-next] xsk: Simplify xp_aligned_validate_desc implementation
On Mon, 10 Apr 2023 at 14:24, Kal Conley <kal.conley@...tris.com> wrote:
>
> Perform the chunk boundary check like the page boundary check in
> xp_desc_crosses_non_contig_pg(). This simplifies the implementation and
> reduces the number of branches.
Thanks for this simplification Kal. Just to check, does your change
pass the xsk selftests, especially the INV_DESC test? If so, then you
have my ack below.
Acked-by: Magnus Karlsson <magnus.karlsson@...el.com>
> Signed-off-by: Kal Conley <kal.conley@...tris.com>
> ---
> net/xdp/xsk_queue.h | 12 ++++--------
> 1 file changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/net/xdp/xsk_queue.h b/net/xdp/xsk_queue.h
> index dea4f378327d..6d40a77fccbe 100644
> --- a/net/xdp/xsk_queue.h
> +++ b/net/xdp/xsk_queue.h
> @@ -133,16 +133,12 @@ static inline bool xskq_cons_read_addr_unchecked(struct xsk_queue *q, u64 *addr)
> static inline bool xp_aligned_validate_desc(struct xsk_buff_pool *pool,
> struct xdp_desc *desc)
> {
> - u64 chunk, chunk_end;
> + u64 offset = desc->addr & (pool->chunk_size - 1);
>
> - chunk = xp_aligned_extract_addr(pool, desc->addr);
> - if (likely(desc->len)) {
> - chunk_end = xp_aligned_extract_addr(pool, desc->addr + desc->len - 1);
> - if (chunk != chunk_end)
> - return false;
> - }
> + if (offset + desc->len > pool->chunk_size)
> + return false;
>
> - if (chunk >= pool->addrs_cnt)
> + if (desc->addr >= pool->addrs_cnt)
> return false;
>
> if (desc->options)
> --
> 2.39.2
>
Powered by blists - more mailing lists