net: reclaim skb->scm_io_uring bit
Subsystems (4)
PATCH 1/1 net: reclaim skb->scm_io_uring bit
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.
--- 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(-)
include/linux/skbuff.h +0 -2
@@ -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 */
include/net/af_unix.h +1 -0
@@ -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);
io_uring/rsrc.c +1 -2
@@ -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); }
net/unix/garbage.c +1 -1
@@ -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); }
net/unix/scm.c +6 -0
@@ -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);
Signature · 1 line
2.40.0.rc0.216.gc4246ad0f0-goog
Quoted 5 lines · Eric Dumazet
Commit
0091bfc81741("io_uring/af_unix: defer registered files gc toio_uringrelease") added one bit to structsk_buff.This structure is critical for networking, and we try very hard to not add bloat on it, unless absolutely required.
Understandable.
Quoted 3 lines
For instance, we can use a specific destructor as a wrapper around
unix_destruct_scm(), to identify skbs thatunix_gc()has to special case.
Looks fine to me:
Signature · 1 line
Jens Axboe
Quoted 9 lines · Eric Dumazet
Commit
0091bfc81741("io_uring/af_unix: defer registered files gc toio_uringrelease") added one bit to structsk_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 thatunix_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
Quoted 85 lines
Signed-off-by Eric Dumazet <[email protected]>Cc Pavel Begunkov <[email protected]>Cc Thadeu Lima de Souza Cascardo <[email protected]>Cc Jens Axboe <[email protected]>--- 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(-)include/linux/skbuff.h +0
-2@@ -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 */ include/net/af_unix.h +1
-0@@ -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);io_uring/rsrc.c +1
-2@@ -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); }net/unix/garbage.c +1
-1@@ -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); }net/unix/scm.c +6
-0@@ -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);
Signature · 1 line
Pavel Begunkov