Linux EXT4 FS development
 help / color / mirror / Atom feed
* [PATCH] ext4: kunit: reduce stack usage
@ 2026-12-01  9:14 Arnd Bergmann
  2026-12-01  9:17 ` sashiko-bot
  2026-12-01 10:10 ` Jan Kara
  0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2026-12-01  9:14 UTC (permalink / raw)
  To: Theodore Ts'o
  Cc: Arnd Bergmann, Andreas Dilger, Baokun Li, Jan Kara, Ojaswin Mujoo,
	Ritesh Harjani (IBM), Zhang Yi, linux-ext4

From: Arnd Bergmann <arnd@arndb.de>

The new kunit tests trip my build bot testing with a slighly reduced
stack frame warning size, as there are some very large structures
on the stack:

arm-soc/fs/ext4/namei-test.c: In function 'test_namei_inline_dir_lifecycle':
arm-soc/fs/ext4/namei-test.c:1870:1: error: the frame size of 1616 bytes is larger than 1536 bytes [-Werror=frame-larger-than=]
 1870 | }
      | ^
fs/ext4/namei-test.c: In function 'test_namei_dx_index_level_growth_and_fallback':
fs/ext4/namei-test.c:1807:1: error: the frame size of 1616 bytes is larger than 1536 bytes [-Werror=frame-larger-than=]

Change the largest ones to be dynamically allocated, as they
are in a lot of the other functions.

Fixes: b82144c319f9 ("ext4: add KUnit tests for fs/ext4/namei.c")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 fs/ext4/namei-test.c | 46 ++++++++++++++++++++++++++------------------
 1 file changed, 27 insertions(+), 19 deletions(-)

diff --git a/fs/ext4/namei-test.c b/fs/ext4/namei-test.c
index f0192135fcf2..07a0e4b73d94 100644
--- a/fs/ext4/namei-test.c
+++ b/fs/ext4/namei-test.c
@@ -1603,18 +1603,23 @@ static void test_namei_dx_index_level_growth_and_fallback(struct kunit *test)
 	struct inode *root_dir = get_mock_inode(ctx, TEST_ROOT_INO);
 	struct inode *dir = get_mock_inode(ctx, TEST_DIR_INO);
 	struct inode *file1 = get_mock_inode(ctx, TEST_FILE1_INO);
-	struct dentry parent_dentry, child_dentry;
+	struct dentry *parent_dentry, *child_dentry;
 	struct buffer_head *bh0, *bh1, *found_bh;
 	struct dx_root *root;
 	struct ext4_dir_entry_2 *de = NULL;
 	unsigned int root_limit;
 	int i, err;
 
+	parent_dentry = kunit_kzalloc(test, sizeof(*parent_dentry), GFP_KERNEL);
+	KUNIT_ASSERT_NOT_NULL(test, parent_dentry);
+	child_dentry = kunit_kzalloc(test, sizeof(*child_dentry), GFP_KERNEL);
+	KUNIT_ASSERT_NOT_NULL(test, child_dentry);
+
 	ctx->es.s_feature_ro_compat |=
 		cpu_to_le32(EXT4_FEATURE_RO_COMPAT_METADATA_CSUM);
 
 	KUNIT_ASSERT_EQ(test, ext4_init_new_dir(NULL, root_dir, dir), 0);
-	init_mock_dentry(&parent_dentry, NULL, "dir", dir, &ctx->sb);
+	init_mock_dentry(parent_dentry, NULL, "dir", dir, &ctx->sb);
 
 	/* Set up a 1-level HTree where root->entries is completely full */
 	ext4_set_inode_flag(dir, EXT4_INODE_INDEX);
@@ -1668,15 +1673,15 @@ static void test_namei_dx_index_level_growth_and_fallback(struct kunit *test)
 	 * full (count == limit), triggering the add_level branch in
 	 * ext4_dx_add_entry (indirect_levels: 0 -> 1).
 	 */
-	init_mock_dentry(&child_dentry, &parent_dentry, "trigger_split_entry",
+	init_mock_dentry(child_dentry, parent_dentry, "trigger_split_entry",
 			 file1, &ctx->sb);
-	err = ext4_add_entry_test(NULL, &child_dentry, file1);
+	err = ext4_add_entry_test(NULL, child_dentry, file1);
 	KUNIT_ASSERT_EQ(test, err, 0);
 	KUNIT_EXPECT_EQ(test, root->info.indirect_levels, 1);
 	KUNIT_EXPECT_EQ(test, dx_get_count(root->entries), 1U);
 
 	/* Verify the newly inserted entry can be found in the 2-level tree */
-	found_bh = ext4_find_entry_test(dir, &child_dentry.d_name, &de, NULL);
+	found_bh = ext4_find_entry_test(dir, &child_dentry->d_name, &de, NULL);
 	KUNIT_ASSERT_FALSE(test, IS_ERR_OR_NULL(found_bh));
 	brelse(found_bh);
 
@@ -1745,10 +1750,10 @@ static void test_namei_dx_index_level_growth_and_fallback(struct kunit *test)
 		}
 		ext4_dx_csum_set_test(dir,
 				      (struct ext4_dir_entry *)bh0->b_data);
-		init_mock_dentry(&child_dentry, &parent_dentry,
+		init_mock_dentry(child_dentry, parent_dentry,
 				 "max_level_enospc", file1, &ctx->sb);
 		KUNIT_EXPECT_EQ(test,
-				ext4_add_entry_test(NULL, &child_dentry, file1),
+				ext4_add_entry_test(NULL, child_dentry, file1),
 				-ENOSPC);
 
 		/*
@@ -1760,10 +1765,10 @@ static void test_namei_dx_index_level_growth_and_fallback(struct kunit *test)
 		dx_set_block(root->entries + 0, 2);
 		ext4_dx_csum_set_test(dir,
 				      (struct ext4_dir_entry *)bh0->b_data);
-		init_mock_dentry(&child_dentry, &parent_dentry,
+		init_mock_dentry(child_dentry, parent_dentry,
 				 "interior_node_split", file1, &ctx->sb);
 		KUNIT_ASSERT_EQ(test,
-				ext4_add_entry_test(NULL, &child_dentry, file1),
+				ext4_add_entry_test(NULL, child_dentry, file1),
 				0);
 		KUNIT_EXPECT_EQ(test, root->info.indirect_levels, 1);
 		KUNIT_EXPECT_EQ(test, dx_get_count(root->entries), 2U);
@@ -1776,19 +1781,19 @@ static void test_namei_dx_index_level_growth_and_fallback(struct kunit *test)
 	 */
 	root->info.hash_version = 99;
 	ext4_dx_csum_set_test(dir, (struct ext4_dir_entry *)bh0->b_data);
-	init_mock_dentry(&child_dentry, &parent_dentry, "after_corrupt",
+	init_mock_dentry(child_dentry, parent_dentry, "after_corrupt",
 			 file1, &ctx->sb);
 	KUNIT_EXPECT_EQ(test,
-			ext4_add_entry_test(NULL, &child_dentry, file1),
+			ext4_add_entry_test(NULL, child_dentry, file1),
 			-EFSCORRUPTED);
 
 	/*
 	 * 2) __ext4_find_entry falls back to linear block scan on
 	 *    ERR_BAD_DX_DIR and still finds "leaf_00000" in block 1!
 	 */
-	init_mock_dentry(&child_dentry, &parent_dentry, "leaf_00000",
+	init_mock_dentry(child_dentry, parent_dentry, "leaf_00000",
 			 file1, &ctx->sb);
-	found_bh = ext4_find_entry_test(dir, &child_dentry.d_name, &de, NULL);
+	found_bh = ext4_find_entry_test(dir, &child_dentry->d_name, &de, NULL);
 	KUNIT_ASSERT_FALSE(test, IS_ERR_OR_NULL(found_bh));
 	KUNIT_EXPECT_EQ(test, le32_to_cpu(de->inode), TEST_FILE1_INO);
 	brelse(found_bh);
@@ -1799,10 +1804,10 @@ static void test_namei_dx_index_level_growth_and_fallback(struct kunit *test)
 	 */
 	ctx->es.s_feature_ro_compat &=
 		~cpu_to_le32(EXT4_FEATURE_RO_COMPAT_METADATA_CSUM);
-	init_mock_dentry(&child_dentry, &parent_dentry, "fallback_new_entry",
+	init_mock_dentry(child_dentry, parent_dentry, "fallback_new_entry",
 			 file1, &ctx->sb);
 	KUNIT_EXPECT_EQ(test,
-			ext4_add_entry_test(NULL, &child_dentry, file1), 0);
+			ext4_add_entry_test(NULL, child_dentry, file1), 0);
 	KUNIT_EXPECT_FALSE(test, ext4_test_inode_flag(dir, EXT4_INODE_INDEX));
 }
 
@@ -1821,10 +1826,13 @@ static void test_namei_inline_dir_lifecycle(struct kunit *test)
 	struct buffer_head *bh;
 	struct ext4_dir_entry_2 *de = NULL;
 	struct dir_private_info *dir_info;
-	struct file dir_file = {};
+	struct file *dir_file;
 	__u32 next_hash = 0;
 	int inlined = 0;
 
+	dir_file = kunit_kzalloc(test, sizeof(*dir_file), GFP_KERNEL);
+	KUNIT_ASSERT_NOT_NULL(test, dir_file);
+
 	ctx->es.s_feature_incompat |=
 		cpu_to_le32(EXT4_FEATURE_INCOMPAT_INLINE_DATA);
 	ext4_set_inode_state(dir, EXT4_STATE_MAY_INLINE_DATA);
@@ -1854,10 +1862,10 @@ static void test_namei_inline_dir_lifecycle(struct kunit *test)
 	/* Load inline directory into rb-tree via ext4_htree_fill_tree */
 	dir_info = kzalloc_obj(*dir_info);
 	KUNIT_ASSERT_NOT_NULL(test, dir_info);
-	dir_file.f_inode = dir;
-	dir_file.private_data = dir_info;
+	dir_file->f_inode = dir;
+	dir_file->private_data = dir_info;
 	KUNIT_EXPECT_EQ(test,
-			ext4_htree_fill_tree(&dir_file, 0, 0, &next_hash), 3);
+			ext4_htree_fill_tree(dir_file, 0, 0, &next_hash), 3);
 	KUNIT_EXPECT_EQ(test, next_hash, ~0U);
 	ext4_htree_free_dir_info(dir_info);
 
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ext4: kunit: reduce stack usage
  2026-12-01  9:14 [PATCH] ext4: kunit: reduce stack usage Arnd Bergmann
@ 2026-12-01  9:17 ` sashiko-bot
  2026-12-01 10:10 ` Jan Kara
  1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-12-01  9:17 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: linux-ext4, tytso

> From: Arnd Bergmann <arnd@arndb.de>
> 
> The new kunit tests trip my build bot testing with a slighly reduced
> stack frame warning size, as there are some very large structures
> on the stack:
> 
> arm-soc/fs/ext4/namei-test.c: In function 'test_namei_inline_dir_lifecycle':
> arm-soc/fs/ext4/namei-test.c:1870:1: error: the frame size of 1616 bytes is larger than 1536 bytes [-Werror=frame-larger-than=]
>  1870 | }
>       | ^
> fs/ext4/namei-test.c: In function 'test_namei_dx_index_level_growth_and_fallback':
> fs/ext4/namei-test.c:1807:1: error: the frame size of 1616 bytes is larger than 1536 bytes [-Werror=frame-larger-than=]
> 
> Change the largest ones to be dynamically allocated, as they
> are in a lot of the other functions.
> 
> Fixes: b82144c319f9 ("ext4: add KUnit tests for fs/ext4/namei.c")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261201091507.876226-1-arnd@kernel.org?part=1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ext4: kunit: reduce stack usage
  2026-12-01  9:14 [PATCH] ext4: kunit: reduce stack usage Arnd Bergmann
  2026-12-01  9:17 ` sashiko-bot
@ 2026-12-01 10:10 ` Jan Kara
  1 sibling, 0 replies; 3+ messages in thread
From: Jan Kara @ 2026-12-01 10:10 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Theodore Ts'o, Arnd Bergmann, Andreas Dilger, Baokun Li,
	Jan Kara, Ojaswin Mujoo, Ritesh Harjani (IBM), Zhang Yi,
	linux-ext4

On Tue 01-12-26 10:14:25, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> The new kunit tests trip my build bot testing with a slighly reduced
> stack frame warning size, as there are some very large structures
> on the stack:
> 
> arm-soc/fs/ext4/namei-test.c: In function 'test_namei_inline_dir_lifecycle':
> arm-soc/fs/ext4/namei-test.c:1870:1: error: the frame size of 1616 bytes is larger than 1536 bytes [-Werror=frame-larger-than=]
>  1870 | }
>       | ^
> fs/ext4/namei-test.c: In function 'test_namei_dx_index_level_growth_and_fallback':
> fs/ext4/namei-test.c:1807:1: error: the frame size of 1616 bytes is larger than 1536 bytes [-Werror=frame-larger-than=]
> 
> Change the largest ones to be dynamically allocated, as they
> are in a lot of the other functions.
> 
> Fixes: b82144c319f9 ("ext4: add KUnit tests for fs/ext4/namei.c")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/ext4/namei-test.c | 46 ++++++++++++++++++++++++++------------------
>  1 file changed, 27 insertions(+), 19 deletions(-)
> 
> diff --git a/fs/ext4/namei-test.c b/fs/ext4/namei-test.c
> index f0192135fcf2..07a0e4b73d94 100644
> --- a/fs/ext4/namei-test.c
> +++ b/fs/ext4/namei-test.c
> @@ -1603,18 +1603,23 @@ static void test_namei_dx_index_level_growth_and_fallback(struct kunit *test)
>  	struct inode *root_dir = get_mock_inode(ctx, TEST_ROOT_INO);
>  	struct inode *dir = get_mock_inode(ctx, TEST_DIR_INO);
>  	struct inode *file1 = get_mock_inode(ctx, TEST_FILE1_INO);
> -	struct dentry parent_dentry, child_dentry;
> +	struct dentry *parent_dentry, *child_dentry;
>  	struct buffer_head *bh0, *bh1, *found_bh;
>  	struct dx_root *root;
>  	struct ext4_dir_entry_2 *de = NULL;
>  	unsigned int root_limit;
>  	int i, err;
>  
> +	parent_dentry = kunit_kzalloc(test, sizeof(*parent_dentry), GFP_KERNEL);
> +	KUNIT_ASSERT_NOT_NULL(test, parent_dentry);
> +	child_dentry = kunit_kzalloc(test, sizeof(*child_dentry), GFP_KERNEL);
> +	KUNIT_ASSERT_NOT_NULL(test, child_dentry);
> +
>  	ctx->es.s_feature_ro_compat |=
>  		cpu_to_le32(EXT4_FEATURE_RO_COMPAT_METADATA_CSUM);
>  
>  	KUNIT_ASSERT_EQ(test, ext4_init_new_dir(NULL, root_dir, dir), 0);
> -	init_mock_dentry(&parent_dentry, NULL, "dir", dir, &ctx->sb);
> +	init_mock_dentry(parent_dentry, NULL, "dir", dir, &ctx->sb);
>  
>  	/* Set up a 1-level HTree where root->entries is completely full */
>  	ext4_set_inode_flag(dir, EXT4_INODE_INDEX);
> @@ -1668,15 +1673,15 @@ static void test_namei_dx_index_level_growth_and_fallback(struct kunit *test)
>  	 * full (count == limit), triggering the add_level branch in
>  	 * ext4_dx_add_entry (indirect_levels: 0 -> 1).
>  	 */
> -	init_mock_dentry(&child_dentry, &parent_dentry, "trigger_split_entry",
> +	init_mock_dentry(child_dentry, parent_dentry, "trigger_split_entry",
>  			 file1, &ctx->sb);
> -	err = ext4_add_entry_test(NULL, &child_dentry, file1);
> +	err = ext4_add_entry_test(NULL, child_dentry, file1);
>  	KUNIT_ASSERT_EQ(test, err, 0);
>  	KUNIT_EXPECT_EQ(test, root->info.indirect_levels, 1);
>  	KUNIT_EXPECT_EQ(test, dx_get_count(root->entries), 1U);
>  
>  	/* Verify the newly inserted entry can be found in the 2-level tree */
> -	found_bh = ext4_find_entry_test(dir, &child_dentry.d_name, &de, NULL);
> +	found_bh = ext4_find_entry_test(dir, &child_dentry->d_name, &de, NULL);
>  	KUNIT_ASSERT_FALSE(test, IS_ERR_OR_NULL(found_bh));
>  	brelse(found_bh);
>  
> @@ -1745,10 +1750,10 @@ static void test_namei_dx_index_level_growth_and_fallback(struct kunit *test)
>  		}
>  		ext4_dx_csum_set_test(dir,
>  				      (struct ext4_dir_entry *)bh0->b_data);
> -		init_mock_dentry(&child_dentry, &parent_dentry,
> +		init_mock_dentry(child_dentry, parent_dentry,
>  				 "max_level_enospc", file1, &ctx->sb);
>  		KUNIT_EXPECT_EQ(test,
> -				ext4_add_entry_test(NULL, &child_dentry, file1),
> +				ext4_add_entry_test(NULL, child_dentry, file1),
>  				-ENOSPC);
>  
>  		/*
> @@ -1760,10 +1765,10 @@ static void test_namei_dx_index_level_growth_and_fallback(struct kunit *test)
>  		dx_set_block(root->entries + 0, 2);
>  		ext4_dx_csum_set_test(dir,
>  				      (struct ext4_dir_entry *)bh0->b_data);
> -		init_mock_dentry(&child_dentry, &parent_dentry,
> +		init_mock_dentry(child_dentry, parent_dentry,
>  				 "interior_node_split", file1, &ctx->sb);
>  		KUNIT_ASSERT_EQ(test,
> -				ext4_add_entry_test(NULL, &child_dentry, file1),
> +				ext4_add_entry_test(NULL, child_dentry, file1),
>  				0);
>  		KUNIT_EXPECT_EQ(test, root->info.indirect_levels, 1);
>  		KUNIT_EXPECT_EQ(test, dx_get_count(root->entries), 2U);
> @@ -1776,19 +1781,19 @@ static void test_namei_dx_index_level_growth_and_fallback(struct kunit *test)
>  	 */
>  	root->info.hash_version = 99;
>  	ext4_dx_csum_set_test(dir, (struct ext4_dir_entry *)bh0->b_data);
> -	init_mock_dentry(&child_dentry, &parent_dentry, "after_corrupt",
> +	init_mock_dentry(child_dentry, parent_dentry, "after_corrupt",
>  			 file1, &ctx->sb);
>  	KUNIT_EXPECT_EQ(test,
> -			ext4_add_entry_test(NULL, &child_dentry, file1),
> +			ext4_add_entry_test(NULL, child_dentry, file1),
>  			-EFSCORRUPTED);
>  
>  	/*
>  	 * 2) __ext4_find_entry falls back to linear block scan on
>  	 *    ERR_BAD_DX_DIR and still finds "leaf_00000" in block 1!
>  	 */
> -	init_mock_dentry(&child_dentry, &parent_dentry, "leaf_00000",
> +	init_mock_dentry(child_dentry, parent_dentry, "leaf_00000",
>  			 file1, &ctx->sb);
> -	found_bh = ext4_find_entry_test(dir, &child_dentry.d_name, &de, NULL);
> +	found_bh = ext4_find_entry_test(dir, &child_dentry->d_name, &de, NULL);
>  	KUNIT_ASSERT_FALSE(test, IS_ERR_OR_NULL(found_bh));
>  	KUNIT_EXPECT_EQ(test, le32_to_cpu(de->inode), TEST_FILE1_INO);
>  	brelse(found_bh);
> @@ -1799,10 +1804,10 @@ static void test_namei_dx_index_level_growth_and_fallback(struct kunit *test)
>  	 */
>  	ctx->es.s_feature_ro_compat &=
>  		~cpu_to_le32(EXT4_FEATURE_RO_COMPAT_METADATA_CSUM);
> -	init_mock_dentry(&child_dentry, &parent_dentry, "fallback_new_entry",
> +	init_mock_dentry(child_dentry, parent_dentry, "fallback_new_entry",
>  			 file1, &ctx->sb);
>  	KUNIT_EXPECT_EQ(test,
> -			ext4_add_entry_test(NULL, &child_dentry, file1), 0);
> +			ext4_add_entry_test(NULL, child_dentry, file1), 0);
>  	KUNIT_EXPECT_FALSE(test, ext4_test_inode_flag(dir, EXT4_INODE_INDEX));
>  }
>  
> @@ -1821,10 +1826,13 @@ static void test_namei_inline_dir_lifecycle(struct kunit *test)
>  	struct buffer_head *bh;
>  	struct ext4_dir_entry_2 *de = NULL;
>  	struct dir_private_info *dir_info;
> -	struct file dir_file = {};
> +	struct file *dir_file;
>  	__u32 next_hash = 0;
>  	int inlined = 0;
>  
> +	dir_file = kunit_kzalloc(test, sizeof(*dir_file), GFP_KERNEL);
> +	KUNIT_ASSERT_NOT_NULL(test, dir_file);
> +
>  	ctx->es.s_feature_incompat |=
>  		cpu_to_le32(EXT4_FEATURE_INCOMPAT_INLINE_DATA);
>  	ext4_set_inode_state(dir, EXT4_STATE_MAY_INLINE_DATA);
> @@ -1854,10 +1862,10 @@ static void test_namei_inline_dir_lifecycle(struct kunit *test)
>  	/* Load inline directory into rb-tree via ext4_htree_fill_tree */
>  	dir_info = kzalloc_obj(*dir_info);
>  	KUNIT_ASSERT_NOT_NULL(test, dir_info);
> -	dir_file.f_inode = dir;
> -	dir_file.private_data = dir_info;
> +	dir_file->f_inode = dir;
> +	dir_file->private_data = dir_info;
>  	KUNIT_EXPECT_EQ(test,
> -			ext4_htree_fill_tree(&dir_file, 0, 0, &next_hash), 3);
> +			ext4_htree_fill_tree(dir_file, 0, 0, &next_hash), 3);
>  	KUNIT_EXPECT_EQ(test, next_hash, ~0U);
>  	ext4_htree_free_dir_info(dir_info);
>  
> -- 
> 2.53.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-12-01 10:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01  9:14 [PATCH] ext4: kunit: reduce stack usage Arnd Bergmann
2026-12-01  9:17 ` sashiko-bot
2026-12-01 10:10 ` Jan Kara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox