bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tariq Toukan <ttoukan.linux@gmail.com>
To: Jakub Kicinski <kuba@kernel.org>,
	Andy Gospodarek <andrew.gospodarek@broadcom.com>
Cc: "Toke Høiland-Jørgensen" <toke@redhat.com>,
	"Lorenzo Bianconi" <lorenzo@kernel.org>,
	ast@kernel.org, daniel@iogearbox.net, davem@davemloft.net,
	hawk@kernel.org, john.fastabend@gmail.com, andrii@kernel.org,
	kafai@fb.com, songliubraving@fb.com, yhs@fb.com,
	kpsingh@kernel.org, lorenzo.bianconi@redhat.com,
	netdev@vger.kernel.org, bpf@vger.kernel.org,
	"Jesper Dangaard Brouer" <brouer@redhat.com>,
	"Ilias Apalodimas" <ilias.apalodimas@linaro.org>,
	gal@nvidia.com, "Saeed Mahameed" <saeedm@nvidia.com>,
	tariqt@nvidia.com
Subject: Re: [PATCH net-next v2] samples/bpf: fixup some tools to be able to support xdp multibuffer
Date: Sun, 8 Jan 2023 14:42:22 +0200	[thread overview]
Message-ID: <4a44bdec-b635-20ef-e915-1733e53c6f38@gmail.com> (raw)
In-Reply-To: <8369e348-a8ec-cb10-f91f-4277e5041a27@nvidia.com>



On 08/01/2023 14:33, Tariq Toukan wrote:
> 
> 
> On 05/01/2023 20:16, Jakub Kicinski wrote:
>> On Thu, 5 Jan 2023 11:57:32 -0500 Andy Gospodarek wrote:
>>>> So my main concern would be that if we "allow" this, the only way to
>>>> write an interoperable XDP program will be to use bpf_xdp_load_bytes()
>>>> for every packet access. Which will be slower than DPA, so we may 
>>>> end up
>>>> inadvertently slowing down all of the XDP ecosystem, because no one is
>>>> going to bother with writing two versions of their programs. Whereas if
>>>> you can rely on packet headers always being in the linear part, you can
>>>> write a lot of the "look at headers and make a decision" type programs
>>>> using just DPA, and they'll work for multibuf as well.
>>>
>>> The question I would have is what is really the 'slow down' for
>>> bpf_xdp_load_bytes() vs DPA?  I know you and Jesper can tell me how many
>>> instructions each use. :)
>>
>> Until we have an efficient and inlined DPA access to frags an
>> unconditional memcpy() of the first 2 cachelines-worth of headers
>> in the driver must be faster than a piece-by-piece bpf_xdp_load_bytes()
>> onto the stack, right?
>>
>>> Taking a step back...years ago Dave mentioned wanting to make XDP
>>> programs easy to write and it feels like using these accessor APIs would
>>> help accomplish that.  If the kernel examples use bpf_xdp_load_bytes()
>>> accessors everywhere then that would accomplish that.
>>
>> I've been pushing for an skb_header_pointer()-like helper but
>> the semantics were not universally loved :)
> 
> Maybe it's time to re-consider.
> 
> Is it something like an API that given an offset returns a pointer + 
> allowed length to be accessed?
> 
> This sounds like a good direction to me, that avoids having any 
> linear-part-length assumptions, while preserving good performance.
> 
> Maybe we can still require/guarantee that each single header (eth, ip, 
> tcp, ...) does not cross a frag/page boundary. For otherwise, a prog 
> needs to handle cases where headers span several fragments, so it has to 
> reconstruct the header by copying the different parts into some local 
> buffer.
> 
> This can be achieved by having another assumption that AFAIK already 
> holds today: all fragments are of size PAGE_SIZE.
> 
> Regards,
> Tariq

This can be a good starting point:
static void *bpf_xdp_pointer(struct xdp_buff *xdp, u32 offset, u32 len)

It's currently not exposed as a bpf-helper, and it works a bit 
differently to what I mentioned earlier: It gets the desired length, and 
fails in case it's not continuously accessible (i.e. this piece of data 
spans multiple frags).

  parent reply	other threads:[~2023-01-08 12:42 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-21 17:54 [PATCH net-next v2] samples/bpf: fixup some tools to be able to support xdp multibuffer Andy Gospodarek
2022-06-22  2:00 ` patchwork-bot+netdevbpf
2023-01-03 12:55 ` Tariq Toukan
2023-01-03 15:19   ` Toke Høiland-Jørgensen
2023-01-04  1:21     ` Jakub Kicinski
2023-01-04  8:44       ` Lorenzo Bianconi
2023-01-04 12:28         ` Toke Høiland-Jørgensen
2023-01-05  1:17           ` Jakub Kicinski
2023-01-05  7:20           ` Tariq Toukan
2023-01-05 15:43             ` Toke Høiland-Jørgensen
2023-01-05 16:57               ` Andy Gospodarek
2023-01-05 18:16                 ` Jakub Kicinski
2023-01-06 13:56                   ` Andy Gospodarek
2023-01-08 12:33                   ` Tariq Toukan
     [not found]                   ` <8369e348-a8ec-cb10-f91f-4277e5041a27@nvidia.com>
2023-01-08 12:42                     ` Tariq Toukan [this message]
2023-01-09 13:50                       ` Toke Høiland-Jørgensen
2023-01-05 22:07                 ` Toke Høiland-Jørgensen
2023-01-06 17:54                   ` Toke Høiland-Jørgensen
2023-01-05 16:22       ` Andy Gospodarek
2023-01-10 20:59       ` Maxim Mikityanskiy
2023-01-13 21:07         ` Tariq Toukan
2023-01-25 12:49           ` Tariq Toukan
2023-01-05 16:18   ` Andy Gospodarek

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=4a44bdec-b635-20ef-e915-1733e53c6f38@gmail.com \
    --to=ttoukan.linux@gmail.com \
    --cc=andrew.gospodarek@broadcom.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=brouer@redhat.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=gal@nvidia.com \
    --cc=hawk@kernel.org \
    --cc=ilias.apalodimas@linaro.org \
    --cc=john.fastabend@gmail.com \
    --cc=kafai@fb.com \
    --cc=kpsingh@kernel.org \
    --cc=kuba@kernel.org \
    --cc=lorenzo.bianconi@redhat.com \
    --cc=lorenzo@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=saeedm@nvidia.com \
    --cc=songliubraving@fb.com \
    --cc=tariqt@nvidia.com \
    --cc=toke@redhat.com \
    --cc=yhs@fb.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).