From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id EDF1CC83F18 for ; Thu, 10 Jul 2025 08:28:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 43F476B00AA; Thu, 10 Jul 2025 04:28:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 410216B00AF; Thu, 10 Jul 2025 04:28:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2FF7D6B00AE; Thu, 10 Jul 2025 04:28:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 189B66B00AA for ; Thu, 10 Jul 2025 04:28:24 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 6850A1A04D2 for ; Thu, 10 Jul 2025 08:28:23 +0000 (UTC) X-FDA: 83647678086.14.074F484 Received: from invmail4.hynix.com (exvmail4.skhynix.com [166.125.252.92]) by imf26.hostedemail.com (Postfix) with ESMTP id 97F25140003 for ; Thu, 10 Jul 2025 08:28:21 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; spf=pass (imf26.hostedemail.com: domain of byungchul@sk.com designates 166.125.252.92 as permitted sender) smtp.mailfrom=byungchul@sk.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1752136102; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=mLv+4+OlSnivIWhuNPqXBs3wDsgmhXQ44RuwojT/mis=; b=jOrFKxkjig5zHjnpBh7y2Lv8t4dhv60jIL8W08IXHvabE+Y5n+ar0nRBb9XKzX8T3Z6nR3 u3MqdtaKV6hEesNOWnUvnqYEo+GwQ7N6GKx78PO4jYyfYJPp4QROtB/ETkdNCSfOJbUelN M+2wcxPeMDq69PyynaORDn3euNS6rvc= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; spf=pass (imf26.hostedemail.com: domain of byungchul@sk.com designates 166.125.252.92 as permitted sender) smtp.mailfrom=byungchul@sk.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1752136102; a=rsa-sha256; cv=none; b=kpVqOZM3tEkFVelE5Q16bHLwyeTiIWVZaiHVMsbD6OyOjwBIe1uaBwjdoUV0cCHbkzRuxN 6sSe4pKnezOFodTR3GVqLmg3XlRArtZyBELOtKYyymzdWQd400ITa3N79cd4ecbf7R71ox teGu5tQpMqRvMGYODk+mxGMU7ZWj/u4= X-AuditID: a67dfc5b-681ff7000002311f-ca-686f79a1a247 From: Byungchul Park To: willy@infradead.org, netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, kernel_team@skhynix.com, kuba@kernel.org, almasrymina@google.com, ilias.apalodimas@linaro.org, harry.yoo@oracle.com, hawk@kernel.org, akpm@linux-foundation.org, davem@davemloft.net, john.fastabend@gmail.com, andrew+netdev@lunn.ch, asml.silence@gmail.com, toke@redhat.com, tariqt@nvidia.com, edumazet@google.com, pabeni@redhat.com, saeedm@nvidia.com, leon@kernel.org, ast@kernel.org, daniel@iogearbox.net, david@redhat.com, lorenzo.stoakes@oracle.com, Liam.Howlett@oracle.com, vbabka@suse.cz, rppt@kernel.org, surenb@google.com, mhocko@suse.com, horms@kernel.org, linux-rdma@vger.kernel.org, bpf@vger.kernel.org, vishal.moola@gmail.com, hannes@cmpxchg.org, ziy@nvidia.com, jackmanb@google.com Subject: [PATCH net-next v9 0/8] Split netmem from struct page Date: Thu, 10 Jul 2025 17:27:59 +0900 Message-Id: <20250710082807.27402-1-byungchul@sk.com> X-Mailer: git-send-email 2.17.1 X-Brightmail-Tracker: H4sIAAAAAAAAAzWRa0hTcRiH++/8z8Xl4DQvnQwSRmVGmYbF+yHMwuD4waykEoVq6MGt5rR5 ScPCclSONClL89ZUKu+LJTrtgk2ddoHUUleWyrpA5gUveZtgLunbw/vwe768DCFtxh6MUp0o aNRylYwSY/GYc+nO0tQ4hW/tLy8oMtRQUD2fAo+HTSQUVTUgmFkYoGG6rYOC8tJZAoreazH8 MSwS8MNio6HaGAJDj35ieH69kQDbrU4KsrR2Al4sjNNw1VQhgq6GbBJyFx8S0Jg+TMOH5iIK BmuWSfhpzsLwuqASw1B2IFj07jD7dhRBm6FRBLM3iym406On4Jt2CEFPqw1D4ZVsBIaXVhLs 8yuNwvZBOnAz3zo6QfD1lZ9EfFPBV5rXG5P4pxXbeZ21h+CNVZkUb5y6TfNf+p5TfGe+HfNN pmkRn5UxTvGTPz5jfuJlL8Ub6nsx/07fRh9ZFyHeFy2olMmCZlfAGbHi2o3vKD4/IOXh2CiR jrR+OuTEcKw/V5vdROoQ848zde6OM8V6cVbrAuFgV9aPm7Z1YB0SMwRbS3FtNQO0Q7iwAZyt zIIdjNktnNlehxwdCbuHe1ZydDXvyVU/aSEcW46dpLnXGd3kqtjAvaqw4hy0Vo/WVCGpUp0c K1eq/H0UqWplik9UXKwRrXz00aWlSBOa6gozI5ZBMmdJV4xaISXlyQmpsWbEMYTMVTIfrlJI JdHy1IuCJu60JkklJJjRRgbL1kt2z16IlrIx8kThnCDEC5r/VsQ4eaSjCB+PsBZ7cJSlrjPz yxu35RGLQnNcfTgvqCy039C+6R7ZVyIVsDk50F4eenJrWta2YjJk5v6BuQdVEu+5XDdq+nxe jLa7J/zgnrzoQ8rikfcLH4P6f7d0uB3zbfXM2bt09tupKG9uueDEjeC04BCrq+Fujk+lKVIR v8MlZfByzX4ZTlDI/bYTmgT5X0ihWDbNAgAA X-Brightmail-Tracker: H4sIAAAAAAAAAwGvAlD9CAMSnAQaCGludGVybmFsIgYKBApOO4MtoXlvaDDzmBU4nK+sBjir +Hg4p+C4BTicqrYBOPT52wc488THBjijofYDOJzPhAQ49a/6AzjlxuIHOKuyTTjfpuYEOLyH twM44o/IBjiNhPsDOL357gc4grioAjjDnckFONC2jgU4lPqlAzi3gOAHONO6nAY43qz/BTjm wo0EOMmaqQQ4345AOMagFjj2y+wBOMSvtwI49oydBjiT0qAGOOOE3wE40sPiBDibgY4BOK++ 2AU4+/icBjibxd4HQCVIw+zvA0i0qdkCSLma3QdIoLJ1SLOoKkiK2NIDSLKqiQZIsvKSB0jc 1rwGSMiY+wRIubjzAkiNg+4GSPHl2gRI777VBkij6PACSK+01QRQEloKPGRlbGl2ZXIvPmAK aIaI5AFwmD54pe3sA4ABhDGKAQgIGBA0GImKFooBCQgGECcY2Nj5A4oBCQgUEDEY8+LHBIoB CggDEK0GGMSs2weKAQkIExA+GOKixgSKAQkIBBAlGML7rgGKAQgIDRA1GLueUYoBCQgYEB8Y q7DAA5ABCKABAKoBFGludm1haWw1LnNraHluaXguY29tsgEGCgSmffyRuAH000fCARAIASIM DdBnbmgSBWF2c3ltwgEYCAMiFA34WGxoEg1kYXl6ZXJvX3J1bGVzwgEbCAQiFw1KV2VgEhBn YXRla2VlcGVyX3J1bGVzwgECCAkagAFStUMQj1PjVdNoZT/OAPt2AocD97vLFII+h6s91m0S mF7sKLoCf1VxcIeIcprXRwHV6mIkqOm1liZtnc8x0/RpYbEGNPseRI+eggTUBb90OjNmVkDC 24ml8nD574OJSsUKMQnwxFiTr62AkyD/0l+qqLwXM54ldy5MlpvIN5SFDSIEc2hhMSoDcnNh GcRSGa8CAAA= X-CFilter-Loop: Reflected X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 97F25140003 X-Stat-Signature: rcrcawbkddqgbkaeikn8my3p7sokwr4t X-Rspam-User: X-HE-Tag: 1752136101-362536 X-HE-Meta: U2FsdGVkX18eSze2Bwdz9JzSU4N+Zxik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zZv96k0Tihcgu7YW+O3OvtajVv3Fa+FpFUZ6L7LgmSy04s1Zh/iwgR/vTb/DQZY= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Hi all, The MM subsystem is trying to reduce struct page to a single pointer. See the following link for your information: https://kernelnewbies.org/MatthewWilcox/Memdescs/Path The first step towards that is splitting struct page by its individual users, as has already been done with folio and slab. This patchset does that for page pool. Matthew Wilcox tried and stopped the same work, you can see in: https://lore.kernel.org/linux-mm/20230111042214.907030-1-willy@infradead.org/ I focused on removing the page pool members in struct page this time, not moving the allocation code of page pool from net to mm. It can be done later if needed. The final patch removing the page pool fields will be posted once all the converting of page to netmem are done: 1. converting use of the pp fields in struct page in prueth_swdata. 2. converting use of the pp fields in struct page in freescale driver. For our discussion, I'm sharing what the final patch looks like, in this cover letter. Byungchul --8<-- commit 1847d9890f798456b21ccb27aac7545303048492 Author: Byungchul Park Date: Wed May 28 20:44:55 2025 +0900 mm, netmem: remove the page pool members in struct page Now that all the users of the page pool members in struct page have been gone, the members can be removed from struct page. However, since struct netmem_desc still uses the space in struct page, the important offsets should be checked properly, until struct netmem_desc has its own instance from slab. Remove the page pool members in struct page and modify static checkers for the offsets. Signed-off-by: Byungchul Park diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 32ba5126e221..db2fe0d0ebbf 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -120,17 +120,6 @@ struct page { */ unsigned long private; }; - struct { /* page_pool used by netstack */ - /** - * @pp_magic: magic value to avoid recycling non - * page_pool allocated pages. - */ - unsigned long pp_magic; - struct page_pool *pp; - unsigned long _pp_mapping_pad; - unsigned long dma_addr; - atomic_long_t pp_ref_count; - }; struct { /* Tail pages of compound page */ unsigned long compound_head; /* Bit zero is set */ }; diff --git a/include/net/netmem.h b/include/net/netmem.h index 8f354ae7d5c3..3414f184d018 100644 --- a/include/net/netmem.h +++ b/include/net/netmem.h @@ -42,11 +42,8 @@ struct netmem_desc { static_assert(offsetof(struct page, pg) == \ offsetof(struct netmem_desc, desc)) NETMEM_DESC_ASSERT_OFFSET(flags, _flags); -NETMEM_DESC_ASSERT_OFFSET(pp_magic, pp_magic); -NETMEM_DESC_ASSERT_OFFSET(pp, pp); -NETMEM_DESC_ASSERT_OFFSET(_pp_mapping_pad, _pp_mapping_pad); -NETMEM_DESC_ASSERT_OFFSET(dma_addr, dma_addr); -NETMEM_DESC_ASSERT_OFFSET(pp_ref_count, pp_ref_count); +NETMEM_DESC_ASSERT_OFFSET(lru, pp_magic); +NETMEM_DESC_ASSERT_OFFSET(mapping, _pp_mapping_pad); #undef NETMEM_DESC_ASSERT_OFFSET /* --- Changes from v8: 1. Rebase on net-next/main as of Jul 10. 2. Exclude non-controversial patches that have already been merged to net-next. 3. Re-add the patches that focus on removing accessing the page pool fields in struct page. 4. Add utility APIs e.g. casting, to use struct netmem_desc as descriptor, to support __netmem_get_pp() that has started to be used again e.g. by libeth. Changes from v7 (no actual updates): 1. Exclude "netmem: introduce struct netmem_desc mirroring struct page" that might be controversial. 2. Exclude "netmem: introduce a netmem API, virt_to_head_netmem()" since there are no users. Changes from v6 (no actual updates): 1. Rebase on net-next/main as of Jun 25. 2. Supplement a comment describing struct net_iov. 3. Exclude a controversial patch, "page_pool: access ->pp_magic through struct netmem_desc in page_pool_page_is_pp()". 4. Exclude "netmem: remove __netmem_get_pp()" since the API started to be used again by libeth. Changes from v5 (no actual updates): 1. Rebase on net-next/main as of Jun 20. 2. Add given 'Reviewed-by's and 'Acked-by's, thanks to all. 3. Add missing cc's. Changes from v4: 1. Add given 'Reviewed-by's, thanks to all. 2. Exclude potentially controversial patches. Changes from v3: 1. Relocates ->owner and ->type of net_iov out of netmem_desc and make them be net_iov specific. 2. Remove __force when casting struct page to struct netmem_desc. Changes from v2: 1. Introduce a netmem API, virt_to_head_netmem(), and use it when it's needed. 2. Introduce struct netmem_desc as a new struct and union'ed with the existing fields in struct net_iov. 3. Make page_pool_page_is_pp() access ->pp_magic through struct netmem_desc instead of struct page. 4. Move netmem alloc APIs from include/net/netmem.h to net/core/netmem_priv.h. 5. Apply trivial feedbacks, thanks to Mina, Pavel, and Toke. 6. Add given 'Reviewed-by's, thanks to Mina. Changes from v1: 1. Rebase on net-next's main as of May 26. 2. Check checkpatch.pl, feedbacked by SJ Park. 3. Add converting of page to netmem in mt76. 4. Revert 'mlx5: use netmem descriptor and APIs for page pool' since it's on-going by Tariq Toukan. I will wait for his work to be done. 5. Revert 'page_pool: use netmem APIs to access page->pp_magic in page_pool_page_is_pp()' since we need more discussion. 6. Revert 'mm, netmem: remove the page pool members in struct page' since there are some prerequisite works to remove the page pool fields from struct page. I can submit this patch separatedly later. 7. Cancel relocating a page pool member in struct page. 8. Modify static assert for offests and size of struct netmem_desc. Changes from rfc: 1. Rebase on net-next's main branch. https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/ 2. Fix a build error reported by kernel test robot. https://lore.kernel.org/all/202505100932.uzAMBW1y-lkp@intel.com/ 3. Add given 'Reviewed-by's, thanks to Mina and Ilias. 4. Do static_assert() on the size of struct netmem_desc instead of placing place-holder in struct page, feedbacked by Matthew. 5. Do struct_group_tagged(netmem_desc) on struct net_iov instead of wholly renaming it to strcut netmem_desc, feedbacked by Mina and Pavel. Byungchul Park (8): netmem: introduce struct netmem_desc mirroring struct page netmem: introduce utility APIs to use struct netmem_desc page_pool: access ->pp_magic through struct netmem_desc in page_pool_page_is_pp() netmem: use netmem_desc instead of page to access ->pp in __netmem_get_pp() netmem: introduce a netmem API, virt_to_head_netmem() mlx4: use netmem descriptor and APIs for page pool netdevsim: use netmem descriptor and APIs for page pool mt76: use netmem descriptor and APIs for page pool drivers/net/ethernet/mellanox/mlx4/en_rx.c | 48 ++--- drivers/net/ethernet/mellanox/mlx4/en_tx.c | 8 +- drivers/net/ethernet/mellanox/mlx4/mlx4_en.h | 4 +- drivers/net/netdevsim/netdev.c | 19 +- drivers/net/netdevsim/netdevsim.h | 2 +- drivers/net/wireless/mediatek/mt76/dma.c | 6 +- drivers/net/wireless/mediatek/mt76/mt76.h | 12 +- .../net/wireless/mediatek/mt76/sdio_txrx.c | 24 +-- drivers/net/wireless/mediatek/mt76/usb.c | 10 +- include/linux/mm.h | 12 -- include/net/netmem.h | 183 +++++++++++++++--- mm/page_alloc.c | 1 + 12 files changed, 231 insertions(+), 98 deletions(-) base-commit: c65d34296b2252897e37835d6007bbd01b255742 -- 2.17.1