Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp1881878pxb; Mon, 13 Sep 2021 07:28:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxjG3cDZbhs6EB+7z+k2aeLnM1dlq8BFNNanBVv/Sjw+HmVnA/wUwdnVBGM4mAz8ywhFbpc X-Received: by 2002:a05:6638:372a:: with SMTP id k42mr6605048jav.71.1631543291548; Mon, 13 Sep 2021 07:28:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631543291; cv=none; d=google.com; s=arc-20160816; b=MySWjU0hBH8YLsL/lyNNqyWLOWgse033h61nIyLeSr684chN3PcLdyA8+5wErYE7p1 G8bH2s3og+0YUomVJFLQJozkcsMd7zeTJAIVpi4De0I7Fij+oxEZEEfPbwBM7k9U6eMR QNmyaaURJ4u673VJshpyYd+TPTvZPIdrLEtOGXATPrvQslqkMaxrKFKFuf4J5i3B69Cm S+NaAB+BiA1QX46b8cyJaPoTVyEtIQ4viqM0tkuHnxDVCuyzNxr1pBUI4y7SZuDFG3ta NrA2msCJlJ2m4ztoa+7n0POqRLn2G95ausomn7PyiL4ZxTFVr1W06izGxUOBRAsMbsRN y2JA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=3yO6By+2WlcJqCrMTKqjDofuBadaAGnlFLLMSRUZQRs=; b=cnDmbAo+LGnVQ4qqT28zhtM1dSgwIUNd9JKBApeniNbgfqhgsoD5b5b6NGX3XRS7si 6pVgVyaGZO/ZktV0/Tvfv4n2gHCtIhG3OHAPC/xkvFScRP+m3ZMaHLLpo4wQzgDeQLpQ owm26SZGknh7IKcJGSY3NUlFMVX3HwPtcHLq+A9aVVFpiEg7yS8Z+hVICIvIhLG3zANo YeZItpxfJTdpl3edVbk4ijq/VSyKw5/7oBTuItxhWztclllDY7tQVTLFNFVcfzBh7w54 hcOJpUs3SJkexrrbI9c7SrqSvDXY3HLUUh6p6Auad6TWrRd837RyNACq3D9aeMpS2NVT ko6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JzwyPIYG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r1si185217ilg.125.2021.09.13.07.27.59; Mon, 13 Sep 2021 07:28:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JzwyPIYG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345901AbhIMO1e (ORCPT + 99 others); Mon, 13 Sep 2021 10:27:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:41880 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345254AbhIMOW2 (ORCPT ); Mon, 13 Sep 2021 10:22:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 53FD861B39; Mon, 13 Sep 2021 13:47:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631540843; bh=nD1nGfIPISEgG+0FeIZQbH3JTWsPv+IA/1iKH8ecKIA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JzwyPIYG0RGKNUpuEzH0La3QiSEvE8C07kxqfxJ3W5oAWmntdpDrxLz6yfymYuvsV BMrB0Q/WTqwjeQYp4HIb5PbsOTwdWyHPGpz+4BkhzBD3Yb8F5EZZu4qKeKemSzH9ZP Hvnpcq5rOW8oLZdzued4+gDg87ex7DfdqUvA+Z2o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Qais Yousef , Yanfei Xu , "Paul E. McKenney" , Sasha Levin Subject: [PATCH 5.14 056/334] rcu: Fix stall-warning deadlock due to non-release of rcu_node ->lock Date: Mon, 13 Sep 2021 15:11:50 +0200 Message-Id: <20210913131115.312077932@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131113.390368911@linuxfoundation.org> References: <20210913131113.390368911@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yanfei Xu [ Upstream commit dc87740c8a6806bd2162bfb441770e4e53be5601 ] If rcu_print_task_stall() is invoked on an rcu_node structure that does not contain any tasks blocking the current grace period, it takes an early exit that fails to release that rcu_node structure's lock. This results in a self-deadlock, which is detected by lockdep. To reproduce this bug: tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration 3 --trust-make --configs "TREE03" --kconfig "CONFIG_PROVE_LOCKING=y" --bootargs "rcutorture.stall_cpu=30 rcutorture.stall_cpu_block=1 rcutorture.fwd_progress=0 rcutorture.test_boost=0" This will also result in other complaints, including RCU's scheduler hook complaining about blocking rather than preemption and an rcutorture writer stall. Only a partial RCU CPU stall warning message will be printed because of the self-deadlock. This commit therefore releases the lock on the rcu_print_task_stall() function's early exit path. Fixes: c583bcb8f5ed ("rcu: Don't invoke try_invoke_on_locked_down_task() with irqs disabled") Tested-by: Qais Yousef Signed-off-by: Yanfei Xu Signed-off-by: Paul E. McKenney Signed-off-by: Sasha Levin --- kernel/rcu/tree_stall.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/rcu/tree_stall.h b/kernel/rcu/tree_stall.h index d56b4ede1db3..0e7a60706d1c 100644 --- a/kernel/rcu/tree_stall.h +++ b/kernel/rcu/tree_stall.h @@ -269,8 +269,10 @@ static int rcu_print_task_stall(struct rcu_node *rnp, unsigned long flags) struct task_struct *ts[8]; lockdep_assert_irqs_disabled(); - if (!rcu_preempt_blocked_readers_cgp(rnp)) + if (!rcu_preempt_blocked_readers_cgp(rnp)) { + raw_spin_unlock_irqrestore_rcu_node(rnp, flags); return 0; + } pr_err("\tTasks blocked on level-%d rcu_node (CPUs %d-%d):", rnp->level, rnp->grplo, rnp->grphi); t = list_entry(rnp->gp_tasks->prev, -- 2.30.2