Linux filesystem development
 help / color / mirror / Atom feed
From: Mateusz Guzik <mjguzik@gmail.com>
To: brauner@kernel.org, viro@zeniv.linux.org.uk
Cc: jack@suse.cz, linux-kernel@vger.kernel.org,
	linux-fsdevel@vger.kernel.org, Mateusz Guzik <mjguzik@gmail.com>
Subject: [PATCH v2 3/4] fs: use fput_close() in filp_close()
Date: Tue,  4 Mar 2025 19:35:05 +0100	[thread overview]
Message-ID: <20250304183506.498724-4-mjguzik@gmail.com> (raw)
In-Reply-To: <20250304183506.498724-1-mjguzik@gmail.com>

When tracing a kernel build over refcounts seen this is a wash:
@[kprobe:filp_close]:
[0]                32195 |@@@@@@@@@@                                          |
[1]               164567 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@|

I verified vast majority of the skew comes from do_close_on_exec() which
could be changed to use a different variant instead.

Even without changing that, the 19.5% of calls which got here still can
save the extra atomic. Calls here are borderline non-existent compared
to fput (over 3.2 mln!), so they should not negatively affect
scalability.

Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
---
 fs/open.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/open.c b/fs/open.c
index fc1c6118eb30..ffb7e2e5e1ef 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -1589,7 +1589,7 @@ int filp_close(struct file *filp, fl_owner_t id)
 	int retval;
 
 	retval = filp_flush(filp, id);
-	fput(filp);
+	fput_close(filp);
 
 	return retval;
 }
-- 
2.43.0


  parent reply	other threads:[~2025-03-04 18:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-04 18:35 [RFC PATCH v v2 0/4] avoid the extra atomic on a ref when closing a fd Mateusz Guzik
2025-03-04 18:35 ` [PATCH v2 1/4] file: add fput and file_ref_put routines optimized for use " Mateusz Guzik
2025-03-04 18:48   ` Mateusz Guzik
2025-03-05 10:46   ` Christian Brauner
2025-03-05 12:40     ` Mateusz Guzik
2025-03-04 18:35 ` [PATCH v2 2/4] fs: use fput_close_sync() in close() Mateusz Guzik
2025-03-04 18:35 ` Mateusz Guzik [this message]
2025-03-04 18:35 ` [PATCH v2 4/4] fs: use fput_close() in path_openat() Mateusz Guzik
2025-03-05  2:19 ` [RFC PATCH v v2 0/4] avoid the extra atomic on a ref when closing a fd David Laight
2025-03-05 12:43   ` Mateusz Guzik
2025-03-05 10:38 ` Christian Brauner
2025-03-05 12:42   ` Mateusz Guzik

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=20250304183506.498724-4-mjguzik@gmail.com \
    --to=mjguzik@gmail.com \
    --cc=brauner@kernel.org \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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