All of lore.kernel.org
 help / color / mirror / Atom feed
From: Larysa Zaremba <larysa.zaremba@intel.com>
To: Stanislav Fomichev <sdf@google.com>
Cc: <bpf@vger.kernel.org>, Alexei Starovoitov <ast@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	"Martin KaFai Lau" <martin.lau@linux.dev>,
	Song Liu <song@kernel.org>,
	Yonghong Song <yonghong.song@linux.dev>,
	John Fastabend <john.fastabend@gmail.com>,
	"KP Singh" <kpsingh@kernel.org>, Hao Luo <haoluo@google.com>,
	Jiri Olsa <jolsa@kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH bpf-next] bpf: Allow to use kfunc XDP hints and frags together
Date: Thu, 14 Sep 2023 19:04:26 +0200	[thread overview]
Message-ID: <ZQM9GjMLo32SqxyQ@lincoln> (raw)
In-Reply-To: <CAKH8qBuw68AixQabgP5wNfAQBcc0RuVNEyV9rf9vgVi__c4Y9A@mail.gmail.com>

On Thu, Sep 14, 2023 at 10:05:47AM -0700, Stanislav Fomichev wrote:
> On Thu, Sep 14, 2023 at 9:55 AM Larysa Zaremba <larysa.zaremba@intel.com> wrote:
> >
> > On Thu, Sep 14, 2023 at 09:29:57AM -0700, Stanislav Fomichev wrote:
> > > On 09/14, Larysa Zaremba wrote:
> > > > There is no fundamental reason, why multi-buffer XDP and XDP kfunc RX hints
> > > > cannot coexist in a single program.
> > > >
> > > > Allow those features to be used together by modifying the flags conditions.
> > > >
> > > > Suggested-by: Stanislav Fomichev <sdf@google.com>
> > > > Link: https://lore.kernel.org/bpf/CAKH8qBuzgtJj=OKMdsxEkyML36VsAuZpcrsXcyqjdKXSJCBq=Q@mail.gmail.com/
> > > > Signed-off-by: Larysa Zaremba <larysa.zaremba@intel.com>
> > > > ---
> > > >  kernel/bpf/offload.c | 6 +++++-
> > > >  1 file changed, 5 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/kernel/bpf/offload.c b/kernel/bpf/offload.c
> > > > index ee35f33a96d1..43aded96c79b 100644
> > > > --- a/kernel/bpf/offload.c
> > > > +++ b/kernel/bpf/offload.c
> > > > @@ -232,7 +232,11 @@ int bpf_prog_dev_bound_init(struct bpf_prog *prog, union bpf_attr *attr)
> > > >         attr->prog_type != BPF_PROG_TYPE_XDP)
> > > >             return -EINVAL;
> > > >
> > > > -   if (attr->prog_flags & ~BPF_F_XDP_DEV_BOUND_ONLY)
> > > > +   if (attr->prog_flags & ~(BPF_F_XDP_DEV_BOUND_ONLY | BPF_F_XDP_HAS_FRAGS))
> > > > +           return -EINVAL;
> > > > +
> > >
> > > [..]
> > >
> > > > +   if (attr->prog_flags & BPF_F_XDP_HAS_FRAGS &&
> > > > +       !(attr->prog_flags & BPF_F_XDP_DEV_BOUND_ONLY))
> > > >             return -EINVAL;
> > >
> > > Any reason we have 'attr->prog_flags & BPF_F_XDP_HAS_FRAGS' part here?
> > > Seems like doing '!(attr->prog_flags & BPF_F_XDP_DEV_BOUND_ONLY)' should
> > > be enough, right? We only want to bail out here when BPF_F_XDP_DEV_BOUND_ONLY
> > > is not set and we don't really care whether BPF_F_XDP_HAS_FRAGS is set
> > > or not at this point.
> >
> > If !(attr->prog_flags & BPF_F_XDP_DEV_BOUND_ONLY) at this point, program could
> > be requesting offload.
> >
> > Now I have thought about those conditions once more and they could be reduced to
> > this:
> >
> > if (attr->prog_flags & ~(BPF_F_XDP_DEV_BOUND_ONLY) &&
> >     attr->prog_flags != (BPF_F_XDP_DEV_BOUND_ONLY | BPF_F_XDP_HAS_FRAGS))
> >         return -EINVAL;
> >
> > What do you think?
> 
> Ah, so this check is here to protect against the mbuf+offloaded
> combination? (looking at that other thread with Maciej)
> Let's keep your current way with two separate checks, but let's add
> your "/* Frags are allowed only if program is dev-bound-only, but not
> if it is requesting
> bpf offload. */" as a comment to the second check?

Ok, sound good to me.

  reply	other threads:[~2023-09-14 17:10 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-14  8:37 [PATCH bpf-next] bpf: Allow to use kfunc XDP hints and frags together Larysa Zaremba
2023-09-14 16:29 ` Stanislav Fomichev
2023-09-14 16:49   ` Larysa Zaremba
2023-09-14 17:05     ` Stanislav Fomichev
2023-09-14 17:04       ` Larysa Zaremba [this message]
2023-09-14 16:38 ` Maciej Fijalkowski
2023-09-14 16:53   ` Larysa Zaremba

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=ZQM9GjMLo32SqxyQ@lincoln \
    --to=larysa.zaremba@intel.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=sdf@google.com \
    --cc=song@kernel.org \
    --cc=yonghong.song@linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.