From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 27A9147F4A; Thu, 11 Sep 2025 12:53:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757595184; cv=none; b=d8yCVmj+qVx577upS1y3q1nZmqhnXe7lXO+03EUEDKGDOfdcSyI37hp7CgfHeqE6R3FKxKkZBB5TEcOx/dnCtoRd7/+93xGcllEqX1/OthS0pObwN5IKmsNPOTZwWK4JmWx/7OHvgo0brO34hGo3Ahx3kIhpolYwi2pQtmSdrz4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757595184; c=relaxed/simple; bh=MZVB7/i0EFuk4RSxg5GLPASN5xXePbd2gQd2oauB1jI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ap0YuhlUfNZ4F3tD9TetZ5KpWO/HRS8f0uXeemMujUHISlmPrriG4XYijTerMbeMWbwpIOtMlfQmF0w4N2mc/xL45HkiLhCxTeHJmCWQ5QkvaDBx2PeP+k9eaITAY1VPaFGlStwd7LI1PecCRgRkJaznhp7zyxHGOkhoSwBXke0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=opGuiMwt; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="opGuiMwt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 42D00C4CEF0; Thu, 11 Sep 2025 12:53:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1757595183; bh=MZVB7/i0EFuk4RSxg5GLPASN5xXePbd2gQd2oauB1jI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=opGuiMwtghtUiv6eseCaXX+yaB5xaDGOoKqv/KMVnLWLPIHxwBjLw+HpwuXniPzUB Xq4NOX6ik2gruLRU+gedJDMtg62EhNYqaLoVlUDHwhvq9D0RuD16q7GK0t4GLEcONp vSvmB2RD9jlgJOItUarSgwrQHMxs+3jT2w7aPZ/U= Date: Thu, 11 Sep 2025 14:53:01 +0200 From: Greg KH To: "wangtao (EQ)" Cc: stable@vger.kernel.org, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, tglx@linutronix.de, frederic@kernel.org, linux-kernel@vger.kernel.org, tanghui20@huawei.com, zhangqiao22@huawei.com Subject: Re: [PATCH stable/linux-5.10.y] sched/core: Fix potential deadlock on rq lock Message-ID: <2025091146-gyration-venue-01c3@gregkh> References: <20250908084230.848195-1-wangtao554@huawei.com> <2025091123-unsterile-why-ca1e@gregkh> <0614bb1c-3dc9-4ad1-9135-19662e20163b@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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <0614bb1c-3dc9-4ad1-9135-19662e20163b@huawei.com> On Thu, Sep 11, 2025 at 08:30:44PM +0800, wangtao (EQ) wrote: > > 在 2025/9/11 20:20, Greg KH 写道: > > On Mon, Sep 08, 2025 at 08:42:30AM +0000, Wang Tao wrote: > > > When CPU 1 enters the nohz_full state, and the kworker on CPU 0 executes > > > the function sched_tick_remote, holding the lock on CPU1's rq > > > and triggering the warning WARN_ON_ONCE(delta > (u64)NSEC_PER_SEC * 3). > > > This leads to the process of printing the warning message, where the > > > console_sem semaphore is held. At this point, the print task on the > > > CPU1's rq cannot acquire the console_sem and joins the wait queue, > > > entering the UNINTERRUPTIBLE state. It waits for the console_sem to be > > > released and then wakes up. After the task on CPU 0 releases > > > the console_sem, it wakes up the waiting console_sem task. > > > In try_to_wake_up, it attempts to acquire the lock on CPU1's rq again, > > > resulting in a deadlock. > > > > > > The triggering scenario is as follows: > > > > > > CPU 0 CPU1 > > > sched_tick_remote > > > WARN_ON_ONCE(delta > (u64)NSEC_PER_SEC * 3) > > > > > > report_bug con_write > > > printk > > > > > > console_unlock > > > do_con_write > > > console_lock > > > down(&console_sem) > > > list_add_tail(&waiter.list, &sem->wait_list); > > > up(&console_sem) > > > wake_up_q(&wake_q) > > > try_to_wake_up > > > __task_rq_lock > > > _raw_spin_lock > > > > > > This patch fixes the issue by deffering all printk console printing > > > during the lock holding period. > > > > > > Fixes: d84b31313ef8 ("sched/isolation: Offload residual 1Hz scheduler tick") > > > Signed-off-by: Wang Tao > > > --- > > > kernel/sched/core.c | 2 ++ > > > 1 file changed, 2 insertions(+) > > > > > > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > > > index 40f40f359c5d..fd2c83058ec2 100644 > > > --- a/kernel/sched/core.c > > > +++ b/kernel/sched/core.c > > > @@ -4091,6 +4091,7 @@ static void sched_tick_remote(struct work_struct *work) > > > goto out_requeue; > > > rq_lock_irq(rq, &rf); > > > + printk_deferred_enter(); > > > curr = rq->curr; > > > if (cpu_is_offline(cpu)) > > > goto out_unlock; > > > @@ -4109,6 +4110,7 @@ static void sched_tick_remote(struct work_struct *work) > > > calc_load_nohz_remote(rq); > > > out_unlock: > > > + printk_deferred_exit(); > > > rq_unlock_irq(rq, &rf); > > > out_requeue: > > > -- > > > 2.34.1 > > > > > > > Sorry, we initially discovered the issue while testing the stable branch, > and it seems that the mainline has the same problem, but I haven't submitted > a patch yet. That is required for us to be able to take a patch into the stable trees, thanks. greg k-h