netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Jonathan Lemon" <jonathan.lemon@gmail.com>
To: "Björn Töpel" <bjorn.topel@gmail.com>
Cc: "Martin Lau" <kafai@fb.com>,
	"Jesper Dangaard Brouer" <brouer@redhat.com>,
	netdev@vger.kernel.org, "Kernel Team" <Kernel-team@fb.com>,
	bjorn.topel@intel.com, magnus.karlsson@intel.com, ast@kernel.org,
	daniel@iogearbox.net
Subject: Re: [PATCH v4 bpf-next 1/2] bpf: Allow bpf_map_lookup_elem() on an xskmap
Date: Wed, 05 Jun 2019 08:42:48 -0700	[thread overview]
Message-ID: <1E4A2FA7-E759-450A-8979-F7CCD7F653C4@gmail.com> (raw)
In-Reply-To: <CAJ+HfNiQ-wO+sT_6FHAMHw7eDv-kMNjg0ecUmHa_TKg-gPXCyA@mail.gmail.com>



On 5 Jun 2019, at 1:45, Björn Töpel wrote:

> On Tue, 4 Jun 2019 at 20:13, Martin Lau <kafai@fb.com> wrote:
>>
>> On Tue, Jun 04, 2019 at 10:25:23AM -0700, Jonathan Lemon wrote:
>>> On 4 Jun 2019, at 9:43, Jesper Dangaard Brouer wrote:
>>>
>>>> On Mon, 3 Jun 2019 09:38:51 -0700
>>>> Jonathan Lemon <jonathan.lemon@gmail.com> wrote:
>>>>
>>>>> Currently, the AF_XDP code uses a separate map in order to
>>>>> determine if an xsk is bound to a queue.  Instead of doing this,
>>>>> have bpf_map_lookup_elem() return the queue_id, as a way of
>>>>> indicating that there is a valid entry at the map index.
>>>>
>>>> Just a reminder, that once we choose a return value, there the
>>>> queue_id, then it basically becomes UAPI, and we cannot change it.
>>>
>>> Yes - Alexei initially wanted to return the sk_cookie instead, but
>>> that's 64 bits and opens up a whole other can of worms.
>>>
>>>
>>>> Can we somehow use BTF to allow us to extend this later?
>>>>
>>>> I was also going to point out that, you cannot return a direct pointer
>>>> to queue_id, as BPF-prog side can modify this... but Daniel already
>>>> pointed this out.
>>>
>>> So, I see three solutions here (for this and Toke's patchset also,
>>> which is encountering the same problem).
>>>
>>> 1) add a scratch register (Toke's approach)
>>> 2) add a PTR_TO_<type>, which has the access checked.  This is the most
>>>    flexible approach, but does seem a bit overkill at the moment.
>> I think it would be nice and more extensible to have PTR_TO_xxx.
>> It could start with the existing PTR_TO_SOCKET
>>
>> or starting with a new PTR_TO_XDP_SOCK from the beginning is also fine.
>>
>
> Doesn't the PTR_TO_SOCKET path involve taking a ref and mandating
> sk_release() from the fast path? :-(

AF_XDP sockets are created with SOCK_RCU_FREE, and used under rcu, so
I don't think that they need to be refcounted.  bpf_sk_release is a NOP
in the RCU_FREE case.
-- 
Jonathan

  reply	other threads:[~2019-06-05 15:42 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-03 16:38 [PATCH v4 bpf-next 0/2] Better handling of xskmap entries Jonathan Lemon
2019-06-03 16:38 ` [PATCH v4 bpf-next 1/2] bpf: Allow bpf_map_lookup_elem() on an xskmap Jonathan Lemon
2019-06-04 14:54   ` Daniel Borkmann
2019-06-04 15:30     ` Daniel Borkmann
2019-06-04 16:43   ` Jesper Dangaard Brouer
2019-06-04 17:25     ` Jonathan Lemon
2019-06-04 18:12       ` Martin Lau
2019-06-05  8:45         ` Björn Töpel
2019-06-05 15:42           ` Jonathan Lemon [this message]
2019-06-04 18:18       ` Björn Töpel
2019-06-04 20:07       ` Toke Høiland-Jørgensen
2019-06-03 16:38 ` [PATCH v4 bpf-next 2/2] libbpf: remove qidconf and better support external bpf programs Jonathan Lemon
2019-06-04  6:06 ` [PATCH v4 bpf-next 0/2] Better handling of xskmap entries Björn Töpel

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=1E4A2FA7-E759-450A-8979-F7CCD7F653C4@gmail.com \
    --to=jonathan.lemon@gmail.com \
    --cc=Kernel-team@fb.com \
    --cc=ast@kernel.org \
    --cc=bjorn.topel@gmail.com \
    --cc=bjorn.topel@intel.com \
    --cc=brouer@redhat.com \
    --cc=daniel@iogearbox.net \
    --cc=kafai@fb.com \
    --cc=magnus.karlsson@intel.com \
    --cc=netdev@vger.kernel.org \
    /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).