diff mbox series

[1/8] shmem: shrink shmem_inode_info: dir_offsets in a union

Message ID 86ebb4b-c571-b9e8-27f5-cb82ec50357e@google.com (mailing list archive)
State New
Headers show
Series shmem,tmpfs: general maintenance | expand

Commit Message

Hugh Dickins Sept. 30, 2023, 3:25 a.m. UTC
Shave 32 bytes off (the 64-bit) shmem_inode_info.  There was a 4-byte
pahole after stop_eviction, better filled by fsflags.  And the 24-byte
dir_offsets can only be used by directories, whereas shrinklist and
swaplist only by shmem_mapping() inodes (regular files or long symlinks):
so put those into a union.  No change in mm/shmem.c is required for this.

Signed-off-by: Hugh Dickins <hughd@google.com>
---
 include/linux/shmem_fs.h | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

Comments

Chuck Lever Sept. 30, 2023, 4:16 p.m. UTC | #1
On Fri, Sep 29, 2023 at 08:25:38PM -0700, Hugh Dickins wrote:
> Shave 32 bytes off (the 64-bit) shmem_inode_info.  There was a 4-byte
> pahole after stop_eviction, better filled by fsflags.  And the 24-byte
> dir_offsets can only be used by directories, whereas shrinklist and
> swaplist only by shmem_mapping() inodes (regular files or long symlinks):
> so put those into a union.  No change in mm/shmem.c is required for this.
> 
> Signed-off-by: Hugh Dickins <hughd@google.com>

Reviewed-by: Chuck Lever <chuck.lever@oracle.com>


> ---
>  include/linux/shmem_fs.h | 16 ++++++++++------
>  1 file changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h
> index 6b0c626620f5..2caa6b86106a 100644
> --- a/include/linux/shmem_fs.h
> +++ b/include/linux/shmem_fs.h
> @@ -23,18 +23,22 @@ struct shmem_inode_info {
>  	unsigned long		flags;
>  	unsigned long		alloced;	/* data pages alloced to file */
>  	unsigned long		swapped;	/* subtotal assigned to swap */
> -	pgoff_t			fallocend;	/* highest fallocate endindex */
> -	struct list_head        shrinklist;     /* shrinkable hpage inodes */
> -	struct list_head	swaplist;	/* chain of maybes on swap */
> +	union {
> +	    struct offset_ctx	dir_offsets;	/* stable directory offsets */
> +	    struct {
> +		struct list_head shrinklist;	/* shrinkable hpage inodes */
> +		struct list_head swaplist;	/* chain of maybes on swap */
> +	    };
> +	};
> +	struct timespec64	i_crtime;	/* file creation time */
>  	struct shared_policy	policy;		/* NUMA memory alloc policy */
>  	struct simple_xattrs	xattrs;		/* list of xattrs */
> +	pgoff_t			fallocend;	/* highest fallocate endindex */
> +	unsigned int		fsflags;	/* for FS_IOC_[SG]ETFLAGS */
>  	atomic_t		stop_eviction;	/* hold when working on inode */
> -	struct timespec64	i_crtime;	/* file creation time */
> -	unsigned int		fsflags;	/* flags for FS_IOC_[SG]ETFLAGS */
>  #ifdef CONFIG_TMPFS_QUOTA
>  	struct dquot		*i_dquot[MAXQUOTAS];
>  #endif
> -	struct offset_ctx	dir_offsets;	/* stable entry offsets */
>  	struct inode		vfs_inode;
>  };
>  
> -- 
> 2.35.3
>
Jan Kara Oct. 3, 2023, 1:06 p.m. UTC | #2
On Fri 29-09-23 20:25:38, Hugh Dickins wrote:
> Shave 32 bytes off (the 64-bit) shmem_inode_info.  There was a 4-byte
> pahole after stop_eviction, better filled by fsflags.  And the 24-byte
> dir_offsets can only be used by directories, whereas shrinklist and
> swaplist only by shmem_mapping() inodes (regular files or long symlinks):
> so put those into a union.  No change in mm/shmem.c is required for this.
> 
> Signed-off-by: Hugh Dickins <hughd@google.com>

Looks good to me. Feel free to add:

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

								Honza


> ---
>  include/linux/shmem_fs.h | 16 ++++++++++------
>  1 file changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h
> index 6b0c626620f5..2caa6b86106a 100644
> --- a/include/linux/shmem_fs.h
> +++ b/include/linux/shmem_fs.h
> @@ -23,18 +23,22 @@ struct shmem_inode_info {
>  	unsigned long		flags;
>  	unsigned long		alloced;	/* data pages alloced to file */
>  	unsigned long		swapped;	/* subtotal assigned to swap */
> -	pgoff_t			fallocend;	/* highest fallocate endindex */
> -	struct list_head        shrinklist;     /* shrinkable hpage inodes */
> -	struct list_head	swaplist;	/* chain of maybes on swap */
> +	union {
> +	    struct offset_ctx	dir_offsets;	/* stable directory offsets */
> +	    struct {
> +		struct list_head shrinklist;	/* shrinkable hpage inodes */
> +		struct list_head swaplist;	/* chain of maybes on swap */
> +	    };
> +	};
> +	struct timespec64	i_crtime;	/* file creation time */
>  	struct shared_policy	policy;		/* NUMA memory alloc policy */
>  	struct simple_xattrs	xattrs;		/* list of xattrs */
> +	pgoff_t			fallocend;	/* highest fallocate endindex */
> +	unsigned int		fsflags;	/* for FS_IOC_[SG]ETFLAGS */
>  	atomic_t		stop_eviction;	/* hold when working on inode */
> -	struct timespec64	i_crtime;	/* file creation time */
> -	unsigned int		fsflags;	/* flags for FS_IOC_[SG]ETFLAGS */
>  #ifdef CONFIG_TMPFS_QUOTA
>  	struct dquot		*i_dquot[MAXQUOTAS];
>  #endif
> -	struct offset_ctx	dir_offsets;	/* stable entry offsets */
>  	struct inode		vfs_inode;
>  };
>  
> -- 
> 2.35.3
>
diff mbox series

Patch

diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h
index 6b0c626620f5..2caa6b86106a 100644
--- a/include/linux/shmem_fs.h
+++ b/include/linux/shmem_fs.h
@@ -23,18 +23,22 @@  struct shmem_inode_info {
 	unsigned long		flags;
 	unsigned long		alloced;	/* data pages alloced to file */
 	unsigned long		swapped;	/* subtotal assigned to swap */
-	pgoff_t			fallocend;	/* highest fallocate endindex */
-	struct list_head        shrinklist;     /* shrinkable hpage inodes */
-	struct list_head	swaplist;	/* chain of maybes on swap */
+	union {
+	    struct offset_ctx	dir_offsets;	/* stable directory offsets */
+	    struct {
+		struct list_head shrinklist;	/* shrinkable hpage inodes */
+		struct list_head swaplist;	/* chain of maybes on swap */
+	    };
+	};
+	struct timespec64	i_crtime;	/* file creation time */
 	struct shared_policy	policy;		/* NUMA memory alloc policy */
 	struct simple_xattrs	xattrs;		/* list of xattrs */
+	pgoff_t			fallocend;	/* highest fallocate endindex */
+	unsigned int		fsflags;	/* for FS_IOC_[SG]ETFLAGS */
 	atomic_t		stop_eviction;	/* hold when working on inode */
-	struct timespec64	i_crtime;	/* file creation time */
-	unsigned int		fsflags;	/* flags for FS_IOC_[SG]ETFLAGS */
 #ifdef CONFIG_TMPFS_QUOTA
 	struct dquot		*i_dquot[MAXQUOTAS];
 #endif
-	struct offset_ctx	dir_offsets;	/* stable entry offsets */
 	struct inode		vfs_inode;
 };