Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ext4: specify the free pointer offset for ext4_inode_cache

Convert ext4_inode_cache to use the kmem_cache_args interface and
specify a free pointer offset.

Since ext4_inode_cache uses a constructor, the free pointer would be
placed after the object to prevent overwriting fields used by the
constructor.

However, some fields such as ->i_flags are not used by the constructor
and can safely be repurposed for the free pointer.

Specify the free pointer offset at i_flags to reduce the object size.

Signed-off-by: Harry Yoo <harry.yoo@oracle.com>
Link: https://patch.msgid.link/20260113061845.159790-4-harry.yoo@oracle.com
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>

authored by

Harry Yoo and committed by
Vlastimil Babka
43d9bb42 a13b68d7

+13 -6
+13 -6
fs/ext4/super.c
··· 1491 1491 1492 1492 static int __init init_inodecache(void) 1493 1493 { 1494 - ext4_inode_cachep = kmem_cache_create_usercopy("ext4_inode_cache", 1495 - sizeof(struct ext4_inode_info), 0, 1496 - SLAB_RECLAIM_ACCOUNT | SLAB_ACCOUNT, 1497 - offsetof(struct ext4_inode_info, i_data), 1498 - sizeof_field(struct ext4_inode_info, i_data), 1499 - init_once); 1494 + struct kmem_cache_args args = { 1495 + .useroffset = offsetof(struct ext4_inode_info, i_data), 1496 + .usersize = sizeof_field(struct ext4_inode_info, i_data), 1497 + .use_freeptr_offset = true, 1498 + .freeptr_offset = offsetof(struct ext4_inode_info, i_flags), 1499 + .ctor = init_once, 1500 + }; 1501 + 1502 + ext4_inode_cachep = kmem_cache_create("ext4_inode_cache", 1503 + sizeof(struct ext4_inode_info), 1504 + &args, 1505 + SLAB_RECLAIM_ACCOUNT | SLAB_ACCOUNT); 1506 + 1500 1507 if (ext4_inode_cachep == NULL) 1501 1508 return -ENOMEM; 1502 1509 return 0;