netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jesper Dangaard Brouer <brouer@redhat.com>
To: "Toke Høiland-Jørgensen" <toke@redhat.com>
Cc: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	netdev@vger.kernel.org, bpf@vger.kernel.org,
	David Ahern <dsahern@gmail.com>,
	brouer@redhat.com
Subject: Re: [PATCH bpf-next] samples/bpf: Attach XDP programs in driver mode by default
Date: Mon, 16 Dec 2019 15:35:01 +0100	[thread overview]
Message-ID: <20191216153501.0c5c036a@carbon> (raw)
In-Reply-To: <20191216110742.364456-1-toke@redhat.com>

On Mon, 16 Dec 2019 12:07:42 +0100
Toke Høiland-Jørgensen <toke@redhat.com> 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@redhat.com>
> ---

I agree, that this is a good way forward.

What is the observed behavior / error-message after this change?

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

> 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


  reply	other threads:[~2019-12-16 14:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-16 11:07 [PATCH bpf-next] samples/bpf: Attach XDP programs in driver mode by default Toke Høiland-Jørgensen
2019-12-16 14:35 ` Jesper Dangaard Brouer [this message]
2019-12-16 14:55   ` Jesper Dangaard Brouer
2019-12-16 15:01 ` David Ahern
2019-12-16 15:06   ` Alexei Starovoitov

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=20191216153501.0c5c036a@carbon \
    --to=brouer@redhat.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=dsahern@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=toke@redhat.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).