netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: error loading xdp program on virtio nic
       [not found]                 ` <8324a37e-5507-2ae6-53f6-949c842537e0@gmail.com>
@ 2019-11-22 16:57                   ` Jesper Dangaard Brouer
  2019-11-22 17:42                     ` David Ahern
  2019-11-25  2:42                     ` Jason Wang
  0 siblings, 2 replies; 4+ messages in thread
From: Jesper Dangaard Brouer @ 2019-11-22 16:57 UTC (permalink / raw)
  To: David Ahern; +Cc: Jason Wang, xdp-newbies, brouer, netdev

On Fri, 22 Nov 2019 08:43:50 -0700
David Ahern <dsahern@gmail.com> wrote:

> On 11/21/19 11:09 PM, Jason Wang wrote:
> >> Doubling the number of queues for each tap device adds overhead to the
> >> hypervisor if you only want to allow XDP_DROP or XDP_DIRECT. Am I
> >> understanding that correctly?  
> > 
> > 
> > Yes, but there's almost impossible to know whether or not XDP_TX will be
> > used by the program. If we don't use per CPU TX queue, it must be
> > serialized through locks, not sure it's worth try that (not by default,
> > of course).
> >   
> 
> This restriction is going to prevent use of XDP in VMs in general cloud
> hosting environments. 2x vhost threads for vcpus is a non-starter.
> 
> If one XDP feature has high resource needs, then we need to subdivide
> the capabilities to let some work and others fail. For example, a flag
> can be added to xdp_buff / xdp_md that indicates supported XDP features.
> If there are insufficient resources for XDP_TX, do not show support for
> it. If a program returns XDP_TX anyways, packets will be dropped.
> 

This sounds like concrete use-case and solid argument why we need XDP
feature detection and checks. (Last part of LPC talk[1] were about
XDP features).

An interesting perspective you bring up, is that XDP features are not
static per device driver.  It actually needs to be dynamic, as your
XDP_TX feature request depend on the queue resources available.

Implementation wise, I would not add flags to xdp_buff / xdp_md.
Instead I propose in[1] slide 46, that the verifier should detect the
XDP features used by a BPF-prog.  If you XDP prog doesn't use e.g.
XDP_TX, then you should be allowed to run it on a virtio_net device
with less queue configured, right?


[1] http://people.netfilter.org/hawk/presentations/LinuxPlumbers2019/xdp-distro-view.pdf
-- 
Best regards,
  Jesper Dangaard Brouer
  MSc.CS, Principal Kernel Engineer at Red Hat
  LinkedIn: http://www.linkedin.com/in/brouer


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: error loading xdp program on virtio nic
  2019-11-22 16:57                   ` error loading xdp program on virtio nic Jesper Dangaard Brouer
@ 2019-11-22 17:42                     ` David Ahern
  2019-11-23 13:27                       ` Toke Høiland-Jørgensen
  2019-11-25  2:42                     ` Jason Wang
  1 sibling, 1 reply; 4+ messages in thread
From: David Ahern @ 2019-11-22 17:42 UTC (permalink / raw)
  To: Jesper Dangaard Brouer; +Cc: Jason Wang, xdp-newbies, netdev

On 11/22/19 9:57 AM, Jesper Dangaard Brouer wrote:
> Implementation wise, I would not add flags to xdp_buff / xdp_md.
> Instead I propose in[1] slide 46, that the verifier should detect the
> XDP features used by a BPF-prog.  If you XDP prog doesn't use e.g.
> XDP_TX, then you should be allowed to run it on a virtio_net device
> with less queue configured, right?

Thanks for the reference and yes, that is the goal: allow XDP in the
most use cases possible. e.g., Why limit XDP_DROP which requires no
resources because XDP_TX does not work?

I agree a flag in the api is an ugly way to allow it. For the verifier
approach, you mean add an internal flag (e.g., bitmask of return codes)
that the program uses and the NIC driver can check at attach time?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: error loading xdp program on virtio nic
  2019-11-22 17:42                     ` David Ahern
@ 2019-11-23 13:27                       ` Toke Høiland-Jørgensen
  0 siblings, 0 replies; 4+ messages in thread
From: Toke Høiland-Jørgensen @ 2019-11-23 13:27 UTC (permalink / raw)
  To: David Ahern, Jesper Dangaard Brouer; +Cc: Jason Wang, xdp-newbies, netdev

David Ahern <dsahern@gmail.com> writes:

> On 11/22/19 9:57 AM, Jesper Dangaard Brouer wrote:
>> Implementation wise, I would not add flags to xdp_buff / xdp_md.
>> Instead I propose in[1] slide 46, that the verifier should detect the
>> XDP features used by a BPF-prog.  If you XDP prog doesn't use e.g.
>> XDP_TX, then you should be allowed to run it on a virtio_net device
>> with less queue configured, right?
>
> Thanks for the reference and yes, that is the goal: allow XDP in the
> most use cases possible. e.g., Why limit XDP_DROP which requires no
> resources because XDP_TX does not work?
>
> I agree a flag in the api is an ugly way to allow it. For the verifier
> approach, you mean add an internal flag (e.g., bitmask of return codes)
> that the program uses and the NIC driver can check at attach time?

Yes, that's more or less what we've discussed. With the actual set of
flags, and the API for the driver (new ndo?) TBD. Suggestions welcome; I
anticipate this is something Jesper and I need to circle back to soonish
in any case (unless someone beats us to it!).

-Toke


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: error loading xdp program on virtio nic
  2019-11-22 16:57                   ` error loading xdp program on virtio nic Jesper Dangaard Brouer
  2019-11-22 17:42                     ` David Ahern
@ 2019-11-25  2:42                     ` Jason Wang
  1 sibling, 0 replies; 4+ messages in thread
From: Jason Wang @ 2019-11-25  2:42 UTC (permalink / raw)
  To: Jesper Dangaard Brouer, David Ahern; +Cc: xdp-newbies, netdev


On 2019/11/23 上午12:57, Jesper Dangaard Brouer wrote:
> On Fri, 22 Nov 2019 08:43:50 -0700
> David Ahern <dsahern@gmail.com> wrote:
>
>> On 11/21/19 11:09 PM, Jason Wang wrote:
>>>> Doubling the number of queues for each tap device adds overhead to the
>>>> hypervisor if you only want to allow XDP_DROP or XDP_DIRECT. Am I
>>>> understanding that correctly?
>>>
>>> Yes, but there's almost impossible to know whether or not XDP_TX will be
>>> used by the program. If we don't use per CPU TX queue, it must be
>>> serialized through locks, not sure it's worth try that (not by default,
>>> of course).
>>>    
>> This restriction is going to prevent use of XDP in VMs in general cloud
>> hosting environments. 2x vhost threads for vcpus is a non-starter.
>>
>> If one XDP feature has high resource needs, then we need to subdivide
>> the capabilities to let some work and others fail. For example, a flag
>> can be added to xdp_buff / xdp_md that indicates supported XDP features.
>> If there are insufficient resources for XDP_TX, do not show support for
>> it. If a program returns XDP_TX anyways, packets will be dropped.
>>
> This sounds like concrete use-case and solid argument why we need XDP
> feature detection and checks. (Last part of LPC talk[1] were about
> XDP features).
>
> An interesting perspective you bring up, is that XDP features are not
> static per device driver.  It actually needs to be dynamic, as your
> XDP_TX feature request depend on the queue resources available.
>
> Implementation wise, I would not add flags to xdp_buff / xdp_md.
> Instead I propose in[1] slide 46, that the verifier should detect the
> XDP features used by a BPF-prog.  If you XDP prog doesn't use e.g.
> XDP_TX, then you should be allowed to run it on a virtio_net device
> with less queue configured, right?


Yes, I think so. But I remember we used to have something like 
header_adjust in the past but finally removed ...

Thanks


>
>
> [1] http://people.netfilter.org/hawk/presentations/LinuxPlumbers2019/xdp-distro-view.pdf


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-11-25  2:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <c484126f-c156-2a17-b47d-06d08121c38b@gmail.com>
     [not found] ` <89f56317-5955-e692-fcf0-ee876aae068b@redhat.com>
     [not found]   ` <3dc7b9d8-bcb2-1a90-630e-681cbf0f1ace@gmail.com>
     [not found]     ` <18659bd0-432e-f317-fa8a-b5670a91c5b9@redhat.com>
     [not found]       ` <f7b8df14-ef7f-be76-a990-b9d71139bcaa@gmail.com>
     [not found]         ` <20191121072625.3573368f@carbon>
     [not found]           ` <4686849f-f3b8-dd1d-0fe4-3c176a37b67a@redhat.com>
     [not found]             ` <df4ae5e7-3f79-fd28-ea2e-43612ff61e6f@gmail.com>
     [not found]               ` <f7b19bae-a9cf-d4bf-7eee-bfe644d87946@redhat.com>
     [not found]                 ` <8324a37e-5507-2ae6-53f6-949c842537e0@gmail.com>
2019-11-22 16:57                   ` error loading xdp program on virtio nic Jesper Dangaard Brouer
2019-11-22 17:42                     ` David Ahern
2019-11-23 13:27                       ` Toke Høiland-Jørgensen
2019-11-25  2:42                     ` Jason Wang

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).