btrfs: accessors: compile-time fast path for u16
authorDavid Sterba <dsterba@suse.com>
Tue, 1 Jul 2025 17:23:52 +0000 (19:23 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 21 Jul 2025 22:09:21 +0000 (00:09 +0200)
commit1ed0f75d57aef3c447fbc78885c90421e40c1755
tree701010d0a5b3b26ccbb23ac2ac7d2c68503fc4c0
parent58383c6866a76acb719b1f22caaba64fa4dd3f6e
btrfs: accessors: compile-time fast path for u16

Reading/writing 2 bytes (u16) may need 2 folios to be written to, each
time it's just one byte so using memcpy for that is an overkill.
Add a branch for the split case so that memcpy is now used for u32 and
u64. Another side effect is that the u16 types now don't need additional
stack space, everything fits to registers.

Stack usage is reduced:

  btrfs_get_16                                           -8 (32 -> 24)
  btrfs_set_16                                          -16 (32 -> 16)

Code size reduction:

     text    data     bss     dec     hex filename
  1454691  115665   16088 1586444  18350c pre/btrfs.ko
  1454459  115665   16088 1586212  183424 post/btrfs.ko

  DELTA: -232

Reviewed-by: Boris Burkov <boris@bur.io>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/accessors.c