Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4046088rdb; Thu, 14 Sep 2023 10:06:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEYuduKoGqQ5YiksG4MELZrOC9Xb2eD3Z1qlCOKHWPOQHNQpqIc4Zlud8C/rtr/TWyPk7qX X-Received: by 2002:a17:902:ce92:b0:1c3:411c:9b7d with SMTP id f18-20020a170902ce9200b001c3411c9b7dmr7350015plg.57.1694711177660; Thu, 14 Sep 2023 10:06:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694711177; cv=none; d=google.com; s=arc-20160816; b=u75jAyotT8ukJu7Q4BbSdRZ9FsWTqgbiUWGhPpaAirFEMpblDKrF/pmI6/mEnh5+ou 5pnTuNczGZyOgardMgsdVxjRtNbBDyjStqHHHshG1vVBnUFZbpoWtwpxi48txUrltTCn lWfm4eyIfwPrVNs5Gs619Le4uqD1JHfHFjPrv63OXEuSmwPDBiuJm2APd9szYVUfVFWc 1UeAXVgEWkYi3SLOFSk9HKYR82dckD9QmUu5sm6bh+hdbUprg54G2xMno1dwL3ff5kZ6 PULU1sN9UpcTuda3h+C71GK4rssqdp8R8AAOoo7fO477tmKIPf2WVaJA4hjPPoscux6V ku1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=ACnGDvO4UdzljeQyTb/RRh5LQy8tu22rKTkwltqG0Ho=; fh=nTumpPVjhmKhqa4LmAxzZwkczWu7lRo42WiAitbZYvY=; b=BfNMa7KImjiKIT46pN6NSovCOq7LMapkMIlUhiLoMxi4v/ytnsSeuPCCqYlSwwNSXs ejzhmhcf6cI6PG2aXOM4Ag+I/Kf600kwZkNUDhl2cH53zgIzJgk2x13asT96bWKH1z8g UWVmNBvi2I0yS2gUKFdnoieISdoqdOrGhx1LseTQEyTHnbXqcw9CZJ/ZrecnUXOGbB25 ANUYUvHymASLBPCXfFn70x27C/M52JCmw8VLkc7AjKWEEgoHwBEetiqi10ItJTLNoWj8 qNCVqoqGSNOOy6IPp6g56xvBON8XlWQWdFFeQoO/uq5sKYg/Qkh0AqLHxCA1wPgG14tF XtSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=A+98zkLr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id e15-20020a17090301cf00b001b9c61c221bsi2028680plh.565.2023.09.14.10.06.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 10:06:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=A+98zkLr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 3E8538347A5D; Thu, 14 Sep 2023 10:06:12 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233171AbjINRGF (ORCPT + 99 others); Thu, 14 Sep 2023 13:06:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232000AbjINRGD (ORCPT ); Thu, 14 Sep 2023 13:06:03 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91BEE1FE8 for ; Thu, 14 Sep 2023 10:05:59 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1bf7423ef3eso10075935ad.3 for ; Thu, 14 Sep 2023 10:05:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694711159; x=1695315959; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=ACnGDvO4UdzljeQyTb/RRh5LQy8tu22rKTkwltqG0Ho=; b=A+98zkLrLIqFQRG2qtHyYhTf1K08tU35To5JZaBVdzpIsqq/+OPOS1QjFPrdwxyFe6 gNmzJrhg94ed5xijOUkSHk3tmYdLm+X0XknXINKL32Nu7PV45hx7TaBvXE4e88NQk3U8 rIsIQ7bqVzQlxH0zG/M17far7Z1nbY9i4O3YPBDeisq4Uu/Y90FiGTTPzAiBcNbQ3WLJ 9GfVGVeuZj3NGLnLPpSN73UDfBt8zo3r4jOJQyWt4hcHNMnnYRQh2z0fzeDRu+BWAzL+ Qp7VWcXjHp2qWrwEVI/nfykM10cEgHSvOG6HbBFNKWxbjgi4UigoDqOMsrLBR1t3usL4 Jc5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694711159; x=1695315959; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ACnGDvO4UdzljeQyTb/RRh5LQy8tu22rKTkwltqG0Ho=; b=iSIjCyF8BfaPXpdzgo4FBnwdm7Ztdyk5bx+kPWyHh88OqJ3dudYPjNT5AF0BVMTyQP bo2XV30Ewtc9RTF0CMJmt723xrQiRTmCcAOJHwDuDIah5AABMVudZtMCsO42/9Xv2zts MExR3JCwRlbf1DLkBQ4vKYyGUXDNVfEdiymO0S30F1Hogi+hIkJupuovI7ZzshWcTTGX YVD85mcNF6CR5jdoxvsZuFkMaws1cKyRE2cmErYj3QQHJFyTtUzIfTuuYzjI22uyq6DI uVt63FJRiC+KqdkzrVNcVXzUWuq1P+P8tlJ0Cg05S5c06Om5wmNtxvw6inATh+Ptv9kH WsFQ== X-Gm-Message-State: AOJu0Yzf7a+dE1fPJxTbwlln8qvl7BDD1tyW6C8GwJZucNfvzuw0ZtRL olp9W0obCUkTuuPuszExIpBIf6auUpv9Xf9qn5FIog== X-Received: by 2002:a17:90a:bc89:b0:274:7b85:eae6 with SMTP id x9-20020a17090abc8900b002747b85eae6mr1570581pjr.34.1694711158726; Thu, 14 Sep 2023 10:05:58 -0700 (PDT) MIME-Version: 1.0 References: <20230914083716.57443-1-larysa.zaremba@intel.com> In-Reply-To: From: Stanislav Fomichev Date: Thu, 14 Sep 2023 10:05:47 -0700 Message-ID: Subject: Re: [PATCH bpf-next] bpf: Allow to use kfunc XDP hints and frags together To: Larysa Zaremba Cc: bpf@vger.kernel.org, Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Hao Luo , Jiri Olsa , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 14 Sep 2023 10:06:12 -0700 (PDT) X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email On Thu, Sep 14, 2023 at 9:55=E2=80=AFAM Larysa Zaremba 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 condi= tions. > > > > > > Suggested-by: Stanislav Fomichev > > > Link: https://lore.kernel.org/bpf/CAKH8qBuzgtJj=3DOKMdsxEkyML36VsAuZp= crsXcyqjdKXSJCBq=3DQ@mail.gmail.com/ > > > Signed-off-by: Larysa Zaremba > > > --- > > > 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 *pro= g, union bpf_attr *attr) > > > attr->prog_type !=3D 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)' shoul= d > > be enough, right? We only want to bail out here when BPF_F_XDP_DEV_BOUN= D_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 red= uced to > this: > > if (attr->prog_flags & ~(BPF_F_XDP_DEV_BOUND_ONLY) && > attr->prog_flags !=3D (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?