public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: [email protected]
Cc: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH 8/8] io_uring/rsrc: extract SCM file put helper
Date: Tue, 11 Apr 2023 12:06:08 +0100	[thread overview]
Message-ID: <58cc7bffc2ee96bec8c2b89274a51febcbfa5556.1681210788.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>

SCM file accounting is a slow path and is only used for UNIX files.
Extract a helper out of io_rsrc_file_put() that does the SCM
unaccounting.

Signed-off-by: Pavel Begunkov <[email protected]>
---
 io_uring/rsrc.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c
index f2c660ffea74..11058e20bdcc 100644
--- a/io_uring/rsrc.c
+++ b/io_uring/rsrc.c
@@ -832,20 +832,14 @@ int __io_scm_file_account(struct io_ring_ctx *ctx, struct file *file)
 	return 0;
 }
 
-static void io_rsrc_file_put(struct io_ring_ctx *ctx, struct io_rsrc_put *prsrc)
+static __cold void io_rsrc_file_scm_put(struct io_ring_ctx *ctx, struct file *file)
 {
-	struct file *file = prsrc->file;
 #if defined(CONFIG_UNIX)
 	struct sock *sock = ctx->ring_sock->sk;
 	struct sk_buff_head list, *head = &sock->sk_receive_queue;
 	struct sk_buff *skb;
 	int i;
 
-	if (!io_file_need_scm(file)) {
-		fput(file);
-		return;
-	}
-
 	__skb_queue_head_init(&list);
 
 	/*
@@ -895,11 +889,19 @@ static void io_rsrc_file_put(struct io_ring_ctx *ctx, struct io_rsrc_put *prsrc)
 			__skb_queue_tail(head, skb);
 		spin_unlock_irq(&head->lock);
 	}
-#else
-	fput(file);
 #endif
 }
 
+static void io_rsrc_file_put(struct io_ring_ctx *ctx, struct io_rsrc_put *prsrc)
+{
+	struct file *file = prsrc->file;
+
+	if (likely(!io_file_need_scm(file)))
+		fput(file);
+	else
+		io_rsrc_file_scm_put(ctx, file);
+}
+
 int io_sqe_files_register(struct io_ring_ctx *ctx, void __user *arg,
 			  unsigned nr_args, u64 __user *tags)
 {
-- 
2.40.0


  parent reply	other threads:[~2023-04-11 11:13 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-11 11:06 [PATCH 0/8] for-next cleanups Pavel Begunkov
2023-04-11 11:06 ` [PATCH 1/8] io_uring: shut io_prep_async_work warning Pavel Begunkov
2023-04-11 11:06 ` [PATCH 2/8] io_uring/kbuf: remove extra ->buf_ring null check Pavel Begunkov
2023-04-11 11:06 ` [PATCH 3/8] io_uring: add irq lockdep checks Pavel Begunkov
2023-04-11 11:06 ` [PATCH 4/8] io_uring/rsrc: add " Pavel Begunkov
2023-04-11 11:06 ` [PATCH 5/8] io_uring/rsrc: consolidate node caching Pavel Begunkov
2023-04-11 11:06 ` [PATCH 6/8] io_uring/rsrc: zero node's rsrc data on alloc Pavel Begunkov
2023-04-11 11:06 ` [PATCH 7/8] io_uring/rsrc: refactor io_rsrc_node_switch Pavel Begunkov
2023-04-11 11:06 ` Pavel Begunkov [this message]
2023-04-12 18:10 ` [PATCH 0/8] for-next cleanups Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=58cc7bffc2ee96bec8c2b89274a51febcbfa5556.1681210788.git.asml.silence@gmail.com \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox