[PATCH 06/11] super: Use acquire for SB_BORN check in super_cache_count()
From: Jinjie Ruan
Date: Tue Aug 25 2026 - 05:58:31 EST
The active SB_BORN check in super_cache_count() pairs with the
smp_store_release() in super_wake() when publishing a newly initialized
superblock.
Replace the historical independent smp_rmb() barrier with an acquire load
on sb->s_flags. This expresses the publish-subscribe pattern more clearly
and allows weakly-ordered architectures like arm64 to utilize efficient
native instructions (e.g., LDAR) instead of a full one-way barrier.
Also update the outdated comment to correctly point to super_wake().
Assisted-by: Gemini:Gemini-3.1
Assisted-by: DeepSeek:DeepSeek-V3
Signed-off-by: Jinjie Ruan <ruanjinjie@xxxxxxxxxx>
---
fs/super.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/fs/super.c b/fs/super.c
index 05e443173038..5860daea6d40 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -267,12 +267,11 @@ static unsigned long super_cache_count(struct shrinker *shrink,
* However, if we are currently mounting the superblock, the underlying
* filesystem might be in a state of partial construction and hence it
* is dangerous to access it. super_trylock_shared() uses a SB_BORN check
- * to avoid this situation, so do the same here. The memory barrier is
- * matched with the one in mount_fs() as we don't hold locks here.
+ * to avoid this situation, so do the same here. The acquire is matched
+ * with the smp_store_release() in super_wake() as we don't hold locks here.
*/
- if (!(sb->s_flags & SB_BORN))
+ if (!(smp_load_acquire(&sb->s_flags) & SB_BORN))
return 0;
- smp_rmb();
if (sb->s_op && sb->s_op->nr_cached_objects &&
super_fs_objects_eligible(sc))
--
2.34.1