Skip to contentSkip to conversation

initramfs_test: mark testcases as __refdata

PATCH In review Arnd Bergmann 2 participants 2 messages Mar 5, 2025 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 initramfs_test: mark testcases as __refdata

From: Arnd Bergmann <[email protected]>

The testcase calls an __init function, so it must have a corresponding annotation:

WARNING: modpost: vmlinux: section mismatch in reference: initramfs_test_cases+0x0 (section: .data) -> initramfs_test_extract (section: .init.text)

As with other kunit tests, using __refdata suppresses the warning without annotating the structure itself as __initdata.

Fixes b6736cfccb58 ("initramfs_test: kunit tests for initramfs unpacking")
---
 init/initramfs_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
init/initramfs_test.c +1 -1
index 6231fe012583..3539891ae081 100644
@@ -387,7 +387,7 @@ static void __init initramfs_test_many(struct kunit *test)
  * The kunit_case/_suite struct cannot be marked as __initdata as this will be
  * used in debugfs to retrieve results after test has run.
  */
-static struct kunit_case initramfs_test_cases[] = {
+static struct kunit_case initramfs_test_cases[] __refdata = {
 	KUNIT_CASE(initramfs_test_extract),
 	KUNIT_CASE(initramfs_test_fname_overrun),
 	KUNIT_CASE(initramfs_test_data),
Signature · 1 line
2.39.5
#1 lore raw

Hi Arnd,

Thanks for the patch. A fix for this was already submitted via:
https://lore.kernel.org/linux-fsdevel/[email protected]/T/#u

Quoted 29 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The testcase calls an __init function, so it must have a corresponding annotation:

WARNING: modpost: vmlinux: section mismatch in reference: initramfs_test_cases+0x0 (section: .data) -> initramfs_test_extract (section: .init.text)

As with other kunit tests, using __refdata suppresses the warning without annotating the structure itself as __initdata.

Fixes b6736cfccb58 ("initramfs_test: kunit tests for initramfs unpacking")
---
 init/initramfs_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
init/initramfs_test.c +1 -1
index 6231fe012583..3539891ae081 100644
@@ -387,7 +387,7 @@ static void __init initramfs_test_many(struct kunit *test)
  * The kunit_case/_suite struct cannot be marked as __initdata as this will be
  * used in debugfs to retrieve results after test has run.
  */
-static struct kunit_case initramfs_test_cases[] = {
+static struct kunit_case initramfs_test_cases[] __refdata = {
 	KUNIT_CASE(initramfs_test_extract),
 	KUNIT_CASE(initramfs_test_fname_overrun),
 	KUNIT_CASE(initramfs_test_data),