From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: David Sterba <dsterba@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 2/4] btrfs: reorder members in btrfs_delayed_root for better packing
Date: Sat, 10 Jan 2026 07:46:11 +1030 [thread overview]
Message-ID: <60a3f79f-b337-4309-9689-3ce0dd90e69d@gmx.com> (raw)
In-Reply-To: <4ffb0817d978715cb34cef429c797f211a993551.1767979013.git.dsterba@suse.com>
在 2026/1/10 03:47, David Sterba 写道:
> There are two unnecessary 4B holes in btrfs_delayed_root;
>
> struct btrfs_delayed_root {
> spinlock_t lock; /* 0 4 */
>
> /* XXX 4 bytes hole, try to pack */
>
> struct list_head node_list; /* 8 16 */
> struct list_head prepare_list; /* 24 16 */
> atomic_t items; /* 40 4 */
> atomic_t items_seq; /* 44 4 */
> int nodes; /* 48 4 */
>
> /* XXX 4 bytes hole, try to pack */
>
> wait_queue_head_t wait; /* 56 24 */
>
> /* size: 80, cachelines: 2, members: 7 */
> /* sum members: 72, holes: 2, sum holes: 8 */
> /* last cacheline: 16 bytes */
> };
>
> Reordering 'nodes' after 'lock' reduces size by 8B, to 72 on release
> config.
Not a huge thing, but can we put members in descend order of their sizes
if they are properly aligned.
For this particular case, wait_queue_heat_t itself isn't properly
power-of-2 sized, but with 2 32bits member, it can be shrink even futher:
struct btrfs_delayed_root {
wait_queue_head_t wait; /* 0 24 */
int nodes; /* 24 4 */
spinlock_t lock; /* 28 4 */
struct list_head node_list; /* 32 16 */
struct list_head prepare_list; /* 48 16 */
/* --- cacheline 1 boundary (64 bytes) --- */
atomic_t items; /* 64 4 */
atomic_t items_seq; /* 68 4 */
/* size: 72, cachelines: 2, members: 7 */
/* last cacheline: 8 bytes */
};
Thanks,
Qu
>
> Signed-off-by: David Sterba <dsterba@suse.com>
> ---
> fs/btrfs/fs.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/fs.h b/fs/btrfs/fs.h
> index dd4944f9a98553..4d721fbd390c55 100644
> --- a/fs/btrfs/fs.h
> +++ b/fs/btrfs/fs.h
> @@ -456,6 +456,7 @@ struct btrfs_commit_stats {
>
> struct btrfs_delayed_root {
> spinlock_t lock;
> + int nodes; /* for delayed nodes */
> struct list_head node_list;
> /*
> * Used for delayed nodes which is waiting to be dealt with by the
> @@ -465,7 +466,6 @@ struct btrfs_delayed_root {
> struct list_head prepare_list;
> atomic_t items; /* for delayed items */
> atomic_t items_seq; /* for delayed items */
> - int nodes; /* for delayed nodes */
> wait_queue_head_t wait;
> };
>
next prev parent reply other threads:[~2026-01-09 21:16 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-09 17:17 [PATCH 0/4] Delayed ref root cleanups David Sterba
2026-01-09 17:17 ` [PATCH 1/4] btrfs: embed delayed root to struct btrfs_fs_info David Sterba
2026-01-09 17:17 ` [PATCH 2/4] btrfs: reorder members in btrfs_delayed_root for better packing David Sterba
2026-01-09 21:16 ` Qu Wenruo [this message]
2026-01-13 0:56 ` David Sterba
2026-01-09 17:17 ` [PATCH 3/4] btrfs: don't use local variables for fs_info->delayed_root David Sterba
2026-01-09 17:17 ` [PATCH 4/4] btrfs: pass btrfs_fs_info to btrfs_first_delayed_node() David Sterba
2026-01-09 18:16 ` [PATCH 0/4] Delayed ref root cleanups Boris Burkov
2026-01-09 21:09 ` David Sterba
2026-01-09 21:39 ` Boris Burkov
2026-01-13 1:10 ` David Sterba
2026-01-09 22:27 ` Boris Burkov
2026-01-13 1:11 ` David Sterba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=60a3f79f-b337-4309-9689-3ce0dd90e69d@gmx.com \
--to=quwenruo.btrfs@gmx.com \
--cc=dsterba@suse.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox