All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@kernel.org>
To: "Theodore Ts'o" <tytso@mit.edu>
Cc: Arnd Bergmann <arnd@arndb.de>,
	Andreas Dilger <adilger.kernel@dilger.ca>,
	Baokun Li <libaokun@linux.alibaba.com>, Jan Kara <jack@suse.cz>,
	Ojaswin Mujoo <ojaswin@linux.ibm.com>,
	"Ritesh Harjani (IBM)" <ritesh.list@gmail.com>,
	Zhang Yi <yi.zhang@huawei.com>,
	linux-ext4@vger.kernel.org
Subject: [PATCH] ext4: kunit: reduce stack usage
Date: Tue,  1 Dec 2026 10:14:25 +0100	[thread overview]
Message-ID: <20261201091507.876226-1-arnd@kernel.org> (raw)

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


             reply	other threads:[~2026-12-01  9:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01  9:14 Arnd Bergmann [this message]
2026-12-01  9:17 ` [PATCH] ext4: kunit: reduce stack usage sashiko-bot
2026-12-01 10:10 ` Jan Kara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261201091507.876226-1-arnd@kernel.org \
    --to=arnd@kernel.org \
    --cc=adilger.kernel@dilger.ca \
    --cc=arnd@arndb.de \
    --cc=jack@suse.cz \
    --cc=libaokun@linux.alibaba.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=ojaswin@linux.ibm.com \
    --cc=ritesh.list@gmail.com \
    --cc=tytso@mit.edu \
    --cc=yi.zhang@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.