linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] lib/test_vmalloc.c: Use late_initcall() if built-in for init ordering
@ 2025-06-23 18:40 Uladzislau Rezki (Sony)
  2025-06-23 18:40 ` [PATCH 2/2] lib/test_vmalloc.c: Restrict default test mask to avoid test warnings Uladzislau Rezki (Sony)
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Uladzislau Rezki (Sony) @ 2025-06-23 18:40 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-mm, LKML, Baoquan He, Uladzislau Rezki, Harry Yoo,
	Suren Baghdasaryan, David Wang

When the vmalloc test code is compiled as a built-in, use late_initcall()
instead of module_init() to defer a vmalloc test execution until most
subsystems are up and running.

It avoids interfering with components that may not yet be initialized
at module_init() time. For example, there was a recent report of memory
profiling infrastructure not being ready early enough leading to kernel
crash.

By using late_initcall() in the built-in case, we ensure the tests are
run at a safer point during a boot sequence.

Cc: Harry Yoo <harry.yoo@oracle.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: David Wang <00107082@163.com>
Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
---
 lib/test_vmalloc.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/test_vmalloc.c b/lib/test_vmalloc.c
index 1b0b59549aaf1..7264781750c96 100644
--- a/lib/test_vmalloc.c
+++ b/lib/test_vmalloc.c
@@ -598,7 +598,11 @@ static int __init vmalloc_test_init(void)
 	return IS_BUILTIN(CONFIG_TEST_VMALLOC) ? 0:-EAGAIN;
 }
 
+#ifdef MODULE
 module_init(vmalloc_test_init)
+#else
+late_initcall(vmalloc_test_init);
+#endif
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Uladzislau Rezki");
-- 
2.39.5



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

* [PATCH 2/2] lib/test_vmalloc.c: Restrict default test mask to avoid test warnings
  2025-06-23 18:40 [PATCH 1/2] lib/test_vmalloc.c: Use late_initcall() if built-in for init ordering Uladzislau Rezki (Sony)
@ 2025-06-23 18:40 ` Uladzislau Rezki (Sony)
  2025-06-24  9:34   ` Baoquan He
  2025-06-24  8:30 ` [PATCH 1/2] lib/test_vmalloc.c: Use late_initcall() if built-in for init ordering Baoquan He
  2025-06-24  9:07 ` David Wang
  2 siblings, 1 reply; 6+ messages in thread
From: Uladzislau Rezki (Sony) @ 2025-06-23 18:40 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-mm, LKML, Baoquan He, Uladzislau Rezki, Harry Yoo,
	Suren Baghdasaryan, David Wang

When the vmalloc test is built into the kernel, it runs automatically
during the boot. The current-default "run_test_mask" includes all test
cases, including those which are designed to fail and which trigger
kernel warnings.

These kernel splats can be misinterpreted as actual kernel bugs, leading
to false alarms and unnecessary reports.

To address this, limit the default test mask to only the first few tests
which are expected to pass cleanly. These tests are safe and should not
generate any warnings unless there is a real bug.

Users who wish to explicitly run specific test cases have to pass the
run_test_mask as a boot parameter or at module load time.

Cc: Harry Yoo <harry.yoo@oracle.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: David Wang <00107082@163.com>
Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
---
 lib/test_vmalloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/test_vmalloc.c b/lib/test_vmalloc.c
index 7264781750c96..c1966cf72ab89 100644
--- a/lib/test_vmalloc.c
+++ b/lib/test_vmalloc.c
@@ -41,7 +41,7 @@ __param(int, nr_pages, 0,
 __param(bool, use_huge, false,
 	"Use vmalloc_huge in fix_size_alloc_test");
 
-__param(int, run_test_mask, INT_MAX,
+__param(int, run_test_mask, 7,
 	"Set tests specified in the mask.\n\n"
 		"\t\tid: 1,    name: fix_size_alloc_test\n"
 		"\t\tid: 2,    name: full_fit_alloc_test\n"
-- 
2.39.5



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

* Re: [PATCH 1/2] lib/test_vmalloc.c: Use late_initcall() if built-in for init ordering
  2025-06-23 18:40 [PATCH 1/2] lib/test_vmalloc.c: Use late_initcall() if built-in for init ordering Uladzislau Rezki (Sony)
  2025-06-23 18:40 ` [PATCH 2/2] lib/test_vmalloc.c: Restrict default test mask to avoid test warnings Uladzislau Rezki (Sony)
@ 2025-06-24  8:30 ` Baoquan He
  2025-06-24  9:07 ` David Wang
  2 siblings, 0 replies; 6+ messages in thread
From: Baoquan He @ 2025-06-24  8:30 UTC (permalink / raw)
  To: Uladzislau Rezki (Sony)
  Cc: Andrew Morton, linux-mm, LKML, Harry Yoo, Suren Baghdasaryan,
	David Wang

On 06/23/25 at 08:40pm, Uladzislau Rezki (Sony) wrote:
> When the vmalloc test code is compiled as a built-in, use late_initcall()
> instead of module_init() to defer a vmalloc test execution until most
> subsystems are up and running.
> 
> It avoids interfering with components that may not yet be initialized
> at module_init() time. For example, there was a recent report of memory
> profiling infrastructure not being ready early enough leading to kernel
> crash.
> 
> By using late_initcall() in the built-in case, we ensure the tests are
> run at a safer point during a boot sequence.
> 
> Cc: Harry Yoo <harry.yoo@oracle.com>
> Cc: Suren Baghdasaryan <surenb@google.com>
> Cc: David Wang <00107082@163.com>
> Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
> ---
>  lib/test_vmalloc.c | 4 ++++
>  1 file changed, 4 insertions(+)

LGTM,

Reviewed-by: Baoquan He <bhe@redhat.com>

> 
> diff --git a/lib/test_vmalloc.c b/lib/test_vmalloc.c
> index 1b0b59549aaf1..7264781750c96 100644
> --- a/lib/test_vmalloc.c
> +++ b/lib/test_vmalloc.c
> @@ -598,7 +598,11 @@ static int __init vmalloc_test_init(void)
>  	return IS_BUILTIN(CONFIG_TEST_VMALLOC) ? 0:-EAGAIN;
>  }
>  
> +#ifdef MODULE
>  module_init(vmalloc_test_init)
> +#else
> +late_initcall(vmalloc_test_init);
> +#endif
>  
>  MODULE_LICENSE("GPL");
>  MODULE_AUTHOR("Uladzislau Rezki");
> -- 
> 2.39.5
> 
> 



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

* Re:[PATCH 1/2] lib/test_vmalloc.c: Use late_initcall() if built-in for init ordering
  2025-06-23 18:40 [PATCH 1/2] lib/test_vmalloc.c: Use late_initcall() if built-in for init ordering Uladzislau Rezki (Sony)
  2025-06-23 18:40 ` [PATCH 2/2] lib/test_vmalloc.c: Restrict default test mask to avoid test warnings Uladzislau Rezki (Sony)
  2025-06-24  8:30 ` [PATCH 1/2] lib/test_vmalloc.c: Use late_initcall() if built-in for init ordering Baoquan He
@ 2025-06-24  9:07 ` David Wang
  2025-06-24 11:42   ` [PATCH " Uladzislau Rezki
  2 siblings, 1 reply; 6+ messages in thread
From: David Wang @ 2025-06-24  9:07 UTC (permalink / raw)
  To: Uladzislau Rezki (Sony)
  Cc: Andrew Morton, linux-mm, LKML, Baoquan He, Harry Yoo,
	Suren Baghdasaryan


At 2025-06-24 02:40:34, "Uladzislau Rezki (Sony)" <urezki@gmail.com> wrote:
>When the vmalloc test code is compiled as a built-in, use late_initcall()
>instead of module_init() to defer a vmalloc test execution until most
>subsystems are up and running.
>
>It avoids interfering with components that may not yet be initialized
>at module_init() time. For example, there was a recent report of memory
>profiling infrastructure not being ready early enough leading to kernel
>crash.
>
>By using late_initcall() in the built-in case, we ensure the tests are
>run at a safer point during a boot sequence.
>
>Cc: Harry Yoo <harry.yoo@oracle.com>
>Cc: Suren Baghdasaryan <surenb@google.com>
>Cc: David Wang <00107082@163.com>
>Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
>---
> lib/test_vmalloc.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
>diff --git a/lib/test_vmalloc.c b/lib/test_vmalloc.c
>index 1b0b59549aaf1..7264781750c96 100644
>--- a/lib/test_vmalloc.c
>+++ b/lib/test_vmalloc.c
>@@ -598,7 +598,11 @@ static int __init vmalloc_test_init(void)
> 	return IS_BUILTIN(CONFIG_TEST_VMALLOC) ? 0:-EAGAIN;
> }
> 
>+#ifdef MODULE
> module_init(vmalloc_test_init)
>+#else
>+late_initcall(vmalloc_test_init);

>+#endif


When MODULE defined,  late_initcall is defined as module_init in ./include/linux/module.h
I think the MODULE check here is redundant,  (it is clearer though)




> 
> MODULE_LICENSE("GPL");
> MODULE_AUTHOR("Uladzislau Rezki");
>-- 
>2.39.5

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

* Re: [PATCH 2/2] lib/test_vmalloc.c: Restrict default test mask to avoid test warnings
  2025-06-23 18:40 ` [PATCH 2/2] lib/test_vmalloc.c: Restrict default test mask to avoid test warnings Uladzislau Rezki (Sony)
@ 2025-06-24  9:34   ` Baoquan He
  0 siblings, 0 replies; 6+ messages in thread
From: Baoquan He @ 2025-06-24  9:34 UTC (permalink / raw)
  To: Uladzislau Rezki (Sony)
  Cc: Andrew Morton, linux-mm, LKML, Harry Yoo, Suren Baghdasaryan,
	David Wang

On 06/23/25 at 08:40pm, Uladzislau Rezki (Sony) wrote:
> When the vmalloc test is built into the kernel, it runs automatically
> during the boot. The current-default "run_test_mask" includes all test
> cases, including those which are designed to fail and which trigger
> kernel warnings.
> 
> These kernel splats can be misinterpreted as actual kernel bugs, leading
> to false alarms and unnecessary reports.
> 
> To address this, limit the default test mask to only the first few tests
> which are expected to pass cleanly. These tests are safe and should not
> generate any warnings unless there is a real bug.
> 
> Users who wish to explicitly run specific test cases have to pass the
> run_test_mask as a boot parameter or at module load time.
> 
> Cc: Harry Yoo <harry.yoo@oracle.com>
> Cc: Suren Baghdasaryan <surenb@google.com>
> Cc: David Wang <00107082@163.com>
> Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
> ---
>  lib/test_vmalloc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Baoquan He <bhe@redhat.com>

> 
> diff --git a/lib/test_vmalloc.c b/lib/test_vmalloc.c
> index 7264781750c96..c1966cf72ab89 100644
> --- a/lib/test_vmalloc.c
> +++ b/lib/test_vmalloc.c
> @@ -41,7 +41,7 @@ __param(int, nr_pages, 0,
>  __param(bool, use_huge, false,
>  	"Use vmalloc_huge in fix_size_alloc_test");
>  
> -__param(int, run_test_mask, INT_MAX,
> +__param(int, run_test_mask, 7,
>  	"Set tests specified in the mask.\n\n"
>  		"\t\tid: 1,    name: fix_size_alloc_test\n"
>  		"\t\tid: 2,    name: full_fit_alloc_test\n"
> -- 
> 2.39.5
> 



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

* Re: [PATCH 1/2] lib/test_vmalloc.c: Use late_initcall() if built-in for init ordering
  2025-06-24  9:07 ` David Wang
@ 2025-06-24 11:42   ` Uladzislau Rezki
  0 siblings, 0 replies; 6+ messages in thread
From: Uladzislau Rezki @ 2025-06-24 11:42 UTC (permalink / raw)
  To: David Wang
  Cc: Uladzislau Rezki (Sony), Andrew Morton, linux-mm, LKML,
	Baoquan He, Harry Yoo, Suren Baghdasaryan

On Tue, Jun 24, 2025 at 05:07:15PM +0800, David Wang wrote:
> 
> At 2025-06-24 02:40:34, "Uladzislau Rezki (Sony)" <urezki@gmail.com> wrote:
> >When the vmalloc test code is compiled as a built-in, use late_initcall()
> >instead of module_init() to defer a vmalloc test execution until most
> >subsystems are up and running.
> >
> >It avoids interfering with components that may not yet be initialized
> >at module_init() time. For example, there was a recent report of memory
> >profiling infrastructure not being ready early enough leading to kernel
> >crash.
> >
> >By using late_initcall() in the built-in case, we ensure the tests are
> >run at a safer point during a boot sequence.
> >
> >Cc: Harry Yoo <harry.yoo@oracle.com>
> >Cc: Suren Baghdasaryan <surenb@google.com>
> >Cc: David Wang <00107082@163.com>
> >Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
> >---
> > lib/test_vmalloc.c | 4 ++++
> > 1 file changed, 4 insertions(+)
> >
> >diff --git a/lib/test_vmalloc.c b/lib/test_vmalloc.c
> >index 1b0b59549aaf1..7264781750c96 100644
> >--- a/lib/test_vmalloc.c
> >+++ b/lib/test_vmalloc.c
> >@@ -598,7 +598,11 @@ static int __init vmalloc_test_init(void)
> > 	return IS_BUILTIN(CONFIG_TEST_VMALLOC) ? 0:-EAGAIN;
> > }
> > 
> >+#ifdef MODULE
> > module_init(vmalloc_test_init)
> >+#else
> >+late_initcall(vmalloc_test_init);
> 
> >+#endif
> 
> 
> When MODULE defined,  late_initcall is defined as module_init in ./include/linux/module.h
> I think the MODULE check here is redundant,  (it is clearer though)
> 
That was an idea to use MODULE, because late_initcall is designed not
for module.s It would require the comment then.

--
Uladzislau Rezki


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

end of thread, other threads:[~2025-06-24 11:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-23 18:40 [PATCH 1/2] lib/test_vmalloc.c: Use late_initcall() if built-in for init ordering Uladzislau Rezki (Sony)
2025-06-23 18:40 ` [PATCH 2/2] lib/test_vmalloc.c: Restrict default test mask to avoid test warnings Uladzislau Rezki (Sony)
2025-06-24  9:34   ` Baoquan He
2025-06-24  8:30 ` [PATCH 1/2] lib/test_vmalloc.c: Use late_initcall() if built-in for init ordering Baoquan He
2025-06-24  9:07 ` David Wang
2025-06-24 11:42   ` [PATCH " Uladzislau Rezki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).