]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
btrfs: use a kmem_cache for free space control structures
authorFilipe Manana <fdmanana@suse.com>
Wed, 15 Apr 2026 12:12:13 +0000 (13:12 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 8 Jun 2026 13:53:29 +0000 (15:53 +0200)
commit66fd877b13c7e7285ec607e4433efec3c2b2dd6a
tree3d8ecd411004659934b37d877aeb96624f9c70d1
parenta8d1f0b5392473102f08d6f91f4dcdfaf9e29b0f
btrfs: use a kmem_cache for free space control structures

We are currently allocating the free space control structures for block
groups using the generic slabs, and given that the size of the
btrfs_free_space_ctl structure is 152 bytes (on a release kernel), we end
up using the kmalloc-192 slab and therefore waste quite some memory since
on a 4K page system we can only fit 21 free space control structures per
page. These structures are allocated and delallocated every time we create
and remove block groups.

So use a kmem_cache for free space control structures, this way on a 4K
page system we can fit 26 structures instead of 21.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/block-group.c