btrfs: reorder btrfs_bio for better packing
authorDavid Sterba <dsterba@suse.com>
Tue, 11 Oct 2022 10:02:31 +0000 (12:02 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 24 Oct 2022 13:27:34 +0000 (15:27 +0200)
After changes in commit 917f32a23501 ("btrfs: give struct btrfs_bio a
real end_io handler") the layout of btrfs_bio can be improved.  There
are two holes and the structure size is 264 bytes on release build. By
reordering the iterator we can get rid of the holes and the size is 256
bytes which fits to slabs much better.

Final layout:

struct btrfs_bio {
unsigned int               mirror_num;           /*     0     4 */
struct bvec_iter           iter;                 /*     4    20 */
u64                        file_offset;          /*    24     8 */
struct btrfs_device *      device;               /*    32     8 */
u8 *                       csum;                 /*    40     8 */
u8                         csum_inline[64];      /*    48    64 */
/* --- cacheline 1 boundary (64 bytes) was 48 bytes ago --- */
btrfs_bio_end_io_t         end_io;               /*   112     8 */
void *                     private;              /*   120     8 */
/* --- cacheline 2 boundary (128 bytes) --- */
struct work_struct         end_io_work;          /*   128    32 */
struct bio                 bio;                  /*   160    96 */

/* size: 256, cachelines: 4, members: 10 */
};

Fixes: 917f32a23501 ("btrfs: give struct btrfs_bio a real end_io handler")
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/volumes.h

index 599b9d5..f8b668d 100644 (file)
@@ -395,6 +395,7 @@ typedef void (*btrfs_bio_end_io_t)(struct btrfs_bio *bbio);
  */
 struct btrfs_bio {
        unsigned int mirror_num;
+       struct bvec_iter iter;
 
        /* for direct I/O */
        u64 file_offset;
@@ -403,7 +404,6 @@ struct btrfs_bio {
        struct btrfs_device *device;
        u8 *csum;
        u8 csum_inline[BTRFS_BIO_INLINE_CSUM_SIZE];
-       struct bvec_iter iter;
 
        /* End I/O information supplied to btrfs_bio_alloc */
        btrfs_bio_end_io_t end_io;