From: Paul Sherman <shermanpauldylan@gmail.com>
To: lee@kernel.org, pavel@kernel.org
Cc: treding@nvidia.com, linux-leds@vger.kernel.org,
linux-kernel@vger.kernel.org,
Paul Sherman <shermanpauldylan@gmail.com>
Subject: [PATCH] leds: trigger: cpu: use cpuhp_setup_state_nocalls() for large CPU counts
Date: Mon, 27 Jul 2026 15:16:06 -0700 [thread overview]
Message-ID: <20260727221607.5216-1-shermanpauldylan@gmail.com> (raw)
ledtrig_cpu_init() uses cpuhp_setup_state() which invokes the startup
callback on every already-online CPU at registration time. On systems
with large CPU counts this serializes callbacks across all online CPUs,
causing boot delays proportional to the number of CPUs.
On a 64-hart RISC-V system this caused ledtrig_cpu_init() to consume
~250 seconds at boot. The same pathology affects any system using
cpuhp_setup_state() where one CPU is slow to acknowledge.
Use cpuhp_setup_state_nocalls() instead, which skips callbacks for
already-online CPUs at registration time. The trigger operates correctly
for future hotplug events regardless.
Tested-on: Milk-V Pioneer (SG2042, 64-hart RISC-V)
Cc: Thierry Reding <treding@nvidia.com>
Signed-off-by: Paul Sherman <shermanpauldylan@gmail.com>
---
drivers/leds/trigger/ledtrig-cpu.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/leds/trigger/ledtrig-cpu.c b/drivers/leds/trigger/ledtrig-cpu.c
index 679323c2ccda0..ce75d5f54684c 100644
--- a/drivers/leds/trigger/ledtrig-cpu.c
+++ b/drivers/leds/trigger/ledtrig-cpu.c
@@ -163,7 +163,15 @@ static int __init ledtrig_cpu_init(void)
register_syscore(&ledtrig_cpu_syscore);
- ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "leds/trigger:starting",
+ /*
+ * Use cpuhp_setup_state_nocalls() to avoid invoking ledtrig_online_cpu()
+ * on every already-online CPU at registration time. On systems with large
+ * CPU counts (e.g. 64-hart RISC-V) cpuhp_setup_state() would serialize
+ * callbacks across all online CPUs, causing multi-hundred-second delays
+ * during boot. The trigger operates correctly for future hotplug events
+ * regardless.
+ */
+ ret = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, "leds/trigger:starting",
ledtrig_online_cpu, ledtrig_prepare_down_cpu);
if (ret < 0)
pr_err("CPU hotplug notifier for ledtrig-cpu could not be registered: %d\n",
--
2.53.0
next reply other threads:[~2026-07-27 22:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-27 22:16 Paul Sherman [this message]
2026-07-27 22:25 ` [PATCH] leds: trigger: cpu: use cpuhp_setup_state_nocalls() for large CPU counts sashiko-bot
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=20260727221607.5216-1-shermanpauldylan@gmail.com \
--to=shermanpauldylan@gmail.com \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=pavel@kernel.org \
--cc=treding@nvidia.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.