[RFC PATCH] file: Use release ordering in file_ref_put()

From: Pranith Kumar

Date: Sun Nov 01 2026 - 15:07:40 EST


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@xxxxxxxxx>
---
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