From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3593E1FA1; Sun, 17 Dec 2023 01:45:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="npth3316" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3DB1C433C7; Sun, 17 Dec 2023 01:45:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702777520; bh=GJ+yokT7RhwyIcN6IONxEy2r0GaoEnqwXkRiPSztTmg=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=npth3316p6Vn06DE4RsPPOpdjwlc84G/9uIDZY/GWB9sqcOhYRX9+jj/QeeDcoCbc r7VADqZfYpRmd1zvg1DeWicsplyeluRAKPAOvLhdT+o9bbpNELPO6S0I+ouEGjFNJ9 +QTamWw0A1HGaOdlCuZ6wGWwHJ1HsMhUPtdKhDsBbLJaJGaoPzOs+sTWel9McRpjd6 SZd0quVZmx26qvke9qRVBtBWAmz8+oTVBNLNlvvD7UVtjEU1VLXtGgMuW9/pAbP8Td q5gqxlKd7mqiWQ/8t6S+sGUPoRen0xzLe5X+2qWQW24NoUlbwga49J6u26VMgnqRia RkbKufMWzOk1Q== Message-ID: <84787af3-aa5e-4202-8578-7a9f14283d87@kernel.org> Date: Sat, 16 Dec 2023 18:45:15 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH net-next v1 2/4] net: introduce abstraction for network memory Content-Language: en-US To: Mina Almasry , Jakub Kicinski Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Greg Kroah-Hartman , "Rafael J. Wysocki" , Sumit Semwal , =?UTF-8?Q?Christian_K=C3=B6nig?= , Michael Chan , "David S. Miller" , Eric Dumazet , Paolo Abeni , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Wei Fang , Shenwei Wang , Clark Wang , NXP Linux Team , Jeroen de Borst , Praveen Kaligineedi , Shailend Chand , Yisen Zhuang , Salil Mehta , Jesse Brandeburg , Tony Nguyen , Thomas Petazzoni , Marcin Wojtas , Russell King , Sunil Goutham , Geetha sowjanya , Subbaraya Sundeep , hariprasad , Felix Fietkau , John Crispin , Sean Wang , Mark Lee , Lorenzo Bianconi , Matthias Brugger , AngeloGioacchino Del Regno , Saeed Mahameed , Leon Romanovsky , Horatiu Vultur , UNGLinuxDriver@microchip.com, "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Jassi Brar , Ilias Apalodimas , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Siddharth Vadapalli , Ravi Gunasekaran , Roger Quadros , Jiawen Wu , Mengyuan Lou , Ronak Doshi , VMware PV-Drivers Reviewers , Ryder Lee , Shayne Chen , Kalle Valo , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Stefan Hajnoczi , Stefano Garzarella , Shuah Khan , =?UTF-8?Q?Micka=C3=ABl_Sala=C3=BCn?= , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Jason Gunthorpe , Shakeel Butt , Yunsheng Lin , Willem de Bruijn References: <20231214020530.2267499-1-almasrymina@google.com> <20231214020530.2267499-3-almasrymina@google.com> <20231215185159.7bada9a7@kernel.org> From: David Ahern In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 12/16/23 2:10 PM, Mina Almasry wrote: > On Fri, Dec 15, 2023 at 6:52 PM Jakub Kicinski wrote: >> >> On Wed, 13 Dec 2023 18:05:25 -0800 Mina Almasry wrote: >>> +struct netmem { >>> + union { >>> + struct page page; >>> + >>> + /* Stub to prevent compiler implicitly converting from page* >>> + * to netmem_t* and vice versa. >>> + * >>> + * Other memory type(s) net stack would like to support >>> + * can be added to this union. >>> + */ >>> + void *addr; >>> + }; >>> +}; >> >> My mind went to something like: >> >> typedef unsigned long __bitwise netmem_ref; >> >> instead. struct netmem does not exist, it's a handle which has >> to be converted to a real type using a helper. > > Sure thing I can do that. Is it better to do something like: > > struct netmem_ref; > > like in this patch: > > https://lore.kernel.org/linux-mm/20221108194139.57604-1-torvalds@linux-foundation.org/ > > Asking because checkpatch tells me not to add typedefs to the kernel, > but checkpatch can be ignored if you think it's OK. > > Also with this approach I can't use container_of and I need to do a > cast, I assume that's fine. > Isn't that the whole point of this set - to introduce a new data type and avoid casts?