From: Sun YangKai <sunk67188@gmail.com>
To: fdmanana@kernel.org, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v2 02/10] btrfs: reduce size of struct btrfs_block_group
Date: Sun, 19 Apr 2026 15:32:37 +0800 [thread overview]
Message-ID: <1c71bc46-9135-4063-9c76-0db94643b671@gmail.com> (raw)
In-Reply-To: <ef130a3bd2f994d615e9b7dc8b17132b6c3a7fc1.1776278490.git.fdmanana@suse.com>
> struct btrfs_block_group {
> struct btrfs_fs_info * fs_info; /* 0 8 */
> struct btrfs_inode * inode; /* 8 8 */
> spinlock_t lock __attribute__((__aligned__(4))); /* 16 4 */
> unsigned int ro; /* 20 4 */
> u64 start; /* 24 8 */
> u64 length; /* 32 8 */
> u64 pinned; /* 40 8 */
> u64 reserved; /* 48 8 */
> u64 used; /* 56 8 */
> /* --- cacheline 1 boundary (64 bytes) --- */
> u64 delalloc_bytes; /* 64 8 */
> u64 bytes_super; /* 72 8 */
> u64 flags; /* 80 8 */
> u64 cache_generation; /* 88 8 */
> u64 global_root_id; /* 96 8 */
> u64 remap_bytes; /* 104 8 */
> u32 identity_remap_count; /* 112 4 */
> u32 last_identity_remap_count; /* 116 4 */
> u64 last_used; /* 120 8 */
> /* --- cacheline 2 boundary (128 bytes) --- */
> u64 last_remap_bytes; /* 128 8 */
> u64 last_flags; /* 136 8 */
> u32 bitmap_high_thresh; /* 144 4 */
> u32 bitmap_low_thresh; /* 148 4 */
> struct rw_semaphore data_rwsem __attribute__((__aligned__(8))); /* 152 40 */
> /* --- cacheline 3 boundary (192 bytes) --- */
> long unsigned int full_stripe_len; /* 192 8 */
> long unsigned int runtime_flags; /* 200 8 */
> int disk_cache_state; /* 208 4 */
This seems always used as enum btrfs_disk_cache_state
> int cached; /* 212 4 */
This seems always used as enum btrfs_caching_type
Maybe we could change them to use the more proper type in this patch
series for better type safety and self documenting.
Thanks,
Sun YangKai
> struct btrfs_caching_control * caching_ctl; /* 216 8 */
> struct btrfs_space_info * space_info; /* 224 8 */
> struct btrfs_free_space_ctl * free_space_ctl; /* 232 8 */
> struct rb_node cache_node __attribute__((__aligned__(8))); /* 240 24 */
> /* --- cacheline 4 boundary (256 bytes) was 8 bytes ago --- */
> struct list_head list; /* 264 16 */
> refcount_t refs __attribute__((__aligned__(4))); /* 280 4 */
> atomic_t frozen __attribute__((__aligned__(4))); /* 284 4 */
> struct list_head cluster_list; /* 288 16 */
> struct list_head bg_list; /* 304 16 */
> /* --- cacheline 5 boundary (320 bytes) --- */
> struct list_head ro_list; /* 320 16 */
> struct list_head discard_list; /* 336 16 */
> int discard_index; /* 352 4 */
> enum btrfs_discard_state discard_state; /* 356 4 */
> u64 discard_eligible_time; /* 360 8 */
> u64 discard_cursor; /* 368 8 */
> struct list_head dirty_list; /* 376 16 */
> /* --- cacheline 6 boundary (384 bytes) was 8 bytes ago --- */
> struct list_head io_list; /* 392 16 */
> struct btrfs_io_ctl io_ctl; /* 408 72 */
> /* --- cacheline 7 boundary (448 bytes) was 32 bytes ago --- */
> atomic_t reservations __attribute__((__aligned__(4))); /* 480 4 */
> atomic_t nocow_writers __attribute__((__aligned__(4))); /* 484 4 */
> struct mutex free_space_lock __attribute__((__aligned__(8))); /* 488 32 */
> /* --- cacheline 8 boundary (512 bytes) was 8 bytes ago --- */
> bool using_free_space_bitmaps; /* 520 1 */
> bool using_free_space_bitmaps_cached; /* 521 1 */
>
> /* XXX 2 bytes hole, try to pack */
> /* Bitfield combined with previous fields */
>
> static enum btrfs_block_group_size_class size_class; /* 0: 0 0 */
> int swap_extents; /* 524 4 */
> u64 alloc_offset; /* 528 8 */
> u64 zone_unusable; /* 536 8 */
> u64 zone_capacity; /* 544 8 */
> u64 meta_write_pointer; /* 552 8 */
> struct btrfs_chunk_map * physical_map; /* 560 8 */
> struct list_head active_bg_list; /* 568 16 */
> /* --- cacheline 9 boundary (576 bytes) was 8 bytes ago --- */
> struct work_struct zone_finish_work; /* 584 32 */
> struct extent_buffer * last_eb; /* 616 8 */
> u64 reclaim_mark; /* 624 8 */
>
> /* size: 632, cachelines: 10, members: 60, static members: 1 */
> /* sum members: 630, holes: 1, sum holes: 2 */
> /* sum bitfield members: 8 bits (1 bytes) */
> /* forced alignments: 8 */
> /* last cacheline: 56 bytes */
>
> /* BRAIN FART ALERT! 632 bytes != 630 (member bytes) + 8 (member bits) + 2 (byte holes) + 0 (bit holes), diff = -8 bits */
> } __attribute__((__aligned__(8)));
>
> Signed-off-by: Filipe Manana <fdmanana@suse.com>
> ---
> fs/btrfs/block-group.h | 33 ++++++++++++++++-----------------
> 1 file changed, 16 insertions(+), 17 deletions(-)
next prev parent reply other threads:[~2026-04-19 7:32 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-15 14:38 [PATCH 0/9] btrfs: reduce memory consumption for block groups fdmanana
2026-04-15 14:38 ` [PATCH 1/9] btrfs: use a kmem_cache " fdmanana
2026-04-15 14:38 ` [PATCH 2/9] btrfs: reduce size of struct btrfs_block_group fdmanana
2026-04-15 14:38 ` [PATCH 3/9] btrfs: use a kmem_cache for free space control structures fdmanana
2026-04-15 14:38 ` [PATCH 4/9] btrfs: remove start field from struct btrfs_free_space_ctl fdmanana
2026-04-15 14:38 ` [PATCH 5/9] btrfs: remove unit " fdmanana
2026-04-15 14:38 ` [PATCH 6/9] btrfs: reduce size of " fdmanana
2026-04-15 14:38 ` [PATCH 7/9] btrfs: remove block group argument from copy_free_space_cache() fdmanana
2026-04-15 14:38 ` [PATCH 8/9] btrfs: remove unnecessary ctl argument from __btrfs_write_out_cache() fdmanana
2026-04-15 14:38 ` [PATCH 9/9] btrfs: remove unnecessary ctl argument from write_cache_extent_entries() fdmanana
2026-04-15 18:44 ` [PATCH v2 00/10] btrfs: reduce memory consumption for block groups fdmanana
2026-04-15 18:44 ` [PATCH v2 01/10] btrfs: use a kmem_cache " fdmanana
2026-04-17 1:51 ` David Sterba
2026-04-15 18:44 ` [PATCH v2 02/10] btrfs: reduce size of struct btrfs_block_group fdmanana
2026-04-15 20:07 ` Martin Raiber
2026-04-16 10:30 ` Filipe Manana
2026-04-16 10:46 ` Martin Raiber
2026-04-17 2:09 ` David Sterba
2026-04-19 7:32 ` Sun YangKai [this message]
2026-04-20 14:00 ` Filipe Manana
2026-04-15 18:44 ` [PATCH v2 03/10] btrfs: use a kmem_cache for free space control structures fdmanana
2026-04-15 18:44 ` [PATCH v2 04/10] btrfs: remove start field from struct btrfs_free_space_ctl fdmanana
2026-04-15 18:44 ` [PATCH v2 05/10] btrfs: remove unit " fdmanana
2026-04-15 18:44 ` [PATCH v2 06/10] btrfs: reduce size of " fdmanana
2026-04-15 18:44 ` [PATCH v2 07/10] btrfs: remove op field from " fdmanana
2026-04-15 18:44 ` [PATCH v2 08/10] btrfs: remove block group argument from copy_free_space_cache() fdmanana
2026-04-15 18:44 ` [PATCH v2 09/10] btrfs: remove unnecessary ctl argument from __btrfs_write_out_cache() fdmanana
2026-04-15 18:44 ` [PATCH v2 10/10] btrfs: remove unnecessary ctl argument from write_cache_extent_entries() fdmanana
2026-04-17 2:16 ` [PATCH v2 00/10] btrfs: reduce memory consumption for block groups David Sterba
2026-04-17 7:54 ` Filipe Manana
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=1c71bc46-9135-4063-9c76-0db94643b671@gmail.com \
--to=sunk67188@gmail.com \
--cc=fdmanana@kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.