* [PATCH] kernel/fork: Increase minimum number of allowed threads
@ 2025-07-11 23:03 Hauke Mehrtens
2025-07-11 23:06 ` Hauke Mehrtens
0 siblings, 1 reply; 3+ messages in thread
From: Hauke Mehrtens @ 2025-07-11 23:03 UTC (permalink / raw)
To: sashal, linux-kernel
Cc: frederic, david, viro, paulmck, Greg Kroah-Hartman, stable,
Hauke Mehrtens
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
A modern Linux system creates much more than 20 threads at bootup.
When I booted up OpenWrt in qemu the system sometimes failed to boot up
when it wanted to create the 419th thread. The VM had 128MB RAM and the
calculation in set_max_threads() calculated that max_threads should be
set to 419. When the system booted up it tried to notify the user space
about every device it created because CONFIG_UEVENT_HELPER was set and
used. I counted 1299 calles to call_usermodehelper_setup(), all of
them try to create a new thread and call the userspace hotplug script in
it.
This fixes bootup of Linux on systems with low memory.
I saw the problem with qemu 10.0.2 using these commands:
qemu-system-aarch64 -machine virt -cpu cortex-a57 -nographic
Cc: stable@vger.kernel.org
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
kernel/fork.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/fork.c b/kernel/fork.c
index 7966c9a1c163..388299525f3c 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -115,7 +115,7 @@
/*
* Minimum number of threads to boot the kernel
*/
-#define MIN_THREADS 20
+#define MIN_THREADS 600
/*
* Maximum number of threads
--
2.50.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] kernel/fork: Increase minimum number of allowed threads
2025-07-11 23:03 [PATCH] kernel/fork: Increase minimum number of allowed threads Hauke Mehrtens
@ 2025-07-11 23:06 ` Hauke Mehrtens
2025-07-16 11:46 ` David Laight
0 siblings, 1 reply; 3+ messages in thread
From: Hauke Mehrtens @ 2025-07-11 23:06 UTC (permalink / raw)
To: sashal, linux-kernel
Cc: frederic, david, viro, paulmck, Greg Kroah-Hartman, stable
On 7/12/25 01:03, Hauke Mehrtens wrote:
> From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Sorry this has the wrong from tag, will send a new patch.
Hauke>
> A modern Linux system creates much more than 20 threads at bootup.
> When I booted up OpenWrt in qemu the system sometimes failed to boot up
> when it wanted to create the 419th thread. The VM had 128MB RAM and the
> calculation in set_max_threads() calculated that max_threads should be
> set to 419. When the system booted up it tried to notify the user space
> about every device it created because CONFIG_UEVENT_HELPER was set and
> used. I counted 1299 calles to call_usermodehelper_setup(), all of
> them try to create a new thread and call the userspace hotplug script in
> it.
>
> This fixes bootup of Linux on systems with low memory.
>
> I saw the problem with qemu 10.0.2 using these commands:
> qemu-system-aarch64 -machine virt -cpu cortex-a57 -nographic
>
> Cc: stable@vger.kernel.org
> Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
> ---
> kernel/fork.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/fork.c b/kernel/fork.c
> index 7966c9a1c163..388299525f3c 100644
> --- a/kernel/fork.c
> +++ b/kernel/fork.c
> @@ -115,7 +115,7 @@
> /*
> * Minimum number of threads to boot the kernel
> */
> -#define MIN_THREADS 20
> +#define MIN_THREADS 600
>
> /*
> * Maximum number of threads
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] kernel/fork: Increase minimum number of allowed threads
2025-07-11 23:06 ` Hauke Mehrtens
@ 2025-07-16 11:46 ` David Laight
0 siblings, 0 replies; 3+ messages in thread
From: David Laight @ 2025-07-16 11:46 UTC (permalink / raw)
To: Hauke Mehrtens
Cc: sashal, linux-kernel, frederic, david, viro, paulmck,
Greg Kroah-Hartman, stable
On Sat, 12 Jul 2025 01:06:07 +0200
Hauke Mehrtens <hauke@hauke-m.de> wrote:
> On 7/12/25 01:03, Hauke Mehrtens wrote:
> > From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>
> Sorry this has the wrong from tag, will send a new patch.
>
> Hauke>
> > A modern Linux system creates much more than 20 threads at bootup.
> > When I booted up OpenWrt in qemu the system sometimes failed to boot up
> > when it wanted to create the 419th thread. The VM had 128MB RAM and the
> > calculation in set_max_threads() calculated that max_threads should be
> > set to 419. When the system booted up it tried to notify the user space
> > about every device it created because CONFIG_UEVENT_HELPER was set and
> > used. I counted 1299 calles to call_usermodehelper_setup(), all of
> > them try to create a new thread and call the userspace hotplug script in
> > it.
> >
> > This fixes bootup of Linux on systems with low memory.
I bet it doesn't - it is likely to fail somewhere else instead.
While 20 is probably too low, the real issue seems to be that
the hotplug notifications need rate limiting.
David
> >
> > I saw the problem with qemu 10.0.2 using these commands:
> > qemu-system-aarch64 -machine virt -cpu cortex-a57 -nographic
> >
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
> > ---
> > kernel/fork.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/kernel/fork.c b/kernel/fork.c
> > index 7966c9a1c163..388299525f3c 100644
> > --- a/kernel/fork.c
> > +++ b/kernel/fork.c
> > @@ -115,7 +115,7 @@
> > /*
> > * Minimum number of threads to boot the kernel
> > */
> > -#define MIN_THREADS 20
> > +#define MIN_THREADS 600
> >
> > /*
> > * Maximum number of threads
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-07-16 11:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-11 23:03 [PATCH] kernel/fork: Increase minimum number of allowed threads Hauke Mehrtens
2025-07-11 23:06 ` Hauke Mehrtens
2025-07-16 11:46 ` David Laight
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).