From nobody Sun Feb 8 13:11:21 2026 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) (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 5664E2C3256 for ; Thu, 8 Jan 2026 07:23:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767857027; cv=none; b=VDMpmWqTOCVT462uRwfxp9awUs3uJbZuBq9/Gk/ahgy5l0I84vmGZW1o4DIYrA+DY3ZeYX/PGLbWyHcquN3AXIxRv86RnF48FszGb6/seyjRI6T3Uxf2yfLl1p44yHhR+nHS1JZj7luElufZPQ8H0YNfA3zNxyj07KZTBbnc2ZQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767857027; c=relaxed/simple; bh=JJ7u8BmAgKTjsuaMaE+DctrUl+T5POgcu5jWfQSvFLI=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=uOoaPvHMo/VTkaiIulhS4SyU0fj/IWmjw/uUPzDMyZvqhpkg8GjtCM7J0VU+7ONT0wDFmxx8ByC8Cu9iOnQ+Z1far5yTcDVyGJ2hCmmoM+HfdyUCunX+kKwfgFlMRo+6vHxh++NU5Q9gmEeNikHqk6QW4aJL6n6yTDzViNdFNAY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=cx5sJYJL; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=cx5sJYJL; arc=none smtp.client-ip=45.249.212.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="cx5sJYJL"; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="cx5sJYJL" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=k09nQP2EbCiyS+BLdkXFdMWrBa6ij+85j9J4rjm+wlQ=; b=cx5sJYJL3a5kglPHsbiUVkd+6lNFpJrSw/mSRW1YO3XKGhvSAmPg0E1eIdfK1ZUEDAtwcJKOR 7+yHr06MOTk+BzqbzGdb9eTtu2lxidZ18MRi13vzYwnLuVIeLHMgxWHQpkN0OAGKQKmcHZHqGug zK7i5MSwl1EwI3JXzLU4bSc= Received: from canpmsgout05.his.huawei.com (unknown [172.19.92.145]) by szxga01-in.huawei.com (SkyGuard) with ESMTPS id 4dmxFG45Pkz1BFxW for ; Thu, 8 Jan 2026 15:22:42 +0800 (CST) dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=k09nQP2EbCiyS+BLdkXFdMWrBa6ij+85j9J4rjm+wlQ=; b=cx5sJYJL3a5kglPHsbiUVkd+6lNFpJrSw/mSRW1YO3XKGhvSAmPg0E1eIdfK1ZUEDAtwcJKOR 7+yHr06MOTk+BzqbzGdb9eTtu2lxidZ18MRi13vzYwnLuVIeLHMgxWHQpkN0OAGKQKmcHZHqGug zK7i5MSwl1EwI3JXzLU4bSc= Received: from mail.maildlp.com (unknown [172.19.163.104]) by canpmsgout05.his.huawei.com (SkyGuard) with ESMTPS id 4dmxBj2tCCz12LCy; Thu, 8 Jan 2026 15:20:29 +0800 (CST) Received: from kwepemg100008.china.huawei.com (unknown [7.202.181.26]) by mail.maildlp.com (Postfix) with ESMTPS id 252A54056A; Thu, 8 Jan 2026 15:23:33 +0800 (CST) Received: from huawei.com (10.67.174.242) by kwepemg100008.china.huawei.com (7.202.181.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.36; Thu, 8 Jan 2026 15:23:32 +0800 From: Chen Jinghuang To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot CC: Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , Subject: [PATCH] sched/rt: Skip currently executing CPU in rto_next_cpu() Date: Thu, 8 Jan 2026 07:03:55 +0000 Message-ID: <20260108070355.259530-1-chenjinghuang2@huawei.com> X-Mailer: git-send-email 2.34.1 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-ClientProxiedBy: kwepems100002.china.huawei.com (7.221.188.206) To kwepemg100008.china.huawei.com (7.202.181.26) Content-Type: text/plain; charset="utf-8" CPU0 becomes overloaded when hosting a CPU-bound RT task, a non-CPU-bound RT task, and a CFS task stuck in kernel space. When other CPUs switch from RT to non-RT tasks, RT load balancing (LB) is triggered; with HAVE_RT_PUSH_IPI enabled, they send IPIs to CPU0 to drive the execution of rto_push_irq_work_func. During push_rt_task on CPU0, if next_task->prio < rq->donor->prio, resched_curr() sets NEED_RESCHED and after the push operation completes, CPU0 calls rto_next_cpu(). Since only CPU0 is overloaded in this scenario, rto_next_cpu() should ideally return -1 (no further IPI needed). However, multiple CPUs invoking tell_cpu_to_push() during LB increments rd->rto_loop_next. Even when rd->rto_cpu is set to -1, the mismatch between rd->rto_loop and rd->rto_loop_next forces rto_next_cpu() to restart its search from -1. With CPU0 remaining overloaded (satisfying rt_nr_migratory && rt_nr_total > 1), it gets reselected, causing CPU0 to queue irq_work to itself and send self-IPIs repeatedly. As long as CPU0 stays overloaded and other CPUs run pull_rt_tasks(), it falls into an infinite self-IPI loop, which triggers a CPU hardlockup due to continuous self-interrupts. The trigging scenario is as follows: cpu0 cpu1 cpu2 pull_rt_task tell_cpu_to_push <------------irq_work_queue_on rto_push_irq_work_func push_rt_task resched_curr(rq) pull_rt_task rto_next_cpu tell_cpu_to_push <-------------------------- atomic_inc(rto_loop_next) rd->rto_loop !=3D next rto_next_cpu irq_work_queue_on rto_push_irq_work_func Fix redundant self-IPI by filtering the initiating CPU in rto_next_cpu(). This solution has been verified to effectively eliminate spurious self-IPIs and prevent CPU hardlockup scenarios. Fixes: 4bdced5c9a29 ("sched/rt: Simplify the IPI based RT balancing logic") Suggested-by: Steven Rostedt (Google) Suggested-by: K Prateek Nayak Signed-off-by: Chen Jinghuang Reviewed-by: Steven Rostedt (Google) Reviewed-by: Valentin Schneider --- Changes since v3: https://lore.kernel.org/all/20260105034012.3196947-1-chen= jinghuang2@huawei.com/ - Replace the do-while loop with a continue statement to simplify the loop logic - Add Suggested-by tag from K Prateek Nayak Changes since v2: https://lore.kernel.org/all/20251125083649.1814558-1-chen= jinghuang2@huawei.com/ - Replace the original "check NEED_RESCHED on target CPU" logic with "skip the currently executing CPU" - This modification eliminates self-IPIS Changes since v1: https://lore.kernel.org/all/20251121014004.564508-1-chenj= inghuang2@huawei.com/ - Remove unneeded extra whitespace - Add Reviewed-by tag from Steven Rostedt --- kernel/sched/rt.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index f1867fe8e5c5..e0ff90905019 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -2100,6 +2100,7 @@ static void push_rt_tasks(struct rq *rq) */ static int rto_next_cpu(struct root_domain *rd) { + int this_cpu =3D smp_processor_id(); int next; int cpu; =20 @@ -2123,6 +2124,10 @@ static int rto_next_cpu(struct root_domain *rd) =20 rd->rto_cpu =3D cpu; =20 + /* Do not send IPI to self */ + if (cpu =3D=3D this_cpu) + continue; + if (cpu < nr_cpu_ids) return cpu; =20 --=20 2.34.1