From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yx1-f45.google.com (mail-yx1-f45.google.com [74.125.224.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0641A3164B4 for ; Mon, 27 Jul 2026 22:16:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785190574; cv=none; b=FgTFFdgUklG5qIr/gPjb/m4cFKqqReh6JlZxB3VR8LQk1FNCFa86TRzBzHHr/FJ/4FPMcxxDqSUtl2E3cyO3Le2HacEbxLEzKRUPvrirCp/TOo2fxeAP/qif31Nifp2Oo/+Bc2lz9kgYOo5s+3mkdNRhtPO1WRcJo+uasZlIpSg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785190574; c=relaxed/simple; bh=BrI5qYQeuVyYMDgpJDgKzp0AaSS+LjrtEVsdPDeZSjc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=UDw7641tCnWs/kVfa6MLLoG+MFM4uw6/0GuJUUJTn0doNrUwiCQoK3vEwSMEzvTa4OMrHiO3jVYfc6aY1A5Pav4XVy1m3Q5G+K1thhI1ABI9uqr04Uu9daGU8SWpb6LJxMtL44dNhkiaYLMMtU2VghqGjhEOaFyss/mTM5DJJr0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=geFIzw9m; arc=none smtp.client-ip=74.125.224.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="geFIzw9m" Received: by mail-yx1-f45.google.com with SMTP id 956f58d0204a3-6688a2dceb8so2178711d50.3 for ; Mon, 27 Jul 2026 15:16:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785190572; x=1785795372; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=v6Lb6PXYoTo2SZV9e0RV4X1y8uZ6bVYYsgCt6gyZv5k=; b=geFIzw9mp7/fvsfFLvosDywqHuGABzXOgzZBhtt0gr7bTCw4z55k9CluBziFCJWblv /CX5slSJUKkXKGK1bQCLeo/Mv/g/pp05Dhm7A8HgEecdhrMjcrtrRHOXuhut01keXdrS +wO5ffA4D911iV+8nQ5flKyx31ZdFH5+AQNKsXePA+iWH9A5lMp+YTSSksTgWgQOK9YW hbgXOuAEUo1kP0g5bB0pw1JgQIfxbkwusPztKYyhq8AuSPdijO4ZKr6XlKOvly2VqDtu dDbhFpDR1hkwuoh9l1tsJr3+HomcPXlQeejp3djxaoubOklhv6r8Ax9jS7I3KRPAMaNy WjEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785190572; x=1785795372; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=v6Lb6PXYoTo2SZV9e0RV4X1y8uZ6bVYYsgCt6gyZv5k=; b=kDdV7q45doe2KyY6UTMEgZeDbLfhb4TztSxaEGaPxwDrzStBflMAyTVL560mF/kh+d kurXiZaUnEGXdFsGJFe0t7BeaHV31ZJ0IcMoWg8DCRqYJEKHcV128HTKliCUfpBAbHjJ A+vwiSn0CMKzLgiwVdf0BS5vqVJZSYOo2vjiXOVu2dwCOP6/U3cTFAeGRsnVHLa4YpkP +w9MjjyDQPMaMcGR1s3rk5phiddobUrrQ9e3PXlxp0BT6QvVTJ8sLO0u+o4i/Hwdmsku pb0Qw9/ZCuKwCRxhV2faWW2oJqeQwZsWNNNcbIlQjJbsz2zXKkrTMeGSZSwmHhT/NZEv 9nTw== X-Forwarded-Encrypted: i=1; AHgh+RqFcqGWO/quj+6fuEAQKYCfsvTLUf4MKvrkdhtcyQvfFO9z5JxTHe+M7RE/4ojx37Q8ehYVITnV8yxjPLA=@vger.kernel.org X-Gm-Message-State: AOJu0Yz/J30kYiIDCbkxqWAUasNE+KQyLhG9L1DRqHJ+k/Ga7ElQ3Tjr KiynXJq29vOM9XVjoLFntB+U4eOCMAWvNv+GUkY++bub14QqJ/biDnei X-Gm-Gg: AR+sD11V04H7Pn7hrgThJc+UrsaFTQeMeqm6RkxjriV7ByYkwol9tqzFLFOeOQh3K6Q ozMUis4Serj/pvIg7zBwRfJDs8YD2HFixk44v7Q7tXogU8ftuoWRmvkvqw8EU5nn+YxrkIFyhSl I7Zq7hiMpUEf0738G/AVCUzGWsz9tDQSVn4lWZGzVsLzMtQQ3s+s7PsHNk8NwCbTfAh98SJqq1H 1/8AxyGDNMJq91/9y/j7C1xYjAi0TuAzsB7PhpJwM9031wlwWFUAYoVq425IrHFncm1Wm4BIlmy rj9cLFSJJGEaEWhadRsizePs08Xijb+xhCte2yOFILdX4JoVV6pPd8vdAhaf6qonyyUh0FBs5Kr ii5D6Mxva/yDlH8L95pqEg8Z94pylU3UaxIRLbawafldGrAzcmRjH8RBP6nZuzUGJQiM/fwO7Pi oef5QgD8pbcVzRuQlyD7AiRDIrgdCQhS7Y/u+Fw+lGHZOo99QQY5CBero= X-Received: by 2002:a53:d005:0:b0:668:52ec:f873 with SMTP id 956f58d0204a3-668c7c0ee01mr2745034d50.81.1785190572003; Mon, 27 Jul 2026 15:16:12 -0700 (PDT) Received: from localhost.localdomain ([107.198.84.185]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-668c6d30094sm4053701d50.1.2026.07.27.15.16.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jul 2026 15:16:11 -0700 (PDT) From: Paul Sherman To: lee@kernel.org, pavel@kernel.org Cc: treding@nvidia.com, linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, Paul Sherman Subject: [PATCH] leds: trigger: cpu: use cpuhp_setup_state_nocalls() for large CPU counts Date: Mon, 27 Jul 2026 15:16:06 -0700 Message-ID: <20260727221607.5216-1-shermanpauldylan@gmail.com> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Paul Sherman --- 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