Received: by 2002:a05:7412:8d23:b0:f7:29d7:fb05 with SMTP id bj35csp477156rdb; Sat, 16 Dec 2023 17:45:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IGY/BJV2eqiQhKjwtpASp5i1OIk4SJS/WQYfKVEUya8LSA1H2BUHoeLIWE2biCTkZylK/fp X-Received: by 2002:a6b:e409:0:b0:7b7:1861:ef72 with SMTP id u9-20020a6be409000000b007b71861ef72mr15315990iog.25.1702777538874; Sat, 16 Dec 2023 17:45:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702777538; cv=none; d=google.com; s=arc-20160816; b=QEBjQk7HLSTmsAFVJoqJh85f6JvtswcdwLwZ2LR9DlkinB2pUXcGPVlS9ww4V0qYLS evl15JivCEjFGMz58+x//kRckMnigUSK6sFOkEDWO8mw0RZgVTLERNMK02aMaJ6euACy jNLXOO2JtQrGYp5eqLUk+vbIb/ccXb1dsJOUI+sQbQGtBOizQyD+s/4DQSclPpJMylHV UNDbR/lKx0EtY68QrdujVascUFmoF8YrheVxZu85JiJ5QgfWDwbakQ2zkeFKYRWgIBje r+ycwpa92CzljNg+lEV6JCEiierogs9Ha7WYjOJlu1x9gtzhGzfTjBVV4ZKfDvxIKROq mTgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=PAgJMsWxhkI94hinCvZTKlZ3nJ7Rt5yROV8R8MpQ9KQ=; fh=IyNs73JWsbznFTYFNyQpPBZyjXb2qEKtVlBJZEeRk2k=; b=pOOVshKAbOJFyV8Vj3W/sHWDGB2vsMu7gD5rxnl+7M7w70rAWdpePVgDcczp4U9gGc PnJlPMGCWSSnozKOBaP5RTluTqLHe9i9X9FBWGhQbvI0E8ArY/sG6UQE5x1+C55EbX4b 8YBYMJnAnv5NNaCZirRRFnMbnmP1x/jzYCmGCi2OcQLGQ6Wq0IjYshWJiE4opE9dYvVi hjfZPw7LJusltj1hmP+xiwR7a7pN9JrE3uoqWsh+buq65qz1Uqj8EX0Gtv2iN+tiP5mk 8oMZPc6sAX3FjZ42mhZZMCUnn2UIqcMoqqYgoQpzvcmKZf1gWthWOqxXnxzyIk+EBbVv msRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=npth3316; spf=pass (google.com: domain of linux-kernel+bounces-2434-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2434-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id m7-20020a635807000000b005c665c81b7bsi15146826pgb.36.2023.12.16.17.45.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Dec 2023 17:45:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-2434-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=npth3316; spf=pass (google.com: domain of linux-kernel+bounces-2434-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2434-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 B190BB22DF6 for ; Sun, 17 Dec 2023 01:45:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0F5B31105; Sun, 17 Dec 2023 01:45:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="npth3316" X-Original-To: linux-kernel@vger.kernel.org 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) 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?