Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp484007rdb; Thu, 21 Dec 2023 15:45:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IG+wGQuosuRsIFISEVlgpdJalOVuB47CEj8S9Jq1rTgTGL7KKujFXWAMqXDIDsuqo2ZfbN4 X-Received: by 2002:a05:6e02:198b:b0:35d:763a:926c with SMTP id g11-20020a056e02198b00b0035d763a926cmr478482ilf.114.1703202334014; Thu, 21 Dec 2023 15:45:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703202333; cv=none; d=google.com; s=arc-20160816; b=F5LHkusiSQ7IAkhCY5ibBfQp1dclcQoxH9aQ06EbkDNnx27gqsJEf+Dj6FbU1+MFL2 CZHs20vcwIY+FiB4XMv2Is1wFbtdpdlpMibRjCD70Wfhn5h9apCBvUXoVqxKd/uUwc5e RhuMOdfJyO41ZLsU4Eq8YhjtEcVVPFN81jA5zJbm2gOewfKgq7eiE7HvSr7+dfFhB0K4 xNjKFu7Lz6WyFu1XqvIlALL0KihswlCAJZLlPBfwqMDwWrP6LORAhObU9yXH+IhFYbfM iO1u1O8gVw3KB8OE9/sDlwwjIGFF+hC3BfswcsqRVLoGFSZJQ3FPejGCSjGbnUdoh2zP cIQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=QYgALaqHaxsIKBoPdNM24Kf+9GYUu7tWwLOH1j6ljO4=; fh=juSLAk0EVzLIRNYMRwFyhks6z7G63qtQ67zVrXmjBbI=; b=WEA7ilEzZOK5+Tk+lgEtvYs2QuczYIuJ7gAvKx0aOdQkKiilb7mE697yJwPJ/TDH6k FWWP2buy+L316JnD3sB/jWJDl+ULRs3J+0Qs5TttwyLuMKlsQIalVdDWBZ0BKnPfGW1k li1QY5pUuoBG9Z6kqFwlABH9d9Ig9/6PXAAnWNaRjqbTk6Ny0P0JaLEkl1GaIB5ej8PR ZS45ezqJcGV+QPPrs5eh6pdK2oWnZjXlCEHri1UMB7kiI4auM69WWUKwkGiSXq6yOHlG U8Yt98mSbHlaDj++K1mPHn0Ku05icdObsETPdGYBfQcbOer3ziU+mEfLxU8FT2b4pKt3 xSjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=UESf6E2n; spf=pass (google.com: domain of linux-kernel+bounces-9186-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9186-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id z23-20020a637e17000000b005cd84c2c7easi2320164pgc.691.2023.12.21.15.45.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 15:45:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-9186-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=UESf6E2n; spf=pass (google.com: domain of linux-kernel+bounces-9186-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9186-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id A6B43B237C7 for ; Thu, 21 Dec 2023 23:44:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 60AB879948; Thu, 21 Dec 2023 23:44:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="UESf6E2n" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 12E0E7948F for ; Thu, 21 Dec 2023 23:44:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-a23566e91d5so166415066b.0 for ; Thu, 21 Dec 2023 15:44:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1703202276; x=1703807076; 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=QYgALaqHaxsIKBoPdNM24Kf+9GYUu7tWwLOH1j6ljO4=; b=UESf6E2nuapnO/93cfBZC6naRm3boMYkXVPonh+ZnJUinJ+lDpZwSCVdeq6CLi3DhW IT1l2KyQMY+m+HME1TJeUiSrERaAZFvty05AmQ/QSTF9E62XAzG0y2iukD3u+TSoUZRS GLWvh2TPZBe4pIR1Os5U14sJlpo/2t/QI4YJlXQFQ7gf63HJb6JwwJdOyB92yB81PrI7 I5rhWj/6fKhsL9cTj5CBZd5nFSXAhjsbadmxDMHVvzczXnQZisn3E68Nr5tLddpvg0IR z0qWGIjF2Yxkmoi1oyz+8D+nyihH2gz/ANd/ui49xAn6FelycX3wD4RXuZrAi7KnGjeR m0OQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703202276; x=1703807076; 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=QYgALaqHaxsIKBoPdNM24Kf+9GYUu7tWwLOH1j6ljO4=; b=mfbb/AzzQ88ORbipd7twt1DNic9Bxa1m12U1rGOBL11HbUHzdtihr2EraZxDPpJnpP EzK2pfNxK/0fEBVrbpUfIwUDcGCZUJhagrUIciiVxP2wmbJPRBhpQ5O/56Xp+9j/25rJ blfutDY7CoMTA8WkaURdduD5/xAVHNh3oAEDIoEzWuXPGby9qvtcyiw5CFyBsbksRlrM OwWdvpSXk071WoQhWAQ7kPEbGlOClp6Rhqjcx10hXLuVmlVASw4cQczft5LR1KMkFf44 QT81YhAtSGo4PVAyuyUGK6EnKho+6f6vUh7XUFdny2dl1La6a01jQZZHEfJIeJWQtwQ0 rFvg== X-Gm-Message-State: AOJu0Yx5pc8LfTTq7/woc0Q0oG+I9csewZ1rMVjs7z8tZPPVycFh2UtF quOEW5KQ8IYv4bIID0Pn8td30zeDTflHaw5tE0soX2ohzSOq X-Received: by 2002:a17:906:81d6:b0:a23:526e:4425 with SMTP id e22-20020a17090681d600b00a23526e4425mr215040ejx.66.1703202276017; Thu, 21 Dec 2023 15:44:36 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231220214505.2303297-1-almasrymina@google.com> <20231220214505.2303297-3-almasrymina@google.com> <20231221232343.qogdsoavt7z45dfc@google.com> In-Reply-To: <20231221232343.qogdsoavt7z45dfc@google.com> From: Mina Almasry Date: Thu, 21 Dec 2023 15:44:22 -0800 Message-ID: Subject: Re: [PATCH net-next v3 2/3] net: introduce abstraction for network memory To: Shakeel Butt Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux.dev, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Stefan Hajnoczi , Stefano Garzarella , David Howells , Jason Gunthorpe , =?UTF-8?Q?Christian_K=C3=B6nig?= , Yunsheng Lin , Willem de Bruijn Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Dec 21, 2023 at 3:23=E2=80=AFPM Shakeel Butt = wrote: > > On Wed, Dec 20, 2023 at 01:45:01PM -0800, Mina Almasry wrote: > > Add the netmem_ref type, an abstraction for network memory. > > > > To add support for new memory types to the net stack, we must first > > abstract the current memory type. Currently parts of the net stack > > use struct page directly: > > > > - page_pool > > - drivers > > - skb_frag_t > > > > Originally the plan was to reuse struct page* for the new memory types, > > and to set the LSB on the page* to indicate it's not really a page. > > However, for compiler type checking we need to introduce a new type. > > > > netmem_ref is introduced to abstract the underlying memory type. Curren= tly > > it's a no-op abstraction that is always a struct page underneath. In > > parallel there is an undergoing effort to add support for devmem to the > > net stack: > > > > https://lore.kernel.org/netdev/20231208005250.2910004-1-almasrymina@goo= gle.com/ > > > > Signed-off-by: Mina Almasry > > > > --- > > > > v3: > > > > - Modify struct netmem from a union of struct page + new types to an op= aque > > netmem_ref type. I went with: > > > > +typedef void *__bitwise netmem_ref; > > > > rather than this that Jakub recommended: > > > > +typedef unsigned long __bitwise netmem_ref; > > > > Because with the latter the compiler issues warnings to cast NULL to > > netmem_ref. I hope that's ok. > > > > Can you share what the warning was? You might just need __force > attribute. However you might need this __force a lot. I wonder if you > can just follow struct encoded_page example verbatim here. > The warning is like so: ./include/net/page_pool/helpers.h: In function =E2=80=98page_pool_alloc=E2= =80=99: ./include/linux/stddef.h:8:14: warning: returning =E2=80=98void *=E2=80=99 = from a function with return type =E2=80=98netmem_ref=E2=80=99 {aka =E2=80=98long u= nsigned int=E2=80=99} makes integer from pointer without a cast [-Wint-conversion] 8 | #define NULL ((void *)0) | ^ ./include/net/page_pool/helpers.h:132:24: note: in expansion of macro =E2=80=98NULL=E2=80=99 132 | return NULL; | ^~~~ And happens in all the code where: netmem_ref func() { return NULL; } It's fixable by changing the return to `return (netmem_ref NULL);` or `return 0;`, but I feel like netmem_ref should be some type which allows a cast from NULL implicitly. Also as you (and patchwork) noticed, __bitwise should not be used with void*; it's only meant for integer types. Sorry I missed that in the docs and was not running make C=3D2. --=20 Thanks, Mina