linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 1/3] netmem, io_uring/zcrx: access pp fields through @desc in net_iov
@ 2025-11-21  4:00 Byungchul Park
  2025-11-21  4:00 ` [PATCH net-next 2/3] netmem, devmem, tcp: " Byungchul Park
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Byungchul Park @ 2025-11-21  4:00 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, linux-mm, kernel_team, harry.yoo, hawk,
	andrew+netdev, david, lorenzo.stoakes, Liam.Howlett, vbabka, ziy,
	willy, toke, davem, edumazet, kuba, pabeni, horms, asml.silence,
	axboe, ncardwell, kuniyu, dsahern, almasrymina, sdf, dw,
	ap420073, dtatulea, shivajikant, io-uring

Convert all the legacy code directly accessing the pp fields in net_iov
to access them through @desc in net_iov.

Signed-off-by: Byungchul Park <byungchul@sk.com>
---
 io_uring/zcrx.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/io_uring/zcrx.c b/io_uring/zcrx.c
index b1b723222cdb..f3ba04ce97ab 100644
--- a/io_uring/zcrx.c
+++ b/io_uring/zcrx.c
@@ -693,12 +693,12 @@ static void io_zcrx_return_niov(struct net_iov *niov)
 {
 	netmem_ref netmem = net_iov_to_netmem(niov);
 
-	if (!niov->pp) {
+	if (!niov->desc.pp) {
 		/* copy fallback allocated niovs */
 		io_zcrx_return_niov_freelist(niov);
 		return;
 	}
-	page_pool_put_unrefed_netmem(niov->pp, netmem, -1, false);
+	page_pool_put_unrefed_netmem(niov->desc.pp, netmem, -1, false);
 }
 
 static void io_zcrx_scrub(struct io_zcrx_ifq *ifq)
@@ -800,7 +800,7 @@ static void io_zcrx_ring_refill(struct page_pool *pp,
 		if (!page_pool_unref_and_test(netmem))
 			continue;
 
-		if (unlikely(niov->pp != pp)) {
+		if (unlikely(niov->desc.pp != pp)) {
 			io_zcrx_return_niov(niov);
 			continue;
 		}
@@ -1074,8 +1074,8 @@ static int io_zcrx_recv_frag(struct io_kiocb *req, struct io_zcrx_ifq *ifq,
 		return io_zcrx_copy_frag(req, ifq, frag, off, len);
 
 	niov = netmem_to_net_iov(frag->netmem);
-	if (!niov->pp || niov->pp->mp_ops != &io_uring_pp_zc_ops ||
-	    io_pp_to_ifq(niov->pp) != ifq)
+	if (!niov->desc.pp || niov->desc.pp->mp_ops != &io_uring_pp_zc_ops ||
+	    io_pp_to_ifq(niov->desc.pp) != ifq)
 		return -EFAULT;
 
 	if (!io_zcrx_queue_cqe(req, niov, ifq, off + skb_frag_off(frag), len))
-- 
2.17.1



^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH net-next 2/3] netmem, devmem, tcp: access pp fields through @desc in net_iov
  2025-11-21  4:00 [PATCH net-next 1/3] netmem, io_uring/zcrx: access pp fields through @desc in net_iov Byungchul Park
@ 2025-11-21  4:00 ` Byungchul Park
  2025-11-25  2:47   ` Jakub Kicinski
  2025-11-21  4:00 ` [PATCH net-next 3/3] netmem: remove the pp fields from net_iov Byungchul Park
  2025-11-21 13:02 ` [PATCH net-next 1/3] netmem, io_uring/zcrx: access pp fields through @desc in net_iov Pavel Begunkov
  2 siblings, 1 reply; 8+ messages in thread
From: Byungchul Park @ 2025-11-21  4:00 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, linux-mm, kernel_team, harry.yoo, hawk,
	andrew+netdev, david, lorenzo.stoakes, Liam.Howlett, vbabka, ziy,
	willy, toke, davem, edumazet, kuba, pabeni, horms, asml.silence,
	axboe, ncardwell, kuniyu, dsahern, almasrymina, sdf, dw,
	ap420073, dtatulea, shivajikant, io-uring

Convert all the legacy code directly accessing the pp fields in net_iov
to access them through @desc in net_iov.

Signed-off-by: Byungchul Park <byungchul@sk.com>
---
 include/linux/skbuff.h | 4 ++--
 net/core/devmem.c      | 6 +++---
 net/ipv4/tcp.c         | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index ff90281ddf90..86737076101d 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -3778,8 +3778,8 @@ static inline dma_addr_t __skb_frag_dma_map(struct device *dev,
 					    enum dma_data_direction dir)
 {
 	if (skb_frag_is_net_iov(frag)) {
-		return netmem_to_net_iov(frag->netmem)->dma_addr + offset +
-		       frag->offset;
+		return netmem_to_net_iov(frag->netmem)->desc.dma_addr +
+		       offset + frag->offset;
 	}
 	return dma_map_page(dev, skb_frag_page(frag),
 			    skb_frag_off(frag) + offset, size, dir);
diff --git a/net/core/devmem.c b/net/core/devmem.c
index 1d04754bc756..ec4217d6c0b4 100644
--- a/net/core/devmem.c
+++ b/net/core/devmem.c
@@ -97,9 +97,9 @@ net_devmem_alloc_dmabuf(struct net_devmem_dmabuf_binding *binding)
 	index = offset / PAGE_SIZE;
 	niov = &owner->area.niovs[index];
 
-	niov->pp_magic = 0;
-	niov->pp = NULL;
-	atomic_long_set(&niov->pp_ref_count, 0);
+	niov->desc.pp_magic = 0;
+	niov->desc.pp = NULL;
+	atomic_long_set(&niov->desc.pp_ref_count, 0);
 
 	return niov;
 }
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index dee578aad690..f035440c475a 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2587,7 +2587,7 @@ static int tcp_recvmsg_dmabuf(struct sock *sk, const struct sk_buff *skb,
 				if (err)
 					goto out;
 
-				atomic_long_inc(&niov->pp_ref_count);
+				atomic_long_inc(&niov->desc.pp_ref_count);
 				tcp_xa_pool.netmems[tcp_xa_pool.idx++] = skb_frag_netmem(frag);
 
 				sent += copy;
-- 
2.17.1



^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH net-next 3/3] netmem: remove the pp fields from net_iov
  2025-11-21  4:00 [PATCH net-next 1/3] netmem, io_uring/zcrx: access pp fields through @desc in net_iov Byungchul Park
  2025-11-21  4:00 ` [PATCH net-next 2/3] netmem, devmem, tcp: " Byungchul Park
@ 2025-11-21  4:00 ` Byungchul Park
  2025-11-21 13:04   ` Pavel Begunkov
  2025-11-21 13:02 ` [PATCH net-next 1/3] netmem, io_uring/zcrx: access pp fields through @desc in net_iov Pavel Begunkov
  2 siblings, 1 reply; 8+ messages in thread
From: Byungchul Park @ 2025-11-21  4:00 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, linux-mm, kernel_team, harry.yoo, hawk,
	andrew+netdev, david, lorenzo.stoakes, Liam.Howlett, vbabka, ziy,
	willy, toke, davem, edumazet, kuba, pabeni, horms, asml.silence,
	axboe, ncardwell, kuniyu, dsahern, almasrymina, sdf, dw,
	ap420073, dtatulea, shivajikant, io-uring

Now that the pp fields in net_iov have no users, remove them from
net_iov and clean up.

Signed-off-by: Byungchul Park <byungchul@sk.com>
---
 include/net/netmem.h | 38 +-------------------------------------
 1 file changed, 1 insertion(+), 37 deletions(-)

diff --git a/include/net/netmem.h b/include/net/netmem.h
index 9e10f4ac50c3..46def457dc65 100644
--- a/include/net/netmem.h
+++ b/include/net/netmem.h
@@ -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;
-- 
2.17.1



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next 1/3] netmem, io_uring/zcrx: access pp fields through @desc in net_iov
  2025-11-21  4:00 [PATCH net-next 1/3] netmem, io_uring/zcrx: access pp fields through @desc in net_iov Byungchul Park
  2025-11-21  4:00 ` [PATCH net-next 2/3] netmem, devmem, tcp: " Byungchul Park
  2025-11-21  4:00 ` [PATCH net-next 3/3] netmem: remove the pp fields from net_iov Byungchul Park
@ 2025-11-21 13:02 ` Pavel Begunkov
  2025-11-22  0:50   ` Byungchul Park
  2 siblings, 1 reply; 8+ messages in thread
From: Pavel Begunkov @ 2025-11-21 13:02 UTC (permalink / raw)
  To: Byungchul Park, netdev
  Cc: linux-kernel, linux-mm, kernel_team, harry.yoo, hawk,
	andrew+netdev, david, lorenzo.stoakes, Liam.Howlett, vbabka, ziy,
	willy, toke, davem, edumazet, kuba, pabeni, horms, axboe,
	ncardwell, kuniyu, dsahern, almasrymina, sdf, dw, ap420073,
	dtatulea, shivajikant, io-uring

On 11/21/25 04:00, Byungchul Park wrote:
> Convert all the legacy code directly accessing the pp fields in net_iov
> to access them through @desc in net_iov.

Byungchul, that was already converted in the appropriate tree.

-- 
Pavel Begunkov



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next 3/3] netmem: remove the pp fields from net_iov
  2025-11-21  4:00 ` [PATCH net-next 3/3] netmem: remove the pp fields from net_iov Byungchul Park
@ 2025-11-21 13:04   ` Pavel Begunkov
  0 siblings, 0 replies; 8+ messages in thread
From: Pavel Begunkov @ 2025-11-21 13:04 UTC (permalink / raw)
  To: Byungchul Park, netdev
  Cc: linux-kernel, linux-mm, kernel_team, harry.yoo, hawk,
	andrew+netdev, david, lorenzo.stoakes, Liam.Howlett, vbabka, ziy,
	willy, toke, davem, edumazet, kuba, pabeni, horms, axboe,
	ncardwell, kuniyu, dsahern, almasrymina, sdf, dw, ap420073,
	dtatulea, shivajikant, io-uring

On 11/21/25 04:00, Byungchul Park wrote:
> Now that the pp fields in net_iov have no users, remove them from
> net_iov and clean up.
> 
> Signed-off-by: Byungchul Park <byungchul@sk.com>
> ---
>   include/net/netmem.h | 38 +-------------------------------------
>   1 file changed, 1 insertion(+), 37 deletions(-)

Nice!

-- 
Pavel Begunkov



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next 1/3] netmem, io_uring/zcrx: access pp fields through @desc in net_iov
  2025-11-21 13:02 ` [PATCH net-next 1/3] netmem, io_uring/zcrx: access pp fields through @desc in net_iov Pavel Begunkov
@ 2025-11-22  0:50   ` Byungchul Park
  0 siblings, 0 replies; 8+ messages in thread
From: Byungchul Park @ 2025-11-22  0:50 UTC (permalink / raw)
  To: Pavel Begunkov
  Cc: netdev, linux-kernel, linux-mm, kernel_team, harry.yoo, hawk,
	andrew+netdev, david, lorenzo.stoakes, Liam.Howlett, vbabka, ziy,
	willy, toke, davem, edumazet, kuba, pabeni, horms, axboe,
	ncardwell, kuniyu, dsahern, almasrymina, sdf, dw, ap420073,
	dtatulea, shivajikant, io-uring

On Fri, Nov 21, 2025 at 01:02:44PM +0000, Pavel Begunkov wrote:
> On 11/21/25 04:00, Byungchul Park wrote:
> > Convert all the legacy code directly accessing the pp fields in net_iov
> > to access them through @desc in net_iov.
> 
> Byungchul, that was already converted in the appropriate tree.

Nice!

	Byungchul
> 
> --
> Pavel Begunkov
> 


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next 2/3] netmem, devmem, tcp: access pp fields through @desc in net_iov
  2025-11-21  4:00 ` [PATCH net-next 2/3] netmem, devmem, tcp: " Byungchul Park
@ 2025-11-25  2:47   ` Jakub Kicinski
  2025-11-26  4:20     ` Byungchul Park
  0 siblings, 1 reply; 8+ messages in thread
From: Jakub Kicinski @ 2025-11-25  2:47 UTC (permalink / raw)
  To: Byungchul Park
  Cc: netdev, linux-kernel, linux-mm, kernel_team, harry.yoo, hawk,
	andrew+netdev, david, lorenzo.stoakes, Liam.Howlett, vbabka, ziy,
	willy, toke, davem, edumazet, pabeni, horms, asml.silence, axboe,
	ncardwell, kuniyu, dsahern, almasrymina, sdf, dw, ap420073,
	dtatulea, shivajikant, io-uring

On Fri, 21 Nov 2025 13:00:46 +0900 Byungchul Park wrote:
> Convert all the legacy code directly accessing the pp fields in net_iov
> to access them through @desc in net_iov.

Please repost just this patch. The last one needs to come after the
merge window, when io-uring and net core changes converge in one tree.
-- 
pw-bot: cr


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next 2/3] netmem, devmem, tcp: access pp fields through @desc in net_iov
  2025-11-25  2:47   ` Jakub Kicinski
@ 2025-11-26  4:20     ` Byungchul Park
  0 siblings, 0 replies; 8+ messages in thread
From: Byungchul Park @ 2025-11-26  4:20 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: netdev, linux-kernel, linux-mm, kernel_team, harry.yoo, hawk,
	andrew+netdev, david, lorenzo.stoakes, Liam.Howlett, vbabka, ziy,
	willy, toke, davem, edumazet, pabeni, horms, asml.silence, axboe,
	ncardwell, kuniyu, dsahern, almasrymina, sdf, dw, ap420073,
	dtatulea, shivajikant, io-uring

On Mon, Nov 24, 2025 at 06:47:29PM -0800, Jakub Kicinski wrote:
> On Fri, 21 Nov 2025 13:00:46 +0900 Byungchul Park wrote:
> > Convert all the legacy code directly accessing the pp fields in net_iov
> > to access them through @desc in net_iov.
> 
> Please repost just this patch. The last one needs to come after the
> merge window, when io-uring and net core changes converge in one tree.

Sure, I will.  Thanks.

	Byungchul
> --
> pw-bot: cr


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-11-26  4:21 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-21  4:00 [PATCH net-next 1/3] netmem, io_uring/zcrx: access pp fields through @desc in net_iov Byungchul Park
2025-11-21  4:00 ` [PATCH net-next 2/3] netmem, devmem, tcp: " Byungchul Park
2025-11-25  2:47   ` Jakub Kicinski
2025-11-26  4:20     ` Byungchul Park
2025-11-21  4:00 ` [PATCH net-next 3/3] netmem: remove the pp fields from net_iov Byungchul Park
2025-11-21 13:04   ` Pavel Begunkov
2025-11-21 13:02 ` [PATCH net-next 1/3] netmem, io_uring/zcrx: access pp fields through @desc in net_iov Pavel Begunkov
2025-11-22  0:50   ` Byungchul Park

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox