Re: [PATCH bpf-next] samples/bpf: Attach XDP programs in driver mode by default

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 16 Dec 2019 15:35:01 +0100
Jesper Dangaard Brouer <brouer@xxxxxxxxxx> wrote:

> On Mon, 16 Dec 2019 12:07:42 +0100
> Toke Høiland-Jørgensen <toke@xxxxxxxxxx> wrote:
> 
> > When attaching XDP programs, userspace can set flags to request the attach
> > mode (generic/SKB mode, driver mode or hw offloaded mode). If no such flags
> > are requested, the kernel will attempt to attach in driver mode, and then
> > silently fall back to SKB mode if this fails.
> > 
> > The silent fallback is a major source of user confusion, as users will try
> > to load a program on a device without XDP support, and instead of an error
> > they will get the silent fallback behaviour, not notice, and then wonder
> > why performance is not what they were expecting.
> > 
> > In an attempt to combat this, let's switch all the samples to default to
> > explicitly requesting driver-mode attach. As part of this, ensure that all
> > the userspace utilities have a switch to enable SKB mode. For those that
> > have a switch to request driver mode, keep it but turn it into a no-op.
> > 
> > Signed-off-by: Toke Høiland-Jørgensen <toke@xxxxxxxxxx>
> > ---  
> 
> I agree, that this is a good way forward.
> 
> What is the observed behavior / error-message after this change?

The error message looks fine:

 $ sudo ./xdp1 enp0s31f6
 libbpf: Kernel error message: underlying driver does not support XDP in native mode
 link set xdp fd failed
 
Acked-by: Jesper Dangaard Brouer <brouer@xxxxxxxxxx>

> I wanted to test this myself, but compiling samples/bpf/ is breaking
> (again) on my system...

I saw your other compile fixes on the list and used those... thanks!


> > diff --git a/samples/bpf/xdp1_user.c b/samples/bpf/xdp1_user.c
> > index 3e553eed95a7..38a8852cb57f 100644
> > --- a/samples/bpf/xdp1_user.c
> > +++ b/samples/bpf/xdp1_user.c
> > @@ -98,7 +98,7 @@ int main(int argc, char **argv)
> >  			xdp_flags |= XDP_FLAGS_SKB_MODE;
> >  			break;
> >  		case 'N':
> > -			xdp_flags |= XDP_FLAGS_DRV_MODE;
> > +			/* default, set below */
> >  			break;
> >  		case 'F':
> >  			xdp_flags &= ~XDP_FLAGS_UPDATE_IF_NOEXIST;
> > @@ -109,6 +109,9 @@ int main(int argc, char **argv)
> >  		}
> >  	}
> >  
> > +	if (!(xdp_flags & XDP_FLAGS_SKB_MODE))
> > +		xdp_flags |= XDP_FLAGS_DRV_MODE;
> > +
> >  	if (optind == argc) {
> >  		usage(basename(argv[0]));
> >  		return 1;  

-- 
Best regards,
  Jesper Dangaard Brouer
  MSc.CS, Principal Kernel Engineer at Red Hat
  LinkedIn: http://www.linkedin.com/in/brouer





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux