[PATCH] ext4: isolate s_orphan_lock from read-mostly fields

From: JonasZhou-oc

Date: Wed Sep 02 2026 - 22:19:24 EST


From: Jonas Zhou <jonaszhou@xxxxxxxxxxx>

s_orphan_lock is modified by orphan-list operations, but currently shares
a cache line with s_journal and s_ext4_flags. The latter fields are read
from common ext4 paths, so unrelated accesses can cause the line containing
the lock to bounce between CPUs.

On a two-socket Intel Xeon Silver 4208 system with 16 workers, throughput
improved by 4.6% for stress-ng.dnotify and 1.7% for stress-ng.unlink. Perf
c2c showed that HITM events on the affected fields decreased from 3,699 to
3,125 (-15.5%) for stress-ng.dnotify and from 1,368 to 571 (-58.3%) for
stress-ng.unlink. Remote HITM events decreased by 45.1% and 65.5%,
respectively. The journal/flags line had no remote HITM events after the
change; the remaining remote HITM events were on the orphan-lock line.

Signed-off-by: Jonas Zhou <jonaszhou@xxxxxxxxxxx>
---
fs/ext4/ext4.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 724a27e8be61..a3f16a981664 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -1644,7 +1644,7 @@ struct ext4_sb_info {
/* Journaling */
struct journal_s *s_journal;
unsigned long s_ext4_flags; /* Ext4 superblock flags */
- struct mutex s_orphan_lock; /* Protects on disk list changes */
+ struct mutex s_orphan_lock ____cacheline_aligned_in_smp;
struct list_head s_orphan; /* List of orphaned inodes in on disk
list */
struct ext4_orphan_info s_orphan_info;
--
2.25.1