on 2/28/2024 12:15 AM, Arnd Bergmann wrote: > From: Arnd Bergmann <arnd@xxxxxxxx> > > Storing an inode structure on the stack pushes some functions over the warning > limit for stack frame size: > > In file included from fs/ext4/mballoc.c:7039: > fs/ext4/mballoc-test.c:506:13: error: stack frame size (1032) exceeds limit (1024) in 'test_mark_diskspace_used' [-Werror,-Wframe-larger-than] > 506 | static void test_mark_diskspace_used(struct kunit *test) > | ^ > > Use kunit_kzalloc() for all inodes. There may be a better way to do it by > preallocating the inode, which would result in a larger rework. > > Fixes: 2b81493f8eb6 ("ext4: Add unit test for ext4_mb_mark_diskspace_used") > Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx> > --- > fs/ext4/mballoc-test.c | 27 +++++++++++++++++++++------ > 1 file changed, 21 insertions(+), 6 deletions(-) > > diff --git a/fs/ext4/mballoc-test.c b/fs/ext4/mballoc-test.c > index 12d0b22cabe1..3b43301054b6 100644 > --- a/fs/ext4/mballoc-test.c > +++ b/fs/ext4/mballoc-test.c > @@ -332,14 +332,19 @@ static void mbt_kunit_exit(struct kunit *test) > static void test_new_blocks_simple(struct kunit *test) > { > struct super_block *sb = (struct super_block *)test->priv; > - struct inode inode = { .i_sb = sb, }; > + struct inode *inode; > struct ext4_allocation_request ar; > ext4_group_t i, goal_group = TEST_GOAL_GROUP; > int err = 0; > ext4_fsblk_t found; > struct ext4_sb_info *sbi = EXT4_SB(sb); > > - ar.inode = &inode; > + inode = kunit_kzalloc(test, sizeof(*inode), GFP_KERNEL); > + if (!inode) > + return; > + > + inode->i_sb = sb; > + ar.inode = inode; > > /* get block at goal */ > ar.goal = ext4_group_first_block_no(sb, goal_group); > @@ -441,15 +446,20 @@ test_free_blocks_simple_range(struct kunit *test, ext4_group_t goal_group, > { > struct super_block *sb = (struct super_block *)test->priv; > struct ext4_sb_info *sbi = EXT4_SB(sb); > - struct inode inode = { .i_sb = sb, }; > + struct inode *inode; > ext4_fsblk_t block; > > + inode = kunit_kzalloc(test, sizeof(*inode), GFP_KERNEL); > + if (!inode) > + return; > + inode->i_sb = sb; > + > if (len == 0) > return; > > block = ext4_group_first_block_no(sb, goal_group) + > EXT4_C2B(sbi, start); > - ext4_free_blocks_simple(&inode, block, len); > + ext4_free_blocks_simple(inode, block, len); > validate_free_blocks_simple(test, sb, goal_group, start, len); > mbt_ctx_mark_used(sb, goal_group, 0, EXT4_CLUSTERS_PER_GROUP(sb)); > } > @@ -506,16 +516,21 @@ test_mark_diskspace_used_range(struct kunit *test, > static void test_mark_diskspace_used(struct kunit *test) > { > struct super_block *sb = (struct super_block *)test->priv; > - struct inode inode = { .i_sb = sb, }; > + struct inode *inode; > struct ext4_allocation_context ac; > struct test_range ranges[TEST_RANGE_COUNT]; > int i; > > mbt_generate_test_ranges(sb, ranges, TEST_RANGE_COUNT); > > + inode = kunit_kzalloc(test, sizeof(*inode), GFP_KERNEL); > + if (!inode) > + return; > + inode->i_sb = sb; > + > ac.ac_status = AC_STATUS_FOUND; > ac.ac_sb = sb; > - ac.ac_inode = &inode; > + ac.ac_inode = inode; > for (i = 0; i < TEST_RANGE_COUNT; i++) > test_mark_diskspace_used_range(test, &ac, ranges[i].start, > ranges[i].len); > Thanks for the fix. Feel free to add: Reviewed-by: Kemeng Shi <shikemeng@xxxxxxxxxxxxxxx>