Skip to content

Commit db1da57

Browse files
committed
btrfs: accessors: compile-time fast path for u8
Reading/writing 1 byte (u8) is a special case compared to the others as it's always contained in the folio we find, so the split memcpy will never be needed. Turn it to a compile-time check that the memcpy part can be optimized out. The stack usage is reduced: btrfs_set_8 -16 (32 -> 16) btrfs_get_8 -16 (24 -> 8) Code size reduction: text data bss dec hex filename 1454951 115665 16088 1586704 183610 pre/btrfs.ko 1454691 115665 16088 1586444 18350c post/btrfs.ko DELTA: -260 Reviewed-by: Boris Burkov <boris@bur.io> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 026cc40 commit db1da57

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

fs/btrfs/accessors.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ u##bits btrfs_get_##bits(const struct extent_buffer *eb, \
5555
report_setget_bounds(eb, ptr, off, sizeof(u##bits)); \
5656
return 0; \
5757
} \
58-
if (INLINE_EXTENT_BUFFER_PAGES == 1 || likely(sizeof(u##bits) <= part)) \
58+
if (INLINE_EXTENT_BUFFER_PAGES == 1 || sizeof(u##bits) == 1 || \
59+
likely(sizeof(u##bits) <= part)) \
5960
return get_unaligned_le##bits(kaddr + oil); \
6061
\
6162
memcpy(lebytes, kaddr + oil, part); \
@@ -78,7 +79,7 @@ void btrfs_set_##bits(const struct extent_buffer *eb, void *ptr, \
7879
report_setget_bounds(eb, ptr, off, sizeof(u##bits)); \
7980
return; \
8081
} \
81-
if (INLINE_EXTENT_BUFFER_PAGES == 1 || \
82+
if (INLINE_EXTENT_BUFFER_PAGES == 1 || sizeof(u##bits) == 1 || \
8283
likely(sizeof(u##bits) <= part)) { \
8384
put_unaligned_le##bits(val, kaddr + oil); \
8485
return; \

0 commit comments

Comments
 (0)