From: David Laight <david.laight.linux@gmail.com>
To: Jiri Slaby <jirislaby@kernel.org>
Cc: Hauke Mehrtens <hauke@hauke-m.de>,
sashal@kernel.org, linux-kernel@vger.kernel.org,
frederic@kernel.org, david@redhat.com, viro@zeniv.linux.org.uk,
paulmck@kernel.org, stable@vger.kernel.org,
Tejun Heo <tj@kernel.org>, Lai Jiangshan <jiangshanlai@gmail.com>,
"Luis R . Rodriguez" <mcgrof@kernel.org>
Subject: Re: [PATCH v2] kernel/fork: Increase minimum number of allowed threads
Date: Thu, 17 Jul 2025 22:34:32 +0100 [thread overview]
Message-ID: <20250717223432.2a74e870@pumpkin> (raw)
In-Reply-To: <48e6e92d-6b6a-4850-9396-f3afa327ca3a@kernel.org>
On Thu, 17 Jul 2025 07:26:59 +0200
Jiri Slaby <jirislaby@kernel.org> wrote:
> Cc wqueue & umode helper folks
>
> On 12. 07. 25, 1:08, Hauke Mehrtens wrote:
> > 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 calls 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
>
> As David noted, this is not the proper fix. It appears that usermode
> helper should use limited thread pool. I.e. instead of
> system_unbound_wq, alloc_workqueue("", WQ_UNBOUND, max_active) with
> max_active set to max_threads divided by some arbitrary constant (3? 4?)?
Or maybe just 1 ?
I'd guess all the threads either block in the same place or just block
each other??
David
>
> regards,
next prev parent reply other threads:[~2025-07-17 21:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-11 23:08 [PATCH v2] kernel/fork: Increase minimum number of allowed threads Hauke Mehrtens
2025-07-12 6:50 ` Greg KH
2025-07-17 5:26 ` Jiri Slaby
2025-07-17 21:34 ` David Laight [this message]
2025-07-17 22:52 ` Hauke Mehrtens
2025-07-20 15:28 ` Hauke Mehrtens
2025-07-21 18:28 ` David Laight
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=20250717223432.2a74e870@pumpkin \
--to=david.laight.linux@gmail.com \
--cc=david@redhat.com \
--cc=frederic@kernel.org \
--cc=hauke@hauke-m.de \
--cc=jiangshanlai@gmail.com \
--cc=jirislaby@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=paulmck@kernel.org \
--cc=sashal@kernel.org \
--cc=stable@vger.kernel.org \
--cc=tj@kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox