From: Magnus Karlsson <magnus.karlsson@gmail.com>
To: Kal Conley <kal.conley@dectris.com>
Cc: "Björn Töpel" <bjorn@kernel.org>,
"Magnus Karlsson" <magnus.karlsson@intel.com>,
"Maciej Fijalkowski" <maciej.fijalkowski@intel.com>,
"Jonathan Lemon" <jonathan.lemon@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Alexei Starovoitov" <ast@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Jesper Dangaard Brouer" <hawk@kernel.org>,
"John Fastabend" <john.fastabend@gmail.com>,
netdev@vger.kernel.org, bpf@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH bpf-next] xsk: Simplify xp_aligned_validate_desc implementation
Date: Wed, 12 Apr 2023 14:23:34 +0200 [thread overview]
Message-ID: <CAJ8uoz11tOSUK0+45K=L9q-yj3gyMCDJVPsOjawE+Wjbe2FSTQ@mail.gmail.com> (raw)
In-Reply-To: <20230410121841.643254-1-kal.conley@dectris.com>
On Mon, 10 Apr 2023 at 14:24, Kal Conley <kal.conley@dectris.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@intel.com>
> Signed-off-by: Kal Conley <kal.conley@dectris.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
>
next prev parent reply other threads:[~2023-04-12 12:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-10 12:18 [PATCH bpf-next] xsk: Simplify xp_aligned_validate_desc implementation Kal Conley
2023-04-12 12:23 ` Magnus Karlsson [this message]
2023-04-12 12:34 ` Kal Cutter Conley
2023-04-13 13:00 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAJ8uoz11tOSUK0+45K=L9q-yj3gyMCDJVPsOjawE+Wjbe2FSTQ@mail.gmail.com' \
--to=magnus.karlsson@gmail.com \
--cc=ast@kernel.org \
--cc=bjorn@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hawk@kernel.org \
--cc=john.fastabend@gmail.com \
--cc=jonathan.lemon@gmail.com \
--cc=kal.conley@dectris.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maciej.fijalkowski@intel.com \
--cc=magnus.karlsson@intel.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).