From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796116514; b=EpnFm8rrfOVW//lqaUCTgevquCPtGl1YAHCYkIop5Y2oD5PR94TjxBfJuQQHCjOqRFBa cT8B/KC3CfTFAHt/7Qwmi452HjVH57QzP2Gt6n/XXN5JW6Z39BrdwSxyKkg+8gyZa7Yze Ll3lFT2t/WYR7b9zRD3TZDzvi+j1tkO+gdO9VI+yfTF47S5mkU6+qZ/tm/Oqm8+I6HXS7 TDYMUPYuCvNHOQB9TI4dyjCFya9JfSdsHlsF7fmORArctVPoi7P2yQHDTNwJb4k/YHyiB nF/nUQ6p/Fx5ys3j7b+4DWcGSfYNTdZKULhN4Gd7arHwLcu1v53HAas+a81bNgIDfEA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796116514; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: MIME-Version:Content-Transfer-Encoding; bh=i0uUp/DQc1iDxi0I5CVud/zKALu4ihPixXBRvNEXepg=; b=riuHQvyXqKg95rZXjWjSmyOFFDyyPTYVA7b7reUcbz6SkIhF4sSKYySGDCR4dvJm5fo7 dfgF1b3oMjbRJ7OGCw4pgJK01F/R7QzAafYzSXFo/3RJ2r9ASEzBHQ4uckV3/d74sbBaQ iV6Lp39KEg65lNgWFLcMWfdxa94RuOAxU2NnStjUNkoMBpov7ZlAvFN5nHRZK8Rt0LQ9D PK4UTldETSpx8QDVwheX7dBZh/odylC2Z427daVHCDy/OmfHp+oOtJyF8fl1tbjKAuceo ToJOe+fnhnd28cJMSz5Ls8eNzyu/pax5pjbr9CihE4QdpyHDCQe5vCuFkPwobLFMEIw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=W5K+ZXfm; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6FEBF606A327 for ; Tue, 1 Dec 2026 09:15:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=W5K+ZXfm Received: by smtp.kernel.org (Postfix) with ESMTPSA id 446AD1F000C1; Tue, 1 Dec 2026 09:15:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796116514; bh=i0uUp/DQc1iDxi0I5CVud/zKALu4ihPixXBRvNEXepg=; h=From:To:Cc:Subject:Date; b=W5K+ZXfm69nchbq4y60sX2MRgXQ5xI4uikNECDn2ZR+OVsSeIeHHSHp6z05Y97NQJ +Ut9y5l81i4/C5YLZ2zsS9GA01GN7PwEc+iQ2wJ4mlc36pt/7JOTlXbvnB6yasEdbZ De6XL62yjJIdpcr3IBWAJxktGZ0v/L2sDjmpRhopnk366eQmN4+Wc04R9LemQtQyVD /MPhAQWbI6X3JnDq97C2qD3vBKf9Ze5NVQJ9PCPyBwWl9yCMbO2g6OFHCESwdViILb JQRbCirdSZnPvtKJdo9JK7rlY2iiqtD3vrXYvl7fyBLmB9f3Y31psSYP94CI6iJoNg 2OjD2/QwRAY0Q== From: Arnd Bergmann To: "Theodore Ts'o" Cc: Arnd Bergmann , Andreas Dilger , Baokun Li , Jan Kara , Ojaswin Mujoo , "Ritesh Harjani (IBM)" , Zhang Yi , linux-ext4@vger.kernel.org Subject: [PATCH] ext4: kunit: reduce stack usage Date: Tue, 1 Dec 2026 10:14:25 +0100 Message-ID: <20261201091507.876226-1-arnd@kernel.org> X-Mailer: git-send-email 2.53.0 X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Arnd Bergmann 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 --- 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