btrfs-progs: reorder extent buffer members for better packing
authorDavid Sterba <dsterba@suse.com>
Mon, 9 Apr 2018 15:42:40 +0000 (17:42 +0200)
committerDavid Sterba <dsterba@suse.com>
Tue, 24 Apr 2018 11:00:12 +0000 (13:00 +0200)
Afther the fs_info was added, the size was over 128 bytes but we still
have 8 bytes of holes, so with minor reordering we get back to that size.

Before:

struct extent_buffer {
        struct cache_extent        cache_node;           /*     0    48 */
        u64                        start;                /*    48     8 */
        u64                        dev_bytenr;           /*    56     8 */
        /* --- cacheline 1 boundary (64 bytes) --- */
        u32                        len;                  /*    64     4 */

        /* XXX 4 bytes hole, try to pack */

        struct extent_io_tree *    tree;                 /*    72     8 */
        struct list_head           lru;                  /*    80    16 */
        struct list_head           recow;                /*    96    16 */
        int                        refs;                 /*   112     4 */
        u32                        flags;                /*   116     4 */
        int                        fd;                   /*   120     4 */

        /* XXX 4 bytes hole, try to pack */

        /* --- cacheline 2 boundary (128 bytes) --- */
        struct btrfs_fs_info *     fs_info;              /*   128     8 */
        char                       data[0];              /*   136     0 */

        /* size: 136, cachelines: 3, members: 12 */
        /* sum members: 128, holes: 2, sum holes: 8 */
        /* last cacheline: 8 bytes */
};

After:

struct extent_buffer {
        struct cache_extent        cache_node;           /*     0    48 */
        u64                        start;                /*    48     8 */
        u64                        dev_bytenr;           /*    56     8 */
        /* --- cacheline 1 boundary (64 bytes) --- */
        struct extent_io_tree *    tree;                 /*    64     8 */
        struct list_head           lru;                  /*    72    16 */
        struct list_head           recow;                /*    88    16 */
        u32                        len;                  /*   104     4 */
        int                        refs;                 /*   108     4 */
        u32                        flags;                /*   112     4 */
        int                        fd;                   /*   116     4 */
        struct btrfs_fs_info *     fs_info;              /*   120     8 */
        /* --- cacheline 2 boundary (128 bytes) --- */
        char                       data[0];              /*   128     0 */

        /* size: 128, cachelines: 2, members: 12 */
};

Signed-off-by: David Sterba <dsterba@suse.com>
extent_io.h

index f8f7308..d407d93 100644 (file)
@@ -91,10 +91,10 @@ struct extent_buffer {
        struct cache_extent cache_node;
        u64 start;
        u64 dev_bytenr;
-       u32 len;
        struct extent_io_tree *tree;
        struct list_head lru;
        struct list_head recow;
+       u32 len;
        int refs;
        u32 flags;
        int fd;