From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from invmail4.hynix.com (exvmail4.hynix.com [166.125.252.92]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 31A5027144B; Wed, 16 Jul 2025 04:27:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=166.125.252.92 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752640055; cv=none; b=LOI383soLGhguaJz8BZTAzlAJWdIAqZ08e6oZ0GU8S3R2alu14vDoaWZcvRInNiivRh49BL1TgCs6cB1oyR6bLk9nfAC3eT7wiA9/gQW7HKiqfPthnNYrCh+HW5dYgK/Xxeht/ys5RfbEy9+1fjuy2cWqEfr791BrGHG5HMygjM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752640055; c=relaxed/simple; bh=gYSJxs1CnBdNF+UKOy6bV8DYyOv8fBWKv4zRjZwmbRI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Bn2RP3TZfCgjtgGconwhsJwQCLXJ0xtYPlwjLSo4fKVuAK6rSWM0AI45d9Ga67UCrtwDJ+ZP7TI/SMjKE2zWF51gJd+rOX+Sq1aN5S4Nxem2roMQSEQHlyJ+sqKLpoDMq67MfwmhJaBIXY+VsqxCxCF6EEAySf+Ni5aNuTYOLxE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sk.com; spf=pass smtp.mailfrom=sk.com; arc=none smtp.client-ip=166.125.252.92 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sk.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sk.com X-AuditID: a67dfc5b-669ff7000002311f-fe-68772a2f6dda Date: Wed, 16 Jul 2025 13:27:22 +0900 From: Byungchul Park To: Pavel Begunkov Cc: Mina Almasry , willy@infradead.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, kernel_team@skhynix.com, ilias.apalodimas@linaro.org, harry.yoo@oracle.com, akpm@linux-foundation.org, andrew+netdev@lunn.ch, toke@redhat.com, david@redhat.com, Liam.Howlett@oracle.com, vbabka@suse.cz, rppt@kernel.org, surenb@google.com, mhocko@suse.com, linux-rdma@vger.kernel.org, bpf@vger.kernel.org, vishal.moola@gmail.com, hannes@cmpxchg.org, ziy@nvidia.com, jackmanb@google.com, wei.fang@nxp.com, shenwei.wang@nxp.com, xiaoning.wang@nxp.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, anthony.l.nguyen@intel.com, przemyslaw.kitszel@intel.com, sgoutham@marvell.com, gakula@marvell.com, sbhatta@marvell.com, hkelam@marvell.com, bbhushan2@marvell.com, tariqt@nvidia.com, ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com, sdf@fomichev.me, saeedm@nvidia.com, leon@kernel.org, mbloch@nvidia.com, danishanwar@ti.com, rogerq@kernel.org, nbd@nbd.name, lorenzo@kernel.org, ryder.lee@mediatek.com, shayne.chen@mediatek.com, sean.wang@mediatek.com, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, aleksander.lobakin@intel.com, horms@kernel.org, m-malladi@ti.com, krzysztof.kozlowski@linaro.org, matthias.schiffer@ew.tq-group.com, robh@kernel.org, imx@lists.linux.dev, intel-wired-lan@lists.osuosl.org, linux-arm-kernel@lists.infradead.org, linux-wireless@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: Re: [PATCH net-next v10 02/12] netmem: use netmem_desc instead of page to access ->pp in __netmem_get_pp() Message-ID: <20250716042722.GA12760@system.software.com> References: <20250714120047.35901-1-byungchul@sk.com> <20250714120047.35901-3-byungchul@sk.com> <9bed2f6e-6251-4d0c-ad1e-f1b8625a0a10@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <9bed2f6e-6251-4d0c-ad1e-f1b8625a0a10@gmail.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-Brightmail-Tracker: H4sIAAAAAAAAA02SbUyTVxTHc5/3dm3y2Dl3lZhl3UTHNpnOZCd7CyNZ8vhhyab7MrfomrWj zQqaIhVMNhl0WyCKRDQppWjRIi0Yq2V9mRTUwpQpm1igqxSogmNMimwopKUM1paY8e2X/7nn /M5NDkfKPMw6TlOwX6UrUGjljJgST0kaXs3OOqB+bT66BcyOcwzcftRAQ0usGJruemkI2DG0 9cYIMDe7ETyOh1lwVgyR8KjrOgNnGuZIiF84QoH5loGCWcc8CX9cG2Wh2/8vBS3ODyBydpwC 3w8eEjpnN8Do0W4GjhgSJNSOfMfA0mCChvb4QxbKvDYC2iddLPS6q2g4Pt9Igqf0btI1FqSh 75KZgb7y2whGzi3RMO5PCqO2IRaqWkwI/JftDJQZXoeo6zELf5/oIiFSlQOLRj1cs6yBuZtR BOHGAQKWfF4Wfhs5T0OXw0NA/704CXOH6xmonDqKYKD2EgE99RdosN7sJ5J77ITg0gIBNQEL A2OGCIJA5ygFdd9WIXB0hGj4x5f8ciJmZnJyhc7oNCl4h61I+NF+hxAmqhcJIdRxgxB+Mg2z gsVZJLTasoQzvr8IoTIUIAVncwUjOGeOscJQ0McI3cYEJbRaDwkTrbXow/W7xG8rVVqNXqXL fvdzsbrj1J/0vlJcHEtoStGArBKJOMxvw7GJq8wTdlhOpJniN+A7MzaUYobfiEOhOJni1fzL ePJ3P1uJxBzJN0qws95DpQpP80X49L1QmqU8YINhMt0s48MI91k2Leer8C+199NvyOTQhZOB 5FAuyRm4aZFbjp/D5a66tEvEv4NdZQ+JFD/Dv4CvuK8TKS/mZ0R4uqeUWF56Lb5qC1HVaJVp hcK0QmH6X2FaobAgqhnJNAX6fIVGu22zuqRAU7z5i735TpQ857NfL3zqRTO9O/2I55BcIvW+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b+DFenMiaAi 5RVeTk7N8s/il0hh0/H5rgRhE2kqeEjFeYnwMrnYfJk6iha5FphcC0yu/02uBSY3outRksFk y9EZjBvWWPbo7SZD3pode3NkpPzV2oMz3/lQNLQ5gAQeaRPVvo02vYbR2Sz2nAAiPNYmqUuD SqTO1tkPSOa928y5RskSQMt5WrtU/e5n0naNsEtnlfZI0j7J/N+U4hNS8pGVHX70+ZYZ3QhV 68ObMvyryj1Vb4ecv+7Yf3Aq/c6KVGvDh/VlznGjnPhG5oD9i+e6yQpTZ7bbcPFAbU80JWqW TW+ZF1nVO0ufjm0NLDux+b2IPTMjOakrMnmNXUc+TX91YNmSVzp3bsgae8H9sb0oVdx9SJ91 ZnXp+oR3Dl34PfmBlrboda+lYbNF9y8C3OucpwMAAA== X-CFilter-Loop: Reflected On Tue, Jul 15, 2025 at 11:37:45AM +0100, Pavel Begunkov wrote: > On 7/14/25 20:37, Mina Almasry wrote: > > On Mon, Jul 14, 2025 at 5:01 AM Byungchul Park wrote: > ...>> +static inline struct netmem_desc *pp_page_to_nmdesc(struct page *page) > > > +{ > > > + DEBUG_NET_WARN_ON_ONCE(!page_pool_page_is_pp(page)); > > > + > > > + /* XXX: How to extract netmem_desc from page must be changed, > > > + * once netmem_desc no longer overlays on page and will be > > > + * allocated through slab. > > > + */ > > > + return (struct netmem_desc *)page; > > > +} > > > + > > > > Same thing. Do not create a generic looking pp_page_to_nmdesc helper > > which does not check that the page is the correct type. The > > DEBUG_NET... is not good enough. > > > > You don't need to add a generic helper here. There is only one call > > site. Open code this in the callsite. The one callsite is marked as > > unsafe, only called by code that knows that the netmem is specifically > > a pp page. Open code this in the unsafe callsite, instead of creating > > a generic looking unsafe helper and not even documenting it's unsafe. > > > > > /** > > > * __netmem_get_pp - unsafely get pointer to the &page_pool backing @netmem > > > * @netmem: netmem reference to get the pointer from > > > @@ -280,7 +291,7 @@ static inline struct net_iov *__netmem_clear_lsb(netmem_ref netmem) > > > */ > > > static inline struct page_pool *__netmem_get_pp(netmem_ref netmem) > > > { > > > - return __netmem_to_page(netmem)->pp; > > > + return pp_page_to_nmdesc(__netmem_to_page(netmem))->pp; > > > } > > > > This makes me very sad. Casting from netmem -> page -> nmdesc... > > The function is not used, and I don't think the series adds any That's whay I'd been keeping the patch, 'netmem: remove __netmem_get_pp()' until v6 [1]. [1] https://lore.kernel.org/all/20250620041224.46646-7-byungchul@sk.com/ However, as the following change log described [2], I excluded the patch from v7 since __netmem_get_pp() started to be used again by libeth. [2] https://lore.kernel.org/all/20250625043350.7939-1-byungchul@sk.com/ > new users? It can be killed then. It's a horrible function anyway, > would be much better to have a variant taking struct page * if > necessary. > > > Instead, we should be able to go from netmem directly to nmdesc. I > > would suggest rename __netmem_clear_lsb to netmem_to_nmdesc and have > > it return netmem_desc instead of net_iov. Then use it here. > > Glad you liked the diff I suggested :) In either case, seems > like it's not strictly necessary for this iteration as > __netmem_get_pp() should be killed, and the rest of patches work > directly with pages. Killing __netmem_get_pp() would be the best I think. Byungchul > > > > We could have an unsafe version of netmem_to_nmdesc which converts the > > netmem to netmem_desc without clearing the lsb and mark it unsafe. > > > > -- > Pavel Begunkov