* xdp generic default option
@ 2020-08-19 9:28 Lorenzo Bianconi
2020-08-19 14:39 ` Toke Høiland-Jørgensen
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Lorenzo Bianconi @ 2020-08-19 9:28 UTC (permalink / raw)
To: andriin; +Cc: bpf, netdev, Jesper Dangaard Brouer, David Miller, ast
[-- Attachment #1: Type: text/plain, Size: 1286 bytes --]
Hi Andrii,
working on xdp multi-buff I figured out now xdp generic is the default choice
if not specified by userspace. In particular after commit 7f0a838254bd
("bpf, xdp: Maintain info on attached XDP BPF programs in net_device"), running
the command below, XDP will run in generic mode even if the underlay driver
support XDP in native mode:
$ip link set dev eth0 xdp obj prog.o
$ip link show dev eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 xdpgeneric qdisc mq state UP mode DEFAULT
group default qlen 1024
link/ether f0:ad:4e:09:6b:57 brd ff:ff:ff:ff:ff:ff
prog/xdp id 1 tag 3b185187f1855c4c jited
Is it better to use xdpdrv as default choice if not specified by userspace?
doing something like:
diff --git a/net/core/dev.c b/net/core/dev.c
index a00aa737ce29..1f85880ee412 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -8747,9 +8747,9 @@ static enum bpf_xdp_mode dev_xdp_mode(u32 flags)
{
if (flags & XDP_FLAGS_HW_MODE)
return XDP_MODE_HW;
- if (flags & XDP_FLAGS_DRV_MODE)
- return XDP_MODE_DRV;
- return XDP_MODE_SKB;
+ if (flags & XDP_FLAGS_SKB_MODE)
+ return XDP_MODE_SKB;
+ return XDP_MODE_DRV;
}
static bpf_op_t dev_xdp_bpf_op(struct net_device *dev, enum bpf_xdp_mode mode)
Regards,
Lorenzo
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: xdp generic default option
2020-08-19 9:28 xdp generic default option Lorenzo Bianconi
@ 2020-08-19 14:39 ` Toke Høiland-Jørgensen
2020-08-19 19:07 ` Jakub Kicinski
2020-08-19 20:57 ` Andrii Nakryiko
2 siblings, 0 replies; 6+ messages in thread
From: Toke Høiland-Jørgensen @ 2020-08-19 14:39 UTC (permalink / raw)
To: Lorenzo Bianconi, andriin
Cc: bpf, netdev, Jesper Dangaard Brouer, David Miller, ast
Lorenzo Bianconi <lorenzo@kernel.org> writes:
> Hi Andrii,
>
> working on xdp multi-buff I figured out now xdp generic is the default choice
> if not specified by userspace. In particular after commit 7f0a838254bd
> ("bpf, xdp: Maintain info on attached XDP BPF programs in net_device"), running
> the command below, XDP will run in generic mode even if the underlay driver
> support XDP in native mode:
>
> $ip link set dev eth0 xdp obj prog.o
> $ip link show dev eth0
> 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 xdpgeneric qdisc mq state UP mode DEFAULT
> group default qlen 1024
> link/ether f0:ad:4e:09:6b:57 brd ff:ff:ff:ff:ff:ff
> prog/xdp id 1 tag 3b185187f1855c4c jited
Yeah, defaulting to xdpgeneric is not a good idea (and a change in
behaviour; I get native mode on the same command on a 5.8 kernel)...
-Toke
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: xdp generic default option
2020-08-19 9:28 xdp generic default option Lorenzo Bianconi
2020-08-19 14:39 ` Toke Høiland-Jørgensen
@ 2020-08-19 19:07 ` Jakub Kicinski
2020-08-19 20:57 ` Andrii Nakryiko
2 siblings, 0 replies; 6+ messages in thread
From: Jakub Kicinski @ 2020-08-19 19:07 UTC (permalink / raw)
To: Lorenzo Bianconi
Cc: andriin, bpf, netdev, Jesper Dangaard Brouer, David Miller, ast
On Wed, 19 Aug 2020 11:28:11 +0200 Lorenzo Bianconi wrote:
> Hi Andrii,
>
> working on xdp multi-buff I figured out now xdp generic is the default choice
> if not specified by userspace. In particular after commit 7f0a838254bd
> ("bpf, xdp: Maintain info on attached XDP BPF programs in net_device"), running
> the command below, XDP will run in generic mode even if the underlay driver
> support XDP in native mode:
Make me wonder if bpf/test_offload.py was ever run on those changes :/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: xdp generic default option
2020-08-19 9:28 xdp generic default option Lorenzo Bianconi
2020-08-19 14:39 ` Toke Høiland-Jørgensen
2020-08-19 19:07 ` Jakub Kicinski
@ 2020-08-19 20:57 ` Andrii Nakryiko
2020-08-20 8:25 ` Jesper Dangaard Brouer
2 siblings, 1 reply; 6+ messages in thread
From: Andrii Nakryiko @ 2020-08-19 20:57 UTC (permalink / raw)
To: Lorenzo Bianconi
Cc: Andrii Nakryiko, bpf, Networking, Jesper Dangaard Brouer,
David Miller, Alexei Starovoitov
On Wed, Aug 19, 2020 at 2:29 AM Lorenzo Bianconi <lorenzo@kernel.org> wrote:
>
> Hi Andrii,
>
> working on xdp multi-buff I figured out now xdp generic is the default choice
> if not specified by userspace. In particular after commit 7f0a838254bd
> ("bpf, xdp: Maintain info on attached XDP BPF programs in net_device"), running
> the command below, XDP will run in generic mode even if the underlay driver
> support XDP in native mode:
>
> $ip link set dev eth0 xdp obj prog.o
> $ip link show dev eth0
> 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 xdpgeneric qdisc mq state UP mode DEFAULT
> group default qlen 1024
> link/ether f0:ad:4e:09:6b:57 brd ff:ff:ff:ff:ff:ff
> prog/xdp id 1 tag 3b185187f1855c4c jited
>
> Is it better to use xdpdrv as default choice if not specified by userspace?
> doing something like:
>
> diff --git a/net/core/dev.c b/net/core/dev.c
> index a00aa737ce29..1f85880ee412 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -8747,9 +8747,9 @@ static enum bpf_xdp_mode dev_xdp_mode(u32 flags)
> {
> if (flags & XDP_FLAGS_HW_MODE)
> return XDP_MODE_HW;
> - if (flags & XDP_FLAGS_DRV_MODE)
> - return XDP_MODE_DRV;
> - return XDP_MODE_SKB;
> + if (flags & XDP_FLAGS_SKB_MODE)
> + return XDP_MODE_SKB;
> + return XDP_MODE_DRV;
> }
>
I think the better way would be to choose XDP_MODE_DRV if ndo_bpf !=
NULL and XDP_MODE_SKB otherwise. That seems to be matching original
behavior, no?
It was not my intent to change the behavior, sorry about that. I'll
post patch a bit later today.
> static bpf_op_t dev_xdp_bpf_op(struct net_device *dev, enum bpf_xdp_mode mode)
>
> Regards,
> Lorenzo
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: xdp generic default option
2020-08-19 20:57 ` Andrii Nakryiko
@ 2020-08-20 8:25 ` Jesper Dangaard Brouer
2020-08-20 14:00 ` David Ahern
0 siblings, 1 reply; 6+ messages in thread
From: Jesper Dangaard Brouer @ 2020-08-20 8:25 UTC (permalink / raw)
To: Andrii Nakryiko
Cc: Lorenzo Bianconi, Andrii Nakryiko, bpf, Networking, David Miller,
Alexei Starovoitov, brouer, David Ahern,
Toke Høiland-Jørgensen
On Wed, 19 Aug 2020 13:57:51 -0700
Andrii Nakryiko <andrii.nakryiko@gmail.com> wrote:
> On Wed, Aug 19, 2020 at 2:29 AM Lorenzo Bianconi <lorenzo@kernel.org> wrote:
> >
> > Hi Andrii,
> >
> > working on xdp multi-buff I figured out now xdp generic is the default choice
> > if not specified by userspace. In particular after commit 7f0a838254bd
> > ("bpf, xdp: Maintain info on attached XDP BPF programs in net_device"), running
> > the command below, XDP will run in generic mode even if the underlay driver
> > support XDP in native mode:
> >
> > $ip link set dev eth0 xdp obj prog.o
> > $ip link show dev eth0
> > 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 xdpgeneric qdisc mq state UP mode DEFAULT
> > group default qlen 1024
> > link/ether f0:ad:4e:09:6b:57 brd ff:ff:ff:ff:ff:ff
> > prog/xdp id 1 tag 3b185187f1855c4c jited
> >
> > Is it better to use xdpdrv as default choice if not specified by userspace?
> > doing something like:
> >
> > diff --git a/net/core/dev.c b/net/core/dev.c
> > index a00aa737ce29..1f85880ee412 100644
> > --- a/net/core/dev.c
> > +++ b/net/core/dev.c
> > @@ -8747,9 +8747,9 @@ static enum bpf_xdp_mode dev_xdp_mode(u32 flags)
> > {
> > if (flags & XDP_FLAGS_HW_MODE)
> > return XDP_MODE_HW;
> > - if (flags & XDP_FLAGS_DRV_MODE)
> > - return XDP_MODE_DRV;
> > - return XDP_MODE_SKB;
> > + if (flags & XDP_FLAGS_SKB_MODE)
> > + return XDP_MODE_SKB;
> > + return XDP_MODE_DRV;
> > }
> >
>
> I think the better way would be to choose XDP_MODE_DRV if ndo_bpf !=
> NULL and XDP_MODE_SKB otherwise. That seems to be matching original
> behavior, no?
Yes, but this silent fallback to XDP_MODE_SKB (generic-XDP) have
cause a lot of support issues in the past. I wish we could change it.
We already changed all the samples/bpf/ to ask for XDP_FLAGS_DRV_MODE,
so they behave this way.
d50ecc46d18f ("samples/bpf: Attach XDP programs in driver mode by default")
https://git.kernel.org/torvalds/c/d50ecc46d18fa
> It was not my intent to change the behavior, sorry about that. I'll
> post patch a bit later today.
--
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] 6+ messages in thread
* Re: xdp generic default option
2020-08-20 8:25 ` Jesper Dangaard Brouer
@ 2020-08-20 14:00 ` David Ahern
0 siblings, 0 replies; 6+ messages in thread
From: David Ahern @ 2020-08-20 14:00 UTC (permalink / raw)
To: Jesper Dangaard Brouer, Andrii Nakryiko
Cc: Lorenzo Bianconi, Andrii Nakryiko, bpf, Networking, David Miller,
Alexei Starovoitov, Toke Høiland-Jørgensen
On 8/20/20 2:25 AM, Jesper Dangaard Brouer wrote:
>>> diff --git a/net/core/dev.c b/net/core/dev.c
>>> index a00aa737ce29..1f85880ee412 100644
>>> --- a/net/core/dev.c
>>> +++ b/net/core/dev.c
>>> @@ -8747,9 +8747,9 @@ static enum bpf_xdp_mode dev_xdp_mode(u32 flags)
>>> {
>>> if (flags & XDP_FLAGS_HW_MODE)
>>> return XDP_MODE_HW;
>>> - if (flags & XDP_FLAGS_DRV_MODE)
>>> - return XDP_MODE_DRV;
>>> - return XDP_MODE_SKB;
>>> + if (flags & XDP_FLAGS_SKB_MODE)
>>> + return XDP_MODE_SKB;
>>> + return XDP_MODE_DRV;
>>> }
>>>
>>
>> I think the better way would be to choose XDP_MODE_DRV if ndo_bpf !=
>> NULL and XDP_MODE_SKB otherwise. That seems to be matching original
>> behavior, no?
>
> Yes, but this silent fallback to XDP_MODE_SKB (generic-XDP) have
> cause a lot of support issues in the past. I wish we could change it.
> We already changed all the samples/bpf/ to ask for XDP_FLAGS_DRV_MODE,
> so they behave this way.
>
I would prefer the flags check in Lorenzo's proposed patch which is an
explicit opt in to the SKB mode.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-08-20 14:06 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-19 9:28 xdp generic default option Lorenzo Bianconi
2020-08-19 14:39 ` Toke Høiland-Jørgensen
2020-08-19 19:07 ` Jakub Kicinski
2020-08-19 20:57 ` Andrii Nakryiko
2020-08-20 8:25 ` Jesper Dangaard Brouer
2020-08-20 14:00 ` David Ahern
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).