From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 6B967259C80 for ; Fri, 23 Jan 2026 10:06:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769162804; cv=none; b=FAsEosO4dNQpV0TO+11CFHj75Lseb9+oy0vhisk8/7x5UOKFaABaORkHAruCR43HzkSdP1Uzxe7kGAlMCAMhkKa5oQlOHPfWMxwOpyHTK9/r8tbTFkLYCspkoNVIyb5hKg0FkSAd9t0yzwhn8KXA5Qvi2Qfgk2pQsgzHK+U4V3Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769162804; c=relaxed/simple; bh=RwATfoSqlKG9K/7XH0YFUE1N3q2yyKK+L7iTy8Fc/28=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=G1ffJN8i9ZipjRQgL7mVA6NUJgZT5jOcE5rvB6uCvN0rhJX00pf0RdOyfVHzVND4Vdp6HtlStjVbUkED3OB42SJh5eW6lgdnBAGlghMCNMbjEmUb/T91WsV5oftRwXpPup8/l7KkfyzdxO5oxKYxkZOhLO21JyfmAEuMFbewzA8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=deHOP1b4; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="deHOP1b4" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=BHeEtGghkYQdz3RvoTPgyVZF7HaU1/bkjOUCg94EqiE=; b=deHOP1b4oCotUDTmHgtTO4BeL8 j+edxdRRilhvoTmk0B5bGxiO9txfQcML1NXTW/An9btyndTrRU9U3DFzmq2IWCLrRogNGAbAZEe7W jou4VVkB/8hmcnGoCdHRG2GjemsC0+Zqnw3Be66Ch83a1wZgWngRi8lX2VAZAljT2hGuApg7jvuaX u/QnBiJiIf2bG5/IljmN/ZjWBNvS/L0kbUDQUAUwtbM/BGNYFh6a37tOeK/1O67mcSuUL13L5Y2C2 e7D0yLozdJ1kyZnpG+bsja9HaEeTxxOiXc7aLTe1mvDm7SAYIvXdZ4ptOxyt12EIbuielLWcdWKAJ nfn1DbRQ==; Received: from 2001-1c00-8d85-5700-266e-96ff-fe07-7dcc.cable.dynamic.v6.ziggo.nl ([2001:1c00:8d85:5700:266e:96ff:fe07:7dcc] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1vjE3d-00000001c07-2zOh; Fri, 23 Jan 2026 10:06:25 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 42F9F3007E1; Fri, 23 Jan 2026 11:06:25 +0100 (CET) Date: Fri, 23 Jan 2026 11:06:25 +0100 From: Peter Zijlstra To: Chen Jinghuang Cc: mingo@redhat.com, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, vschneid@redhat.com, linux-kernel@vger.kernel.org Subject: Re: [RESEND] sched/rt: Skip currently executing CPU in rto_next_cpu() Message-ID: <20260123100625.GK171111@noisy.programming.kicks-ass.net> References: <20260122012533.673768-1-chenjinghuang2@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260122012533.673768-1-chenjinghuang2@huawei.com> On Thu, Jan 22, 2026 at 01:25:33AM +0000, Chen Jinghuang wrote: > 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 != 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 > --- Thanks!