Commit ae0e5df4 authored by David Sterba's avatar David Sterba

btrfs: reorder btrfs_bio for better packing

After changes in commit 917f32a2 ("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: 917f32a2 ("btrfs: give struct btrfs_bio a real end_io handler")
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent ab4c54c6
...@@ -395,6 +395,7 @@ typedef void (*btrfs_bio_end_io_t)(struct btrfs_bio *bbio); ...@@ -395,6 +395,7 @@ typedef void (*btrfs_bio_end_io_t)(struct btrfs_bio *bbio);
*/ */
struct btrfs_bio { struct btrfs_bio {
unsigned int mirror_num; unsigned int mirror_num;
struct bvec_iter iter;
/* for direct I/O */ /* for direct I/O */
u64 file_offset; u64 file_offset;
...@@ -403,7 +404,6 @@ struct btrfs_bio { ...@@ -403,7 +404,6 @@ struct btrfs_bio {
struct btrfs_device *device; struct btrfs_device *device;
u8 *csum; u8 *csum;
u8 csum_inline[BTRFS_BIO_INLINE_CSUM_SIZE]; u8 csum_inline[BTRFS_BIO_INLINE_CSUM_SIZE];
struct bvec_iter iter;
/* End I/O information supplied to btrfs_bio_alloc */ /* End I/O information supplied to btrfs_bio_alloc */
btrfs_bio_end_io_t end_io; btrfs_bio_end_io_t end_io;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment