From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mail.toke.dk (Postfix) with ESMTPS id 14C4AA06FCC for ; Mon, 15 May 2023 18:17:10 +0200 (CEST) Authentication-Results: mail.toke.dk; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=jT10K2Df DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684167429; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Y2n8nonK1QjGxCr0VUr93GpzjyMzxVkptj6zYuPWAuE=; b=jT10K2DfnNdwYmmU687ZG7ucNmahFBrM1xbxOB4lu6f7QE6euI3hb9FQSwRuWIc98buFGb Oj7SlHclGKv+x4wLESOzUuD1lSSfL/hXf/FakUGtcrlCe0rXvFMLlEiZz734c3DvUBN9Ve nIaiZvn9fsbX/HnYkzqK/myQlvACiAA= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-169-8i1fkiIWOAiAtuWQhavSEw-1; Mon, 15 May 2023 12:17:06 -0400 X-MC-Unique: 8i1fkiIWOAiAtuWQhavSEw-1 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-510526d2a5fso8456541a12.0 for ; Mon, 15 May 2023 09:17:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684167425; x=1686759425; h=content-transfer-encoding:in-reply-to:references:to :content-language:subject:cc:user-agent:mime-version:date:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Y2n8nonK1QjGxCr0VUr93GpzjyMzxVkptj6zYuPWAuE=; b=MsM79A2S8ulRWnz18d2tmsFbof6WjXlyQT6DYN9d7xUNHFdoI7B8kRsjU8p3ADQ9be pVFrFfOFYZaImurVUML6cHndH84N2nokqnkys7QfVdp7SR2I024CGgt0X8J9JqTrWfOY vUkeOPQ893XZ5ZXgCutNckhsoUInxnGx4TSXxVdhVgC1cN7JpdhwyPOeu+4cL5aicrnN 4XHjxojYgsmy7epHtB/Rq74F9RhRAX6YnPnHchRHmFIxfXerBwOu+nOeI9jHswUNod3+ OgPyC9TblrJNtCdwTzc80BpyZhcobaZto0+nD0gl9qCY0E8P03K148lHAemCVzZCXdFJ bUFA== X-Gm-Message-State: AC+VfDyLyMYJnpMjJIUUuTavB0FJTwB473NMGKnFJAx7uPcl0/bHDK2F w+aQZz0TLrPro8cmCLvwUylL+kF58N5mSuVWcIt9pv/rFoDQOeFjPjYgF4bKncsKjRb2sQKl58/ 21rfaQkzitTH/lZB3dUy0 X-Received: by 2002:a17:907:8a08:b0:969:2df9:a0dd with SMTP id sc8-20020a1709078a0800b009692df9a0ddmr24600314ejc.25.1684167425411; Mon, 15 May 2023 09:17:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6RQlKd2/JfsFteQEmuUPf/8L4dZ5P2zo1ST2B53RtXrhApGfHpCM2SRHnGguT14dpugsCwvw== X-Received: by 2002:a17:907:8a08:b0:969:2df9:a0dd with SMTP id sc8-20020a1709078a0800b009692df9a0ddmr24600277ejc.25.1684167425043; Mon, 15 May 2023 09:17:05 -0700 (PDT) Received: from [192.168.41.200] (83-90-141-187-cable.dk.customer.tdc.net. [83.90.141.187]) by smtp.gmail.com with ESMTPSA id rq12-20020a17090788cc00b0094f0f0de1bcsm9444386ejc.200.2023.05.15.09.17.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 15 May 2023 09:17:04 -0700 (PDT) From: Jesper Dangaard Brouer X-Google-Original-From: Jesper Dangaard Brouer Message-ID: Date: Mon, 15 May 2023 18:17:02 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 To: Larysa Zaremba , bpf@vger.kernel.org References: <20230512152607.992209-1-larysa.zaremba@intel.com> <20230512152607.992209-15-larysa.zaremba@intel.com> In-Reply-To: <20230512152607.992209-15-larysa.zaremba@intel.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Message-ID-Hash: CSY46ZJYB2V7R46S4VJZNNVTA6USAECL X-Message-ID-Hash: CSY46ZJYB2V7R46S4VJZNNVTA6USAECL X-MailFrom: jbrouer@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: brouer@redhat.com, Stanislav Fomichev , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Jakub Kicinski , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Jiri Olsa , Jesse Brandeburg , Tony Nguyen , Anatoly Burakov , Alexander Lobakin , Magnus Karlsson , Maryam Tahhan , xdp-hints@xdp-project.net, netdev@vger.kernel.org, intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org, Aleksander Lobakin X-Mailman-Version: 3.3.8 Precedence: list Subject: [xdp-hints] Re: [PATCH RESEND bpf-next 14/15] net, xdp: allow metadata > 32 List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On 12/05/2023 17.26, Larysa Zaremba wrote: > From: Aleksander Lobakin > > When using XDP hints, metadata sometimes has to be much bigger > than 32 bytes. Relax the restriction, allow metadata larger than 32 bytes > and make __skb_metadata_differs() work with bigger lengths. > > Now size of metadata is only limited by the fact it is stored as u8 > in skb_shared_info, so maximum possible value is 255. I'm confused, IIRC the metadata area isn't stored "in skb_shared_info". The maximum possible size is limited by the XDP headroom, which is also shared/limited with/by xdp_frame. I must be reading the sentence wrong, somehow. > Other important > conditions, such as having enough space for xdp_frame building, are already > checked in bpf_xdp_adjust_meta(). > > The requirement of having its length aligned to 4 bytes is still > valid. > > Signed-off-by: Aleksander Lobakin > Signed-off-by: Larysa Zaremba > --- > include/linux/skbuff.h | 13 ++++++++----- > include/net/xdp.h | 7 ++++++- > 2 files changed, 14 insertions(+), 6 deletions(-) > > diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h > index 8ddb4af1a501..afcd372aecdf 100644 > --- a/include/linux/skbuff.h > +++ b/include/linux/skbuff.h > @@ -4219,10 +4219,13 @@ static inline bool __skb_metadata_differs(const struct sk_buff *skb_a, > { > const void *a = skb_metadata_end(skb_a); > const void *b = skb_metadata_end(skb_b); > - /* Using more efficient varaiant than plain call to memcmp(). */ > -#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && BITS_PER_LONG == 64 > u64 diffs = 0; > > + if (!IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) || > + BITS_PER_LONG != 64) > + goto slow; > + > + /* Using more efficient variant than plain call to memcmp(). */ > switch (meta_len) { > #define __it(x, op) (x -= sizeof(u##op)) > #define __it_diff(a, b, op) (*(u##op *)__it(a, op)) ^ (*(u##op *)__it(b, op)) > @@ -4242,11 +4245,11 @@ static inline bool __skb_metadata_differs(const struct sk_buff *skb_a, > fallthrough; > case 4: diffs |= __it_diff(a, b, 32); > break; > + default: > +slow: > + return memcmp(a - meta_len, b - meta_len, meta_len); > } > return diffs; > -#else > - return memcmp(a - meta_len, b - meta_len, meta_len); > -#endif > } > > static inline bool skb_metadata_differs(const struct sk_buff *skb_a, > diff --git a/include/net/xdp.h b/include/net/xdp.h > index 0fbd25616241..f48723250c7c 100644 > --- a/include/net/xdp.h > +++ b/include/net/xdp.h > @@ -370,7 +370,12 @@ xdp_data_meta_unsupported(const struct xdp_buff *xdp) > > static inline bool xdp_metalen_invalid(unsigned long metalen) > { > - return (metalen & (sizeof(__u32) - 1)) || (metalen > 32); > + typeof(metalen) meta_max; > + > + meta_max = type_max(typeof_member(struct skb_shared_info, meta_len)); > + BUILD_BUG_ON(!__builtin_constant_p(meta_max)); > + > + return !IS_ALIGNED(metalen, sizeof(u32)) || metalen > meta_max; > } > > struct xdp_attachment_info {