The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Daniel Vacek <neelx@suse.com>
To: David Sterba <dsterba@suse.com>, Chris Mason <clm@fb.com>,
	Josef Bacik <josef@toxicpanda.com>
Cc: Daniel Vacek <neelx@suse.com>,
	linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 2/2] btrfs: rearrange the extent buffer structure members
Date: Fri,  2 May 2025 15:37:23 +0200	[thread overview]
Message-ID: <20250502133725.1210587-3-neelx@suse.com> (raw)
In-Reply-To: <20250502133725.1210587-1-neelx@suse.com>

Fill in the hole after the removed `len` field. There should be no difference
on default config but it cuts the size down by 8 bytes on -rt kernels due to
different lock sizes and alignment. This way we can completely get rid of the
other hole which was there before.

Signed-off-by: Daniel Vacek <neelx@suse.com>
---

This patch is new in v2.

@Dave> What assembly would you like to see?

>@@ -10148,30 +10148,27 @@
> struct extent_buffer {
> 	u64                        start;                /*     0     8 */
> 	u32                        folio_size;           /*     8     4 */
>+	u8                         folio_shift;          /*    12     1 */
>+	s8                         log_index;            /*    13     1 */
> 
>-	/* XXX 4 bytes hole, try to pack */
>+	/* XXX 2 bytes hole, try to pack */
> 
> 	long unsigned int          bflags;               /*    16     8 */
> 	struct btrfs_fs_info *     fs_info;              /*    24     8 */
> 	void *                     addr;                 /*    32     8 */
> 	spinlock_t                 refs_lock;            /*    40    32 */
> 	/* --- cacheline 1 boundary (64 bytes) was 8 bytes ago --- */
> 	atomic_t                   refs;                 /*    72     4 */
> 	int                        read_mirror;          /*    76     4 */
>-	s8                         log_index;            /*    80     1 */
>-	u8                         folio_shift;          /*    81     1 */
>+	struct callback_head       callback_head __attribute__((__aligned__(8))); /*    80    16 */
>+	struct rw_semaphore        lock;                 /*    96    40 */
>+	/* --- cacheline 2 boundary (128 bytes) was 8 bytes ago --- */
>+	struct folio *             folios[16];           /*   136   128 */
> 
>-	/* XXX 6 bytes hole, try to pack */
>-
>-	struct callback_head       callback_head __attribute__((__aligned__(8))); /*    88    16 */
>-	struct rw_semaphore        lock;                 /*   104    40 */
>-	/* --- cacheline 2 boundary (128 bytes) was 16 bytes ago --- */
>-	struct folio *             folios[16];           /*   144   128 */
>-
>-	/* size: 272, cachelines: 5, members: 13 */
>-	/* sum members: 262, holes: 2, sum holes: 10 */
>-	/* forced alignments: 1, forced holes: 1, sum forced holes: 6 */
>-	/* last cacheline: 16 bytes */
>+	/* size: 264, cachelines: 5, members: 13 */
>+	/* sum members: 262, holes: 1, sum holes: 2 */
>+	/* forced alignments: 1 */
>+	/* last cacheline: 8 bytes */
> } __attribute__((__aligned__(8)));

Here the refs_lock and refs are split to different cachelines. But the
slab object is not aligned anyways so this is inevitable anyways on -rt.
For non-rt they always move together as they fit into 8 bytes aligned.
So that's not an issue for non-rt.

---
 fs/btrfs/extent_io.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h
index 7a8451c11630a..5162d2da767ad 100644
--- a/fs/btrfs/extent_io.h
+++ b/fs/btrfs/extent_io.h
@@ -88,6 +88,9 @@ void __cold extent_buffer_free_cachep(void);
 struct extent_buffer {
 	u64 start;
 	u32 folio_size;
+	u8 folio_shift;
+	/* >= 0 if eb belongs to a log tree, -1 otherwise */
+	s8 log_index;
 	unsigned long bflags;
 	struct btrfs_fs_info *fs_info;
 
@@ -100,9 +103,6 @@ struct extent_buffer {
 	spinlock_t refs_lock;
 	atomic_t refs;
 	int read_mirror;
-	/* >= 0 if eb belongs to a log tree, -1 otherwise */
-	s8 log_index;
-	u8 folio_shift;
 	struct rcu_head rcu_head;
 
 	struct rw_semaphore lock;
-- 
2.47.2


      parent reply	other threads:[~2025-05-02 13:38 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-29 15:17 [PATCH] btrfs: remove extent buffer's redundant `len` member field Daniel Vacek
2025-04-29 22:34 ` Qu Wenruo
2025-04-30  8:03 ` David Sterba
2025-04-30  8:21   ` Daniel Vacek
2025-04-30 12:31     ` Daniel Vacek
2025-05-02 10:30       ` David Sterba
2025-05-02 11:23         ` Daniel Vacek
2025-04-30 13:30     ` David Sterba
2025-04-30 14:13       ` Daniel Vacek
2025-05-02 10:56         ` David Sterba
2025-05-02 12:03           ` Daniel Vacek
2025-05-05 14:10             ` David Sterba
2025-05-05 16:19               ` Daniel Vacek
2025-04-30  8:05 ` Filipe Manana
2025-04-30  8:26   ` Daniel Vacek
2025-04-30  8:34     ` Filipe Manana
2025-04-30  8:50       ` Daniel Vacek
2025-04-30 10:26         ` Filipe Manana
2025-04-30 11:09           ` Johannes Thumshirn
2025-04-30 12:09             ` Daniel Vacek
2025-04-30 12:06           ` Daniel Vacek
2025-04-30 12:33             ` Filipe Manana
2025-04-30 12:53               ` Daniel Vacek
2025-05-02 13:37 ` [PATCH v2 0/2] btrfs: eb struct cleanups Daniel Vacek
2025-05-02 13:37   ` [PATCH v2 1/2] btrfs: remove extent buffer's redundant `len` member field Daniel Vacek
2025-05-02 17:35     ` Boris Burkov
2025-05-05  8:23       ` Daniel Vacek
2025-05-05 11:50     ` [PATCH v3 0/2] btrfs: eb struct cleanups Daniel Vacek
2025-05-05 11:50       ` [PATCH v3 1/2] btrfs: remove extent buffer's redundant `len` member field Daniel Vacek
2025-05-05 15:18         ` David Sterba
2025-05-05 17:53           ` Daniel Vacek
2025-05-13  0:32             ` David Sterba
2025-05-13 10:43               ` Daniel Vacek
2025-05-05 11:50       ` [PATCH v3 2/2] btrfs: rearrange the extent buffer structure members Daniel Vacek
2025-05-02 13:37   ` Daniel Vacek [this message]

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=20250502133725.1210587-3-neelx@suse.com \
    --to=neelx@suse.com \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=josef@toxicpanda.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@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