From nobody Sun Feb 8 09:12:59 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 107DE3431F0 for ; Wed, 22 Oct 2025 12:14:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761135268; cv=none; b=EHTYRWs+AOkkS61afXLpu5DC/R2b+67SmXkq/mP0D4hnqTWdaufUtGWCZ8YoRgeVga9wIJtVp415Q6bKuNn77lcHWRVrWFkhBUvBQrQqtVWAH3FKmNJUWujhrWHf5zI3xvVCAz/uxCjqLmyM/WMtaFHDDlA/djdnOWjvavQohjU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761135268; c=relaxed/simple; bh=QrL7OONpmTtsZljTHd0Qyo5LOvQrGKEBSY3RO5pbFfQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=k+rEvT45sIhi3+BGtm2PRsc8CpopcNytecilUZI2QUAhh240yTRRwhoJNkhQ6vYju96bEm+RkHmVwm4YRsf4N/+jS1kCwdmYSi6sUSZYhuUw3HBY7aXfFTL/OudM6dbg/lk8knJ01wDl2UgRocTx0TFzsH/yyW9V/W2tkqMUE9g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=OTbpQ1dt; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="OTbpQ1dt" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1761135266; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=efuKFpXatQa3caS7HeNgDN4jbZUJUL46OQhq/PHK3n4=; b=OTbpQ1dtmXEkzjGqj6nudJqZt09aGnOdw9vApPnAOKscazEeWg3/pdR1MGx57gAfqO4bWC r5V/oR9JGOzGFb8ehhfYVl+8RGBqXEzo6vLPuuZKke+gD8qC8DmcH/zwpqgeb4gvJ2P1vc 07/ivkAT2GLwywjB82+mQ04ep2J67hw= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-198-VE1wR571MBqjaxw4FgCZSw-1; Wed, 22 Oct 2025 08:14:22 -0400 X-MC-Unique: VE1wR571MBqjaxw4FgCZSw-1 X-Mimecast-MFC-AGG-ID: VE1wR571MBqjaxw4FgCZSw_1761135261 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 743361956094; Wed, 22 Oct 2025 12:14:20 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.72.112.98]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A1F3D180035A; Wed, 22 Oct 2025 12:14:09 +0000 (UTC) From: Pingfan Liu To: kexec@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Pingfan Liu , Waiman Long , Peter Zijlstra , Juri Lelli , Pierre Gondois , Andrew Morton , Baoquan He , Ingo Molnar , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Valentin Schneider , "Rafael J. Wysocki" , Joel Granados Subject: [RFC 1/3] sched/deadline: Skip the deadline bandwidth check if kexec_in_progress Date: Wed, 22 Oct 2025 20:13:43 +0800 Message-ID: <20251022121345.23496-2-piliu@redhat.com> In-Reply-To: <20251022121345.23496-1-piliu@redhat.com> References: <20251022121345.23496-1-piliu@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Content-Type: text/plain; charset="utf-8" During discussion of the scheduler deadline bug [1], Pierre Gondois pointed out a potential issue during kexec: as CPUs are unplugged, the available DL bandwidth of the root domain gradually decreases. At some point, insufficient bandwidth triggers an overflow detection, causing CPU hot-removal to fail and kexec to hang. This can be reproduced by: chrt -d -T 1000000 -P 1000000 0 yes > /dev/null & kexec -e This patch skips the DL bandwidth check if kexec is in progress. [1]: https://lore.kernel.org/all/20250929133602.32462-1-piliu@redhat.com/ Reported-by: Pierre Gondois Closes: https://lore.kernel.org/all/3408aca5-e6c9-434a-9950-82e9147fcbba@ar= m.com/ Signed-off-by: Pingfan Liu Cc: Waiman Long Cc: Peter Zijlstra Cc: Juri Lelli Cc: Pierre Gondois Cc: Andrew Morton Cc: Baoquan He Cc: Ingo Molnar Cc: Vincent Guittot Cc: Dietmar Eggemann Cc: Steven Rostedt Cc: Valentin Schneider Cc: "Rafael J. Wysocki" Cc: Joel Granados To: kexec@lists.infradead.org To: linux-kernel@vger.kernel.org --- kernel/kexec_core.c | 6 ++++++ kernel/sched/deadline.c | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c index 31203f0bacafa..265de9d1ff5f5 100644 --- a/kernel/kexec_core.c +++ b/kernel/kexec_core.c @@ -1183,7 +1183,13 @@ int kernel_kexec(void) } else #endif { + /* + * CPU hot-removal path refers to kexec_in_progress, it + * requires a sync to ensure no in-flight hot-removing. + */ + cpu_hotplug_disable(); kexec_in_progress =3D true; + cpu_hotplug_enable(); kernel_restart_prepare("kexec reboot"); migrate_to_reboot_cpu(); syscore_shutdown(); diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index a3a43baf4314e..cc864cc348b2c 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -18,6 +18,7 @@ =20 #include #include +#include #include #include "sched.h" #include "pelt.h" @@ -3502,6 +3503,12 @@ static int dl_bw_manage(enum dl_bw_request req, int = cpu, u64 dl_bw) =20 int dl_bw_deactivate(int cpu) { + /* + * The system is shutting down and cannot roll back. There is no point + * in keeping track of bandwidth, which may fail hotplug. + */ + if (unlikely(kexec_in_progress)) + return 0; return dl_bw_manage(dl_bw_req_deactivate, cpu, 0); } =20 --=20 2.49.0 From nobody Sun Feb 8 09:12:59 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EC3FB28B7D7 for ; Wed, 22 Oct 2025 12:14:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761135280; cv=none; b=K/3apTdHgQvQtMdNfhotgWtFgmy/RdLOkQsTGoiC0/xtTETjmq1Tgts+SR0uylnGxy2vyvaiiQUn2KjdjSke5M7M57Ort55r/f5tvvRuQbvvIWULTaIZ/XfkodhJ+g50yCg+B1/mUniqOtAuLHX/U9+Fovb7bMKiPQzbVay4O+0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761135280; c=relaxed/simple; bh=x2as0rITwGwnqzpM+DDHJ134ScOAHVCmgUim9nHInaA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gFhVzP4ysng2OvnIlwm27Gauu0HxA7sKPT4jscfDUCewvbCDF6JgqgcKS68kOgbmPhV7O9vdJtnUia4HYl4cW175qddGVrt9Jzyd/zsoz+oIINAaJiIIWnZ2wDAQMyGOcQ3+05OwKkRfiBIMUUvqajl4BZweAwr7vindLUXA0jg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=IxSWkvk0; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="IxSWkvk0" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1761135278; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=luI49aJWaaO/LQ54EBxZk4WAfdvW9kwQCGC0aaaZi3A=; b=IxSWkvk080KgZH4krs3uihAUuvIyLk+puduNc3/ZIVhV5sun/u+/1zCQUgYoN8UmcsFPdL SY0ENvvWk0fujE0hfKsZg8v4dPUxHEDp6aQc8Qwa9e7jidahiD8a8NwQObimVu9i3JsHkk m2UmjEv1fb32rh6obX2p54jFUleBgHk= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-404-FQa_G7grMAKwqXKMAP421Q-1; Wed, 22 Oct 2025 08:14:34 -0400 X-MC-Unique: FQa_G7grMAKwqXKMAP421Q-1 X-Mimecast-MFC-AGG-ID: FQa_G7grMAKwqXKMAP421Q_1761135272 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7C01019539AB; Wed, 22 Oct 2025 12:14:31 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.72.112.98]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C2FEA180035A; Wed, 22 Oct 2025 12:14:20 +0000 (UTC) From: Pingfan Liu To: kexec@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Pingfan Liu , Waiman Long , Peter Zijlstra , Juri Lelli , Pierre Gondois , Andrew Morton , Baoquan He , Ingo Molnar , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Valentin Schneider , "Rafael J. Wysocki" , Joel Granados , Thomas Gleixner Subject: [RFC 2/3] kernel/cpu: Mark nonboot cpus as inactive when shutting down nonboot cpus Date: Wed, 22 Oct 2025 20:13:44 +0800 Message-ID: <20251022121345.23496-3-piliu@redhat.com> In-Reply-To: <20251022121345.23496-1-piliu@redhat.com> References: <20251022121345.23496-1-piliu@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Content-Type: text/plain; charset="utf-8" The previous patch lifted the deadline bandwidth check during the kexec process, which raises a potential issue: as the number of online CPUs decreases, DL tasks may be crowded onto a few CPUs, which may starve the CPU hotplug kthread. As a result, the hot-removal cannot proceed in practice. On the other hand, as CPUs are offlined one by one, all tasks will eventually be migrated to the kexec CPU. Therefore, this patch marks all other CPUs as inactive to signal the scheduler to migrate tasks to the kexec CPU during hot-removal. Signed-off-by: Pingfan Liu Cc: Waiman Long Cc: Peter Zijlstra Cc: Juri Lelli Cc: Pierre Gondois Cc: Thomas Gleixner Cc: kexec@lists.infradead.org To: linux-kernel@vger.kernel.org --- kernel/cpu.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/kernel/cpu.c b/kernel/cpu.c index db9f6c539b28c..76aa0f784602b 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -1546,6 +1546,16 @@ void smp_shutdown_nonboot_cpus(unsigned int primary_= cpu) if (!cpu_online(primary_cpu)) primary_cpu =3D cpumask_first(cpu_online_mask); =20 + /* + * Mark all other CPUs as inactive so the scheduler won't select them as + * migration targets. + */ + for_each_online_cpu(cpu) { + if (cpu =3D=3D primary_cpu) + continue; + set_cpu_active(cpu, false); + } + for_each_online_cpu(cpu) { if (cpu =3D=3D primary_cpu) continue; --=20 2.49.0 From nobody Sun Feb 8 09:12:59 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2916B34167A for ; Wed, 22 Oct 2025 12:14:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761135290; cv=none; b=gH23nGH1DbENqTcUvoh6YProidLp/n2032SWMDK59O58AwG3/3hENuYbk7yRV/4rDdZBFQc9s1Edsjq6et2wPQzVRjIQq2HwoLuS7aafaOuz4GfMzjU3+GSQY6tYPk7GxnxqKl8O24lceBHxDsrCECBr8WmBiIgBwJj/ucYwrIY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761135290; c=relaxed/simple; bh=pfS8U/j5Ny1hiXcolE4aHLqnuv2ch3BXbnGcgM7t6B4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CR1s9WhjEVwYyhMPHxRE4FbKFNs42WCc6Px0nL+XVP08X5AIREHASBb6hHpK52EiU0Po2YJo9HJOVULoQvfMSXF//fyS7qnvq8UppYLQEgIDEsVXWxIT1jvp0mGSZ0sn3xThjSAKleNk6eAl9wId+eOLxQz9Gn8cRXDKAwiw4JY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Emir2s6k; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Emir2s6k" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1761135287; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ekimc72PCbpOA1x/tlS6SXdLF6ETf9qbbL3151vpaxg=; b=Emir2s6kDBNWk0o1OQ4izoaKLvicEhr8kWN7vsLTQIbJ30mHznN/67fruNTjdk8NrRxUUQ FtSqz+3LniPkklxS9sswEWzdbZXfpG5/GscK+nVxVNcJVGLOME5Uf7ug3ccxkdB3XtXuKp adVT78Na9CiY+rQ+MsDjDPVE285R840= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-589-d2iakW3GOnuSp_JrGPkW3A-1; Wed, 22 Oct 2025 08:14:44 -0400 X-MC-Unique: d2iakW3GOnuSp_JrGPkW3A-1 X-Mimecast-MFC-AGG-ID: d2iakW3GOnuSp_JrGPkW3A_1761135282 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7125D1956089; Wed, 22 Oct 2025 12:14:42 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.72.112.98]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5BF521800590; Wed, 22 Oct 2025 12:14:31 +0000 (UTC) From: Pingfan Liu To: kexec@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Pingfan Liu , Waiman Long , Peter Zijlstra , Juri Lelli , Pierre Gondois , Andrew Morton , Baoquan He , Ingo Molnar , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Valentin Schneider , "Rafael J. Wysocki" , Joel Granados Subject: [RFC 3/3] kexec_core: Promote the kexec to DL task Date: Wed, 22 Oct 2025 20:13:45 +0800 Message-ID: <20251022121345.23496-4-piliu@redhat.com> In-Reply-To: <20251022121345.23496-1-piliu@redhat.com> References: <20251022121345.23496-1-piliu@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Content-Type: text/plain; charset="utf-8" The previous patch lifted the deadline bandwidth check during the kexec process. As a result, DL tasks may be crowded onto the kexec CPU, which may starve the kexec task. At this point, the kexec task is the only task needed to make the reboot proceed, hence promoting it to a deadline task prevents this starvation. Signed-off-by: Pingfan Liu Cc: Waiman Long Cc: Peter Zijlstra Cc: Juri Lelli Cc: Pierre Gondois Cc: Andrew Morton Cc: Baoquan He To: kexec@lists.infradead.org To: linux-kernel@vger.kernel.org --- kernel/kexec_core.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c index 265de9d1ff5f5..0960bea1a8bab 100644 --- a/kernel/kexec_core.c +++ b/kernel/kexec_core.c @@ -41,6 +41,7 @@ #include #include #include +#include =20 #include #include @@ -1183,6 +1184,20 @@ int kernel_kexec(void) } else #endif { + struct sched_attr attr =3D { + .size =3D sizeof(struct sched_attr), + .sched_policy =3D SCHED_DEADLINE, + .sched_nice =3D 0, + .sched_priority =3D 0, + /* + * Fake (unused) bandwidth; workaround to "fix" + * priority inheritance. + */ + .sched_runtime =3D NSEC_PER_MSEC, + .sched_deadline =3D 10 * NSEC_PER_MSEC, + .sched_period =3D 10 * NSEC_PER_MSEC, + }; + /* * CPU hot-removal path refers to kexec_in_progress, it * requires a sync to ensure no in-flight hot-removing. @@ -1202,6 +1217,13 @@ int kernel_kexec(void) */ cpu_hotplug_enable(); pr_notice("Starting new kernel\n"); + /* + * During hot-removing cpu, all DL tasks will be migrated to + * this cpu. To prevent this task from starving, promoting it + * to DL task. And soon, local interrupt will be disabled in + * machine_kexec(). + */ + sched_setattr_nocheck(current, &attr); machine_shutdown(); } =20 --=20 2.49.0