[PATCH v3] ext4: move orphan tracking away from journal state

JonasZhou-oc posted 1 patch 2 weeks ago
fs/ext4/ext4.h | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
[PATCH v3] ext4: move orphan tracking away from journal state
Posted by JonasZhou-oc 2 weeks ago
From: Jonas Zhou <jonaszhou@zhaoxin.com>

In the tested x86-64 layout, s_journal and s_ext4_flags share a cache
line with s_orphan_lock and s_orphan. Legacy orphan-list updates
invalidate the same line used by unrelated journal and inode paths.

Move s_orphan_lock, s_orphan and s_orphan_info together below
s_journal_triggers. This separates orphan-list writes from journal
and flag readers while keeping the related fields in logical groups.
Add a comment identifying the orphan tracking group and preserve the
existing member comments.

On a system with two Xeon Silver 4208 processors and a filesystem
without orphan_file enabled, repeated tests against v7.3-rc2 recorded
mean throughput increases of 11.06% for stress-ng dnotify and 35.93%
for unlink.

Tests with orphan_file enabled showed no clear throughput change
within the observed boot-to-boot variation.

perf c2c shows remote HITM samples on the original shared line, but
none on the separate journal line after the change. Local HITM samples
and orphan-lock contention remain.

Suggested-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/all/575wyoks3ldokhrg6v43rxwsegaecod4bgrpbii6jeczy7czbi@a3yq26u52orp/
Signed-off-by: Jonas Zhou <jonaszhou@zhaoxin.com>
---
Changes since v2:
- Follow Jan's suggestion to move the orphan tracking fields together
  below s_journal_triggers, instead of exchanging journal state with
  the error-reporting and lazy-init fields.
- Add an Orphan inode tracking comment.
- Rebase and retest against v7.3-rc2.

v2:
https://lore.kernel.org/all/a33183c1c24ea47a98afdd4756b49365593a2762.1788779199.git.jonaszhou@zhaoxin.com/
v1:
https://lore.kernel.org/all/20260903021836.962624-1-jonaszhou-oc@zhaoxin.com/

 fs/ext4/ext4.h | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 724a27e8be61..166910914973 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -1644,10 +1644,6 @@ 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 list_head s_orphan;	/* List of orphaned inodes in on disk
-					   list */
-	struct ext4_orphan_info s_orphan_info;
 	unsigned long s_commit_interval;
 	u32 s_max_batch_time;
 	u32 s_min_batch_time;
@@ -1786,6 +1782,12 @@ struct ext4_sb_info {
 	/* Journal triggers for checksum computation */
 	struct ext4_journal_trigger s_journal_triggers[EXT4_JOURNAL_TRIGGER_COUNT];
 
+	/* Orphan inode tracking */
+	struct mutex s_orphan_lock;	/* Protects on disk list changes */
+	struct list_head s_orphan;	/* List of orphaned inodes in on disk
+					   list */
+	struct ext4_orphan_info s_orphan_info;
+
 	/* Ratelimit ext4 messages. */
 	struct ratelimit_state s_err_ratelimit_state;
 	struct ratelimit_state s_warning_ratelimit_state;

base-commit: df2908090cda368b01ff43709f51890076c56157
-- 
2.43.0
Re: [PATCH v3] ext4: move orphan tracking away from journal state
Posted by Jan Kara 2 weeks ago
On Fri 11-09-26 11:31:13, JonasZhou-oc wrote:
> From: Jonas Zhou <jonaszhou@zhaoxin.com>
> 
> In the tested x86-64 layout, s_journal and s_ext4_flags share a cache
> line with s_orphan_lock and s_orphan. Legacy orphan-list updates
> invalidate the same line used by unrelated journal and inode paths.
> 
> Move s_orphan_lock, s_orphan and s_orphan_info together below
> s_journal_triggers. This separates orphan-list writes from journal
> and flag readers while keeping the related fields in logical groups.
> Add a comment identifying the orphan tracking group and preserve the
> existing member comments.
> 
> On a system with two Xeon Silver 4208 processors and a filesystem
> without orphan_file enabled, repeated tests against v7.3-rc2 recorded
> mean throughput increases of 11.06% for stress-ng dnotify and 35.93%
> for unlink.
> 
> Tests with orphan_file enabled showed no clear throughput change
> within the observed boot-to-boot variation.
> 
> perf c2c shows remote HITM samples on the original shared line, but
> none on the separate journal line after the change. Local HITM samples
> and orphan-lock contention remain.
> 
> Suggested-by: Jan Kara <jack@suse.cz>
> Link: https://lore.kernel.org/all/575wyoks3ldokhrg6v43rxwsegaecod4bgrpbii6jeczy7czbi@a3yq26u52orp/
> Signed-off-by: Jonas Zhou <jonaszhou@zhaoxin.com>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
> Changes since v2:
> - Follow Jan's suggestion to move the orphan tracking fields together
>   below s_journal_triggers, instead of exchanging journal state with
>   the error-reporting and lazy-init fields.
> - Add an Orphan inode tracking comment.
> - Rebase and retest against v7.3-rc2.
> 
> v2:
> https://lore.kernel.org/all/a33183c1c24ea47a98afdd4756b49365593a2762.1788779199.git.jonaszhou@zhaoxin.com/
> v1:
> https://lore.kernel.org/all/20260903021836.962624-1-jonaszhou-oc@zhaoxin.com/
> 
>  fs/ext4/ext4.h | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
> index 724a27e8be61..166910914973 100644
> --- a/fs/ext4/ext4.h
> +++ b/fs/ext4/ext4.h
> @@ -1644,10 +1644,6 @@ 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 list_head s_orphan;	/* List of orphaned inodes in on disk
> -					   list */
> -	struct ext4_orphan_info s_orphan_info;
>  	unsigned long s_commit_interval;
>  	u32 s_max_batch_time;
>  	u32 s_min_batch_time;
> @@ -1786,6 +1782,12 @@ struct ext4_sb_info {
>  	/* Journal triggers for checksum computation */
>  	struct ext4_journal_trigger s_journal_triggers[EXT4_JOURNAL_TRIGGER_COUNT];
>  
> +	/* Orphan inode tracking */
> +	struct mutex s_orphan_lock;	/* Protects on disk list changes */
> +	struct list_head s_orphan;	/* List of orphaned inodes in on disk
> +					   list */
> +	struct ext4_orphan_info s_orphan_info;
> +
>  	/* Ratelimit ext4 messages. */
>  	struct ratelimit_state s_err_ratelimit_state;
>  	struct ratelimit_state s_warning_ratelimit_state;
> 
> base-commit: df2908090cda368b01ff43709f51890076c56157
> -- 
> 2.43.0
> 
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR