netmem: remove the pp fields from net_iov
Subsystems (4)
PATCH RESEND 1/1 netmem: remove the pp fields from net_iov
Now that the pp fields in net_iov have no users, remove them from net_iov and clean up.
---
The original post was:
https://lore.kernel.org/all/[email protected]/
1/3 was covered by Pavel's patch:
commit f0243d2b86b97 ("io_uring/zcrx: convert to use netmem_desc").
2/3 was taken by Jakub and merged:
commit df59bb5b9af3f ("netmem, devmem, tcp: access pp fields through @desc in net_iov")
Now that io-uring and net core changes converge in one tree, I'm resending the 3/3, which is what Jakub asked:
https://lore.kernel.org/all/[email protected]/
--- include/net/netmem.h | 38 +------------------------------------- 1 file changed, 1 insertion(+), 37 deletions(-)
include/net/netmem.h +1 -37
@@ -93,23 +93,7 @@ enum net_iov_type {* supported. */ struct net_iov { -union { -struct netmem_desc desc; - -/* XXX: The following part should be removed once all -* the references to them are converted so as to be -* accessed via netmem_desc e.g. niov->desc.pp instead -* of niov->pp. -*/ -struct { -unsigned long _flags; -unsigned long pp_magic; -struct page_pool *pp; -unsigned long _pp_mapping_pad; -unsigned long dma_addr; -atomic_long_t pp_ref_count; - }; - }; +struct netmem_desc desc;struct net_iov_area *owner;enum net_iov_type type; };
@@ -123,26 +107,6 @@ struct net_iov_area {unsigned long base_virtual; }; -/* net_iov is union'ed with struct netmem_desc mirroring struct page, so -* the page_pool can access these fields without worrying whether the -* underlying fields are accessed via netmem_desc or directly via -* net_iov, until all the references to them are converted so as to be -* accessed via netmem_desc e.g. niov->desc.pp instead of niov->pp. -* -* The non-net stack fields of struct page are private to the mm stack -* and must never be mirrored to net_iov. -*/ -#define NET_IOV_ASSERT_OFFSET (desc, iov) \ - static_assert(offsetof(struct netmem_desc, desc) == \ - offsetof(struct net_iov, iov)) -NET_IOV_ASSERT_OFFSET (_flags, _flags); -NET_IOV_ASSERT_OFFSET (pp_magic, pp_magic); -NET_IOV_ASSERT_OFFSET (pp, pp); -NET_IOV_ASSERT_OFFSET (_pp_mapping_pad, _pp_mapping_pad); -NET_IOV_ASSERT_OFFSET (dma_addr, dma_addr); -NET_IOV_ASSERT_OFFSET (pp_ref_count, pp_ref_count); -#undef NET_IOV_ASSERT_OFFSET -static inline struct net_iov_area *net_iov_owner (const struct net_iov *niov) {return niov->owner;
Signature · 1 line
2.17.1
Quoted 4 lines · Byungchul Park
Now that the pp fields in
net_iovhave no users, remove them fromnet_iovand clean up.Signed-off-by Byungchul Park <[email protected]>
Quoted 2 lines · Byungchul Park
Now that the pp fields in
net_iovhave no users, remove them fromnet_iovand clean up.
Looks good, it's great to get rid of all this aliasing.
Signature · 1 line
Pavel Begunkov
Quoted 4 lines · Byungchul Park
Now that the pp fields in
net_iovhave no users, remove them fromnet_iovand clean up.Signed-off-by Byungchul Park <[email protected]>
Quoted 70 lines · Byungchul Park
Now that the pp fields in
net_iovhave no users, remove them fromnet_iovand clean up.Signed-off-by Byungchul Park <[email protected]>---
The original post was:https://lore.kernel.org/all/[email protected]/
1/3 was covered by Pavel's patch:
commit
f0243d2b86b97("io_uring/zcrx: convert to usenetmem_desc").2/3 was taken by Jakub and merged:
commit
df59bb5b9af3f("netmem, devmem, tcp: access pp fields through @desc innet_iov")Now that io-uring and net core changes converge in one tree, I'm resending the 3/3, which is what Jakub asked:
https://lore.kernel.org/all/[email protected]/
--- include/net/netmem.h | 38 +------------------------------------- 1 file changed, 1 insertion(+), 37 deletions(-)include/net/netmem.h +1
-27@@ -93,23 +93,7 @@ enum net_iov_type {* supported. */ struct net_iov { -union { -struct netmem_desc desc; - -/* XXX: The following part should be removed once all -* the references to them are converted so as to be -* accessed via netmem_desc e.g. niov->desc.pp instead -* of niov->pp. -*/ -struct { -unsigned long _flags; -unsigned long pp_magic; -struct page_pool *pp; -unsigned long _pp_mapping_pad; -unsigned long dma_addr; -atomic_long_t pp_ref_count; - }; - }; +struct netmem_desc desc;struct net_iov_area *owner;enum net_iov_type type; };@@ -123,26 +107,6 @@ struct net_iov_area {unsigned long base_virtual; }; -/* net_iov is union'ed with struct netmem_desc mirroring struct page, so -* the page_pool can access these fields without worrying whether the -* underlying fields are accessed via netmem_desc or directly via -* net_iov, until all the references to them are converted so as to be -* accessed via netmem_desc e.g. niov->desc.pp instead of niov->pp. -* -* The non-net stack fields of struct page are private to the mm stack -* and must never be mirrored to net_iov. -*/ -#define NET_IOV_ASSERT_OFFSET (desc, iov) \
include/net/netmem.h struct net_iov_area { · line 145
Quoted 10 lines
include/net/netmem.h +0
-10-static_assert (offsetof(struct netmem_desc , desc) == \ - offsetof(struct net_iov, iov)) -NET_IOV_ASSERT_OFFSET (_flags, _flags); -NET_IOV_ASSERT_OFFSET (pp_magic, pp_magic); -NET_IOV_ASSERT_OFFSET (pp, pp); -NET_IOV_ASSERT_OFFSET (_pp_mapping_pad, _pp_mapping_pad); -NET_IOV_ASSERT_OFFSET (dma_addr, dma_addr); -NET_IOV_ASSERT_OFFSET (pp_ref_count, pp_ref_count); -#undef NET_IOV_ASSERT_OFFSET -
Probably better to retain an assert that netmem_desc is the first field in struct net_iov, no?
There technically is no assert that netmem_desc is the first field of struct page, but it's generally well understood that the memory descriptor types should be the first field of struct page. It's not well understand that the netmem_desc type should be the first field in struct net_iov though.
--
Thanks,
Mina
Quoted 76 lines · Mina Almasry
Quoted 75 lines · Byungchul Park
Now that the pp fields in
net_iovhave no users, remove them fromnet_iovand clean up.Signed-off-by Byungchul Park <[email protected]>---
The original post was:https://lore.kernel.org/all/[email protected]/
1/3 was covered by Pavel's patch:
commit
f0243d2b86b97("io_uring/zcrx: convert to usenetmem_desc").2/3 was taken by Jakub and merged:
commit
df59bb5b9af3f("netmem, devmem, tcp: access pp fields through @desc innet_iov")Now that io-uring and net core changes converge in one tree, I'm resending the 3/3, which is what Jakub asked:
https://lore.kernel.org/all/[email protected]/
--- include/net/netmem.h | 38 +------------------------------------- 1 file changed, 1 insertion(+), 37 deletions(-)include/net/netmem.h +1
-32@@ -93,23 +93,7 @@ enum net_iov_type {* supported. */ struct net_iov { -union { -struct netmem_desc desc; - -/* XXX: The following part should be removed once all -* the references to them are converted so as to be -* accessed via netmem_desc e.g. niov->desc.pp instead -* of niov->pp. -*/ -struct { -unsigned long _flags; -unsigned long pp_magic; -struct page_pool *pp; -unsigned long _pp_mapping_pad; -unsigned long dma_addr; -atomic_long_t pp_ref_count; - }; - }; +struct netmem_desc desc;struct net_iov_area *owner;enum net_iov_type type; };@@ -123,26 +107,6 @@ struct net_iov_area {unsigned long base_virtual; }; -/* net_iov is union'ed with struct netmem_desc mirroring struct page, so -* the page_pool can access these fields without worrying whether the -* underlying fields are accessed via netmem_desc or directly via -* net_iov, until all the references to them are converted so as to be -* accessed via netmem_desc e.g. niov->desc.pp instead of niov->pp. -* -* The non-net stack fields of struct page are private to the mm stack -* and must never be mirrored to net_iov. -*/ -#define NET_IOV_ASSERT_OFFSET (desc, iov) \ - static_assert(offsetof(struct netmem_desc, desc) == \ - offsetof(struct net_iov, iov)) -NET_IOV_ASSERT_OFFSET (_flags, _flags); -NET_IOV_ASSERT_OFFSET (pp_magic, pp_magic); -NET_IOV_ASSERT_OFFSET (pp, pp);
Quoted 8 lines
include/net/netmem.h struct net_iov_area { · line 145
Quoted 5 lines
include/net/netmem.h +0
-5-NET_IOV_ASSERT_OFFSET (_pp_mapping_pad, _pp_mapping_pad); -NET_IOV_ASSERT_OFFSET (dma_addr, dma_addr); -NET_IOV_ASSERT_OFFSET (pp_ref_count, pp_ref_count); -#undef NET_IOV_ASSERT_OFFSET -Probably better to retain an assert that
netmem_descis the first field in structnet_iov, no?
What is the assert for? Can you give an example that might lead wrong without the assert?
Byungchul
Quoted 9 lines
There technically is no assert that
netmem_descis the first field of struct page, but it's generally well understood that the memory descriptor types should be the first field of struct page. It's not well understand that thenetmem_desctype should be the first field in structnet_iovthough.--
Thanks,
Mina
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Tue, 24 Feb 2026 15:14:24 +0900 you wrote:
Now that the pp fields in
net_iovhave no users, remove them fromnet_iovand clean up.Signed-off-by Byungchul Park <[email protected]>---
The original post was:[...]
Here is the summary with links:
- [RESEND,net-next] netmem: remove the pp fields from net_iov
https://git.kernel.org/netdev/net-next/c/fd6dad4e1ae2
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html