* [PATCH 1/2] xfs: reorder xfs_inode structure elements to remove unneeded padding. @ 2024-06-18 11:35 Junchao Sun 2024-06-18 11:35 ` [PATCH 2/2] vfs: reorder struct file " Junchao Sun 2024-06-18 16:23 ` [PATCH 1/2] xfs: reorder xfs_inode " Darrick J. Wong 0 siblings, 2 replies; 7+ messages in thread From: Junchao Sun @ 2024-06-18 11:35 UTC (permalink / raw) To: linux-fsdevel, linux-xfs Cc: viro, brauner, jack, chandan.babu, djwong, Junchao Sun By reordering the elements in the xfs_inode structure, we can reduce the padding needed on an x86_64 system by 8 bytes. Signed-off-by: Junchao Sun <sunjunchao2870@gmail.com> --- fs/xfs/xfs_inode.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index 292b90b5f2ac..3239ae4e33d2 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -40,8 +40,8 @@ typedef struct xfs_inode { /* Transaction and locking information. */ struct xfs_inode_log_item *i_itemp; /* logging information */ struct rw_semaphore i_lock; /* inode lock */ - atomic_t i_pincount; /* inode pin count */ struct llist_node i_gclist; /* deferred inactivation list */ + atomic_t i_pincount; /* inode pin count */ /* * Bitsets of inode metadata that have been checked and/or are sick. -- 2.39.2 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/2] vfs: reorder struct file structure elements to remove unneeded padding. 2024-06-18 11:35 [PATCH 1/2] xfs: reorder xfs_inode structure elements to remove unneeded padding Junchao Sun @ 2024-06-18 11:35 ` Junchao Sun 2024-06-18 14:52 ` Christian Brauner 2024-06-18 16:23 ` [PATCH 1/2] xfs: reorder xfs_inode " Darrick J. Wong 1 sibling, 1 reply; 7+ messages in thread From: Junchao Sun @ 2024-06-18 11:35 UTC (permalink / raw) To: linux-fsdevel, linux-xfs Cc: viro, brauner, jack, chandan.babu, djwong, Junchao Sun By reordering the elements in the struct file structure, we can reduce the padding needed on an x86_64 system by 8 bytes. Signed-off-by: Junchao Sun <sunjunchao2870@gmail.com> --- include/linux/fs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/fs.h b/include/linux/fs.h index 0283cf366c2a..9235b7a960d3 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -999,10 +999,10 @@ struct file { */ spinlock_t f_lock; fmode_t f_mode; + unsigned int f_flags; atomic_long_t f_count; struct mutex f_pos_lock; loff_t f_pos; - unsigned int f_flags; struct fown_struct f_owner; const struct cred *f_cred; struct file_ra_state f_ra; -- 2.39.2 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] vfs: reorder struct file structure elements to remove unneeded padding. 2024-06-18 11:35 ` [PATCH 2/2] vfs: reorder struct file " Junchao Sun @ 2024-06-18 14:52 ` Christian Brauner 0 siblings, 0 replies; 7+ messages in thread From: Christian Brauner @ 2024-06-18 14:52 UTC (permalink / raw) To: Junchao Sun; +Cc: linux-fsdevel, linux-xfs, viro, jack, chandan.babu, djwong On Tue, Jun 18, 2024 at 07:35:05PM GMT, Junchao Sun wrote: > By reordering the elements in the struct file structure, we can > reduce the padding needed on an x86_64 system by 8 bytes. > > Signed-off-by: Junchao Sun <sunjunchao2870@gmail.com> > --- > include/linux/fs.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/linux/fs.h b/include/linux/fs.h > index 0283cf366c2a..9235b7a960d3 100644 > --- a/include/linux/fs.h > +++ b/include/linux/fs.h > @@ -999,10 +999,10 @@ struct file { > */ > spinlock_t f_lock; > fmode_t f_mode; > + unsigned int f_flags; Iiuc, then this will push f_pos_lock into a new cache line whereas it's explicitly optimized so that f_lock, f_mode, and f_pos_lock are all in the same cache line. You could play around with moving the union to the end of struct file. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] xfs: reorder xfs_inode structure elements to remove unneeded padding. 2024-06-18 11:35 [PATCH 1/2] xfs: reorder xfs_inode structure elements to remove unneeded padding Junchao Sun 2024-06-18 11:35 ` [PATCH 2/2] vfs: reorder struct file " Junchao Sun @ 2024-06-18 16:23 ` Darrick J. Wong 2024-06-18 16:40 ` JunChao Sun 1 sibling, 1 reply; 7+ messages in thread From: Darrick J. Wong @ 2024-06-18 16:23 UTC (permalink / raw) To: Junchao Sun; +Cc: linux-fsdevel, linux-xfs, viro, brauner, jack, chandan.babu On Tue, Jun 18, 2024 at 07:35:04PM +0800, Junchao Sun wrote: > By reordering the elements in the xfs_inode structure, we can > reduce the padding needed on an x86_64 system by 8 bytes. Does this result in denser packing of xfs_inode objects in the slab page? --D > Signed-off-by: Junchao Sun <sunjunchao2870@gmail.com> > --- > fs/xfs/xfs_inode.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h > index 292b90b5f2ac..3239ae4e33d2 100644 > --- a/fs/xfs/xfs_inode.h > +++ b/fs/xfs/xfs_inode.h > @@ -40,8 +40,8 @@ typedef struct xfs_inode { > /* Transaction and locking information. */ > struct xfs_inode_log_item *i_itemp; /* logging information */ > struct rw_semaphore i_lock; /* inode lock */ > - atomic_t i_pincount; /* inode pin count */ > struct llist_node i_gclist; /* deferred inactivation list */ > + atomic_t i_pincount; /* inode pin count */ > > /* > * Bitsets of inode metadata that have been checked and/or are sick. > -- > 2.39.2 > > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] xfs: reorder xfs_inode structure elements to remove unneeded padding. 2024-06-18 16:23 ` [PATCH 1/2] xfs: reorder xfs_inode " Darrick J. Wong @ 2024-06-18 16:40 ` JunChao Sun 2024-06-18 16:51 ` Matthew Wilcox 0 siblings, 1 reply; 7+ messages in thread From: JunChao Sun @ 2024-06-18 16:40 UTC (permalink / raw) To: Darrick J. Wong Cc: linux-fsdevel, linux-xfs, viro, brauner, jack, chandan.babu Darrick J. Wong <djwong@kernel.org> 于2024年6月18日周二 12:23写道: > > On Tue, Jun 18, 2024 at 07:35:04PM +0800, Junchao Sun wrote: > > By reordering the elements in the xfs_inode structure, we can > > reduce the padding needed on an x86_64 system by 8 bytes. > > > > Does this result in denser packing of xfs_inode objects in the slab > > page? No. Before applying the patch, the size of xfs_inode is 1800 bytes with my config, and after applying the patch, the size is 1792 bytes. This slight reduction does not result in a denser packing of xfs_inode objects within a single page. > > --D > > > Signed-off-by: Junchao Sun <sunjunchao2870@gmail.com> > > --- > > fs/xfs/xfs_inode.h | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h > > index 292b90b5f2ac..3239ae4e33d2 100644 > > --- a/fs/xfs/xfs_inode.h > > +++ b/fs/xfs/xfs_inode.h > > @@ -40,8 +40,8 @@ typedef struct xfs_inode { > > /* Transaction and locking information. */ > > struct xfs_inode_log_item *i_itemp; /* logging information */ > > struct rw_semaphore i_lock; /* inode lock */ > > - atomic_t i_pincount; /* inode pin count */ > > struct llist_node i_gclist; /* deferred inactivation list */ > > + atomic_t i_pincount; /* inode pin count */ > > > > /* > > * Bitsets of inode metadata that have been checked and/or are sick. > > -- > > 2.39.2 > > > > -- Junchao Sun <sunjunchao2870@gmail.com> ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] xfs: reorder xfs_inode structure elements to remove unneeded padding. 2024-06-18 16:40 ` JunChao Sun @ 2024-06-18 16:51 ` Matthew Wilcox 2024-06-19 10:05 ` JunChao Sun 0 siblings, 1 reply; 7+ messages in thread From: Matthew Wilcox @ 2024-06-18 16:51 UTC (permalink / raw) To: JunChao Sun Cc: Darrick J. Wong, linux-fsdevel, linux-xfs, viro, brauner, jack, chandan.babu On Tue, Jun 18, 2024 at 12:40:23PM -0400, JunChao Sun wrote: > Darrick J. Wong <djwong@kernel.org> 于2024年6月18日周二 12:23写道: > > > > On Tue, Jun 18, 2024 at 07:35:04PM +0800, Junchao Sun wrote: > > > By reordering the elements in the xfs_inode structure, we can > > > reduce the padding needed on an x86_64 system by 8 bytes. > > > > > > > Does this result in denser packing of xfs_inode objects in the slab > > > page? > > No. Before applying the patch, the size of xfs_inode is 1800 bytes > with my config, and after applying the patch, the size is 1792 bytes. > This slight reduction does not result in a denser packing of xfs_inode > objects within a single page. The "config dependent" part of this is important though. On my laptop running Debian 6.6.15-amd64, xfs_inode is exactly 1024 bytes, and slab chooses to allocate 32 of them from an order-3 slab. Your config gets you 18 from an order-3 slab, and you'd need to get it down to 1724 (probably 1720 bytes due to alignment) to get 19 from an order-3 slab. I bet you have lockdep or something on. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] xfs: reorder xfs_inode structure elements to remove unneeded padding. 2024-06-18 16:51 ` Matthew Wilcox @ 2024-06-19 10:05 ` JunChao Sun 0 siblings, 0 replies; 7+ messages in thread From: JunChao Sun @ 2024-06-19 10:05 UTC (permalink / raw) To: Matthew Wilcox Cc: Darrick J. Wong, linux-fsdevel, linux-xfs, viro, brauner, jack, chandan.babu Matthew Wilcox <willy@infradead.org> 于2024年6月19日周三 00:51写道: > > On Tue, Jun 18, 2024 at 12:40:23PM -0400, JunChao Sun wrote: > > Darrick J. Wong <djwong@kernel.org> 于2024年6月18日周二 12:23写道: > > > > > > On Tue, Jun 18, 2024 at 07:35:04PM +0800, Junchao Sun wrote: > > > > By reordering the elements in the xfs_inode structure, we can > > > > reduce the padding needed on an x86_64 system by 8 bytes. > > > > > > > > > > Does this result in denser packing of xfs_inode objects in the slab > > > > page? > > > > No. Before applying the patch, the size of xfs_inode is 1800 bytes > > with my config, and after applying the patch, the size is 1792 bytes. > > This slight reduction does not result in a denser packing of xfs_inode > > objects within a single page. > > > > The "config dependent" part of this is important though. On my > > laptop running Debian 6.6.15-amd64, xfs_inode is exactly 1024 bytes, > > and slab chooses to allocate 32 of them from an order-3 slab. > > > > Your config gets you 18 from an order-3 slab, and you'd need to get > > it down to 1724 (probably 1720 bytes due to alignment) to get 19 > > from an order-3 slab. I bet you have lockdep or something on. Hi, I couldn't find the exact 6.6.15-amd64 kernel, but I installed the Debian 6.8.12-amd64 and 6.1.0-21-amd64 kernels, along with their corresponding debug packages. In both cases, the size of xfs_inode is 1000 bytes. By eliminating the padding bytes, the number of xfs_inode objects allocated from an order-3 slab increased from 32 to 33. I'm not sure what specific differences there are between our Debian kernels, but I have submitted the v2 version of the patch. If there are any issues, please feel free to let me know. Thank you! Best regards -- Junchao Sun <sunjunchao2870@gmail.com> ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-06-19 10:06 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-06-18 11:35 [PATCH 1/2] xfs: reorder xfs_inode structure elements to remove unneeded padding Junchao Sun 2024-06-18 11:35 ` [PATCH 2/2] vfs: reorder struct file " Junchao Sun 2024-06-18 14:52 ` Christian Brauner 2024-06-18 16:23 ` [PATCH 1/2] xfs: reorder xfs_inode " Darrick J. Wong 2024-06-18 16:40 ` JunChao Sun 2024-06-18 16:51 ` Matthew Wilcox 2024-06-19 10:05 ` JunChao Sun
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).