• David Sterba's avatar
    btrfs: better packing of btrfs_delayed_extent_op · 35b3ad50
    David Sterba authored
    btrfs_delayed_extent_op can be packed in a better way, it's 40 bytes now
    and has 8 unused bytes. Reducing the level type to u8 makes it possible
    to squeeze it to the padding byte after key. The bitfields were switched
    to bool as there's space to store the full byte without increasing the
    whole structure, besides that the generated assembly is smaller.
    
    struct btrfs_delayed_extent_op {
    	struct btrfs_disk_key      key;                  /*     0    17 */
    	u8                         level;                /*    17     1 */
    	bool                       update_key;           /*    18     1 */
    	bool                       update_flags;         /*    19     1 */
    	bool                       is_data;              /*    20     1 */
    
    	/* XXX 3 bytes hole, try to pack */
    
    	u64                        flags_to_set;         /*    24     8 */
    
    	/* size: 32, cachelines: 1, members: 6 */
    	/* sum members: 29, holes: 1, sum holes: 3 */
    	/* last cacheline: 32 bytes */
    };
    
    The final size is 32 bytes which gives +26 object per slab page.
    
       text	   data	    bss	    dec	    hex	filename
     938811	  43670	  23144	1005625	  f5839	fs/btrfs/btrfs.ko.before
     938747	  43670	  23144	1005561	  f57f9	fs/btrfs/btrfs.ko.after
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    35b3ad50
delayed-ref.c 26.4 KB