mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pranith Kumar <bobby.prani@gmail.com>
To: Christian Brauner <brauner@kernel.org>,
	linux-kernel@vger.kernel.org (open list)
Cc: Mateusz Guzik <mjguzik@gmail.com>,
	viro@zeniv.linux.org.uk, jack@suse.cz,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: [RFC PATCH] file: Use release ordering in file_ref_put()
Date: Sun,  1 Nov 2026 12:07:28 -0800	[thread overview]
Message-ID: <20261101200729.2872806-1-bobby.prani@gmail.com> (raw)

file_ref_put() uses a fully ordered atomic decrement for every put,
although it only requires release ordering for the decrement.
Acquire ordering is needed only when the caller may destroy the file.
On that path, __file_ref_put() already executes
smp_acquire__after_ctrl_dep() after successfully changing the count
to FILE_REF_DEAD.

Use atomic_long_dec_return_release() for the common decrement. On
arm64 LSE this changes the fput() instruction from LDADDAL to LDADDL,
so subsequent independent loads need not wait for an acquire that
the common path does not require.

A pipe workload that performs 20,000 write/read pairs while a sleeping
helper keeps the file table shared runs in 2.92% fewer cycles with
this change.

Signed-off-by: Pranith Kumar <bobby.prani@gmail.com>
---
 include/linux/file_ref.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/file_ref.h b/include/linux/file_ref.h
index 31551e4cb8f3..a5e262d7083c 100644
--- a/include/linux/file_ref.h
+++ b/include/linux/file_ref.h
@@ -154,7 +154,7 @@ static __always_inline __must_check bool file_ref_put(file_ref_t *ref)
 	 * fails then we need to handle the last reference drop and
 	 * cases inside the saturation and dead zones.
 	 */
-	cnt = atomic_long_dec_return(&ref->refcnt);
+	cnt = atomic_long_dec_return_release(&ref->refcnt);
 	if (cnt >= 0)
 		return false;
 	return __file_ref_put(ref, cnt);
-- 
2.47.3


                 reply	other threads:[~2026-11-01 20:07 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261101200729.2872806-1-bobby.prani@gmail.com \
    --to=bobby.prani@gmail.com \
    --cc=brauner@kernel.org \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mjguzik@gmail.com \
    --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

all inboxes | Powered by JetHome®