netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: reclaim skb->scm_io_uring bit
@ 2023-03-07 14:59 Eric Dumazet
  2023-03-07 15:24 ` Jens Axboe
  2023-03-07 15:29 ` Pavel Begunkov
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Dumazet @ 2023-03-07 14:59 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski, Paolo Abeni
  Cc: netdev, eric.dumazet, Eric Dumazet, Pavel Begunkov,
	Thadeu Lima de Souza Cascardo, Jens Axboe

Commit 0091bfc81741 ("io_uring/af_unix: defer registered
files gc to io_uring release") added one bit to struct sk_buff.

This structure is critical for networking, and we try very hard
to not add bloat on it, unless absolutely required.

For instance, we can use a specific destructor as a wrapper
around unix_destruct_scm(), to identify skbs that unix_gc()
has to special case.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Pavel Begunkov <asml.silence@gmail.com>
Cc: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Cc: Jens Axboe <axboe@kernel.dk>
---
 include/linux/skbuff.h | 2 --
 include/net/af_unix.h  | 1 +
 io_uring/rsrc.c        | 3 +--
 net/unix/garbage.c     | 2 +-
 net/unix/scm.c         | 6 ++++++
 5 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index ff7ad331fb8259fd06c07913dfa197d7ac448390..fe661011644b8f468ff5e92075a6624f0557584c 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -810,7 +810,6 @@ typedef unsigned char *sk_buff_data_t;
  *	@csum_level: indicates the number of consecutive checksums found in
  *		the packet minus one that have been verified as
  *		CHECKSUM_UNNECESSARY (max 3)
- *	@scm_io_uring: SKB holds io_uring registered files
  *	@dst_pending_confirm: need to confirm neighbour
  *	@decrypted: Decrypted SKB
  *	@slow_gro: state present at GRO time, slower prepare step required
@@ -989,7 +988,6 @@ struct sk_buff {
 #endif
 	__u8			slow_gro:1;
 	__u8			csum_not_inet:1;
-	__u8			scm_io_uring:1;
 
 #ifdef CONFIG_NET_SCHED
 	__u16			tc_index;	/* traffic control index */
diff --git a/include/net/af_unix.h b/include/net/af_unix.h
index 480fa579787e597f264ae26a32e519c235ce1d39..45ebde587138e59f8331d358420d3fca79d9ee66 100644
--- a/include/net/af_unix.h
+++ b/include/net/af_unix.h
@@ -11,6 +11,7 @@
 void unix_inflight(struct user_struct *user, struct file *fp);
 void unix_notinflight(struct user_struct *user, struct file *fp);
 void unix_destruct_scm(struct sk_buff *skb);
+void io_uring_destruct_scm(struct sk_buff *skb);
 void unix_gc(void);
 void wait_for_unix_gc(void);
 struct sock *unix_get_socket(struct file *filp);
diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c
index a59fc02de5983c4f789e9cdfea3a1376f578ebe6..27ceda3b50cf4e677cde5e2417a80adad66e162f 100644
--- a/io_uring/rsrc.c
+++ b/io_uring/rsrc.c
@@ -867,8 +867,7 @@ int __io_scm_file_account(struct io_ring_ctx *ctx, struct file *file)
 
 		UNIXCB(skb).fp = fpl;
 		skb->sk = sk;
-		skb->scm_io_uring = 1;
-		skb->destructor = unix_destruct_scm;
+		skb->destructor = io_uring_destruct_scm;
 		refcount_add(skb->truesize, &sk->sk_wmem_alloc);
 	}
 
diff --git a/net/unix/garbage.c b/net/unix/garbage.c
index dc27635403932154f3dec069c2e10d2ae365d8cb..2405f0f9af31c0ccefe2aa404002cfab8583c090 100644
--- a/net/unix/garbage.c
+++ b/net/unix/garbage.c
@@ -305,7 +305,7 @@ void unix_gc(void)
 	 * release.path eventually putting registered files.
 	 */
 	skb_queue_walk_safe(&hitlist, skb, next_skb) {
-		if (skb->scm_io_uring) {
+		if (skb->destructor == io_uring_destruct_scm) {
 			__skb_unlink(skb, &hitlist);
 			skb_queue_tail(&skb->sk->sk_receive_queue, skb);
 		}
diff --git a/net/unix/scm.c b/net/unix/scm.c
index aa27a02478dc1a7e4022f77e6ea7ac55f40b95c7..f9152881d77f636f9500d1b57fdda584df845fc2 100644
--- a/net/unix/scm.c
+++ b/net/unix/scm.c
@@ -152,3 +152,9 @@ void unix_destruct_scm(struct sk_buff *skb)
 	sock_wfree(skb);
 }
 EXPORT_SYMBOL(unix_destruct_scm);
+
+void io_uring_destruct_scm(struct sk_buff *skb)
+{
+	unix_destruct_scm(skb);
+}
+EXPORT_SYMBOL(io_uring_destruct_scm);
-- 
2.40.0.rc0.216.gc4246ad0f0-goog


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

* Re: [PATCH net-next] net: reclaim skb->scm_io_uring bit
  2023-03-07 14:59 [PATCH net-next] net: reclaim skb->scm_io_uring bit Eric Dumazet
@ 2023-03-07 15:24 ` Jens Axboe
  2023-03-07 15:29 ` Pavel Begunkov
  1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2023-03-07 15:24 UTC (permalink / raw)
  To: Eric Dumazet, David S . Miller, Jakub Kicinski, Paolo Abeni
  Cc: netdev, eric.dumazet, Pavel Begunkov,
	Thadeu Lima de Souza Cascardo

On 3/7/23 7:59 AM, Eric Dumazet wrote:
> Commit 0091bfc81741 ("io_uring/af_unix: defer registered
> files gc to io_uring release") added one bit to struct sk_buff.
> 
> This structure is critical for networking, and we try very hard
> to not add bloat on it, unless absolutely required.

Understandable.

> For instance, we can use a specific destructor as a wrapper
> around unix_destruct_scm(), to identify skbs that unix_gc()
> has to special case.

Looks fine to me:

Reviewed-by: Jens Axboe <axboe@kernel.dk>

-- 
Jens Axboe



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

* Re: [PATCH net-next] net: reclaim skb->scm_io_uring bit
  2023-03-07 14:59 [PATCH net-next] net: reclaim skb->scm_io_uring bit Eric Dumazet
  2023-03-07 15:24 ` Jens Axboe
@ 2023-03-07 15:29 ` Pavel Begunkov
  1 sibling, 0 replies; 3+ messages in thread
From: Pavel Begunkov @ 2023-03-07 15:29 UTC (permalink / raw)
  To: Eric Dumazet, David S . Miller, Jakub Kicinski, Paolo Abeni
  Cc: netdev, eric.dumazet, Thadeu Lima de Souza Cascardo, Jens Axboe

On 3/7/23 14:59, Eric Dumazet wrote:
> Commit 0091bfc81741 ("io_uring/af_unix: defer registered
> files gc to io_uring release") added one bit to struct sk_buff.
> 
> This structure is critical for networking, and we try very hard
> to not add bloat on it, unless absolutely required.
> 
> For instance, we can use a specific destructor as a wrapper
> around unix_destruct_scm(), to identify skbs that unix_gc()
> has to special case.

We also should be able to use struct unix_sock :: gc_flags for
that, not sure why I didn't do it in the first place.

In any case, looks good, thanks

Reviewed-by: Pavel Begunkov <asml.silence@gmail.com>

> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Pavel Begunkov <asml.silence@gmail.com>
> Cc: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
> Cc: Jens Axboe <axboe@kernel.dk>
> ---
>   include/linux/skbuff.h | 2 --
>   include/net/af_unix.h  | 1 +
>   io_uring/rsrc.c        | 3 +--
>   net/unix/garbage.c     | 2 +-
>   net/unix/scm.c         | 6 ++++++
>   5 files changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
> index ff7ad331fb8259fd06c07913dfa197d7ac448390..fe661011644b8f468ff5e92075a6624f0557584c 100644
> --- a/include/linux/skbuff.h
> +++ b/include/linux/skbuff.h
> @@ -810,7 +810,6 @@ typedef unsigned char *sk_buff_data_t;
>    *	@csum_level: indicates the number of consecutive checksums found in
>    *		the packet minus one that have been verified as
>    *		CHECKSUM_UNNECESSARY (max 3)
> - *	@scm_io_uring: SKB holds io_uring registered files
>    *	@dst_pending_confirm: need to confirm neighbour
>    *	@decrypted: Decrypted SKB
>    *	@slow_gro: state present at GRO time, slower prepare step required
> @@ -989,7 +988,6 @@ struct sk_buff {
>   #endif
>   	__u8			slow_gro:1;
>   	__u8			csum_not_inet:1;
> -	__u8			scm_io_uring:1;
>   
>   #ifdef CONFIG_NET_SCHED
>   	__u16			tc_index;	/* traffic control index */
> diff --git a/include/net/af_unix.h b/include/net/af_unix.h
> index 480fa579787e597f264ae26a32e519c235ce1d39..45ebde587138e59f8331d358420d3fca79d9ee66 100644
> --- a/include/net/af_unix.h
> +++ b/include/net/af_unix.h
> @@ -11,6 +11,7 @@
>   void unix_inflight(struct user_struct *user, struct file *fp);
>   void unix_notinflight(struct user_struct *user, struct file *fp);
>   void unix_destruct_scm(struct sk_buff *skb);
> +void io_uring_destruct_scm(struct sk_buff *skb);
>   void unix_gc(void);
>   void wait_for_unix_gc(void);
>   struct sock *unix_get_socket(struct file *filp);
> diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c
> index a59fc02de5983c4f789e9cdfea3a1376f578ebe6..27ceda3b50cf4e677cde5e2417a80adad66e162f 100644
> --- a/io_uring/rsrc.c
> +++ b/io_uring/rsrc.c
> @@ -867,8 +867,7 @@ int __io_scm_file_account(struct io_ring_ctx *ctx, struct file *file)
>   
>   		UNIXCB(skb).fp = fpl;
>   		skb->sk = sk;
> -		skb->scm_io_uring = 1;
> -		skb->destructor = unix_destruct_scm;
> +		skb->destructor = io_uring_destruct_scm;
>   		refcount_add(skb->truesize, &sk->sk_wmem_alloc);
>   	}
>   
> diff --git a/net/unix/garbage.c b/net/unix/garbage.c
> index dc27635403932154f3dec069c2e10d2ae365d8cb..2405f0f9af31c0ccefe2aa404002cfab8583c090 100644
> --- a/net/unix/garbage.c
> +++ b/net/unix/garbage.c
> @@ -305,7 +305,7 @@ void unix_gc(void)
>   	 * release.path eventually putting registered files.
>   	 */
>   	skb_queue_walk_safe(&hitlist, skb, next_skb) {
> -		if (skb->scm_io_uring) {
> +		if (skb->destructor == io_uring_destruct_scm) {
>   			__skb_unlink(skb, &hitlist);
>   			skb_queue_tail(&skb->sk->sk_receive_queue, skb);
>   		}
> diff --git a/net/unix/scm.c b/net/unix/scm.c
> index aa27a02478dc1a7e4022f77e6ea7ac55f40b95c7..f9152881d77f636f9500d1b57fdda584df845fc2 100644
> --- a/net/unix/scm.c
> +++ b/net/unix/scm.c
> @@ -152,3 +152,9 @@ void unix_destruct_scm(struct sk_buff *skb)
>   	sock_wfree(skb);
>   }
>   EXPORT_SYMBOL(unix_destruct_scm);
> +
> +void io_uring_destruct_scm(struct sk_buff *skb)
> +{
> +	unix_destruct_scm(skb);
> +}
> +EXPORT_SYMBOL(io_uring_destruct_scm);

-- 
Pavel Begunkov

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

end of thread, other threads:[~2023-03-07 15:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-07 14:59 [PATCH net-next] net: reclaim skb->scm_io_uring bit Eric Dumazet
2023-03-07 15:24 ` Jens Axboe
2023-03-07 15:29 ` Pavel Begunkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).