Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp61497pxb; Mon, 13 Sep 2021 12:58:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYbK8NNzpH4edozWYoiYirCBZDnYPzLT8qvapLYz+zUJL+emNolr5pqPCTBPAn7wsLzbLZ X-Received: by 2002:a17:906:32c9:: with SMTP id k9mr14759980ejk.218.1631563123773; Mon, 13 Sep 2021 12:58:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631563123; cv=none; d=google.com; s=arc-20160816; b=Xd5MptdlaO04D5HjDOUDq5A4Bomu5br+Py399KFo9UMwLCL+AGC+BfUfK8f+Fl3VaZ +Lj7jBkiiMql0GUbRButqecSg/Kzo/9sfVae4q3+Fh7sS4Rs/S9pcX2dUgZgb+Chw01a Hozkb2Hho/4608JFLRVV3Rg4egjeH/Zeyesw+OAWPR11vGCkE92gRccxgux+xWAGj4HL KaPS4+vnAu7FgfBdq7RCwqltgKbq4u441AC/wIW8rYqEPermMj67PW5XHr1WLYzGP6cF ZeD1GHB0rHD+wPqxf5fPppgTIMMP17bRC00lJvymMNG8h4InurLWrCQwMzCjCh2VTzeL LGcQ== 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=+vf7S+y3CYwF1TZRt0xy1y8aiVYuATBQCOOC4twf7uE=; b=pn8HojmeiDPwxPBuMjlPaQkmYfZkK3alga2sVs96PoUVpzGvmQLptsYd1+1S5TqvuP ChlcoK8ZTV/8f72H4mZiY36KpyZ5vCFvbg+OTbKu252qYstCwyxRoU/oLR9v6j0osyj0 ob/k975XV41i5pNK4Bc6MBFWtNVGGVY+AAq4BkEE/m3CnR4bisuQpbkAx5ZUyWin3hKn t8UuKsYTCt5/7AnN7utRWYzdS0MYgiAIOxxjGDi0ALqCkU6ZcsbYffkcM1WNVgGLo/fB 5FXS7gi4i2lb4CA1WUktlFPDzluaRy0GCEne8yXSD0XnCYp1PhV42y3Pi8qY4btUZrxr NyaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PIhC+Azc; 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 bu1si8475754ejb.482.2021.09.13.12.58.19; Mon, 13 Sep 2021 12:58:43 -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=PIhC+Azc; 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 S241602AbhIMNgS (ORCPT + 99 others); Mon, 13 Sep 2021 09:36:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:50120 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242809AbhIMNaF (ORCPT ); Mon, 13 Sep 2021 09:30:05 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 896B561350; Mon, 13 Sep 2021 13:24:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631539487; bh=j8yzQaZ7jqYtVHIcY+Z8RyZrLQRxc7MPDvul1l9dzMw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PIhC+AzcKo6iAiNHDmEuCzDkOUDgEsCtgeFTmjrDJ93VNdJBj2bMmFU8r1x0IOEKv 4KhZc0nK0UMb8jYadSAZO6KazWMwwNHLkPgbGKVk3kfHbn1CknU1SzhwOx5jCcMnh0 ROrwipdtiwBfHaa7xZxVZSiw9X4P/owtrpCKgSww= 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.10 044/236] rcu: Fix to include first blocked task in stall warning Date: Mon, 13 Sep 2021 15:12:29 +0200 Message-Id: <20210913131101.852817750@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131100.316353015@linuxfoundation.org> References: <20210913131100.316353015@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 e6a901a44f76878ed1653626c9ff4cfc5a3f58f8 ] The for loop in rcu_print_task_stall() always omits ts[0], which points to the first task blocking the stalled grace period. This in turn fails to count this first task, which means that ndetected will be equal to zero when all CPUs have passed through their quiescent states and only one task is blocking the stalled grace period. This zero value for ndetected will in turn result in an incorrect "All QSes seen" message: rcu: INFO: rcu_preempt detected stalls on CPUs/tasks: rcu: Tasks blocked on level-1 rcu_node (CPUs 12-23): (detected by 15, t=6504 jiffies, g=164777, q=9011209) rcu: All QSes seen, last rcu_preempt kthread activity 1 (4295252379-4295252378), jiffies_till_next_fqs=1, root ->qsmask 0x2 BUG: sleeping function called from invalid context at include/linux/uaccess.h:156 in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 70613, name: msgstress04 INFO: lockdep is turned off. Preemption disabled at: [] create_object.isra.0+0x204/0x4b0 CPU: 15 PID: 70613 Comm: msgstress04 Kdump: loaded Not tainted 5.12.2-yoctodev-standard #1 Hardware name: Marvell OcteonTX CN96XX board (DT) Call trace: dump_backtrace+0x0/0x2cc show_stack+0x24/0x30 dump_stack+0x110/0x188 ___might_sleep+0x214/0x2d0 __might_sleep+0x7c/0xe0 This commit therefore fixes the loop to include ts[0]. 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, 2 insertions(+), 2 deletions(-) diff --git a/kernel/rcu/tree_stall.h b/kernel/rcu/tree_stall.h index 0435e5e716a8..cdfaa44ffd70 100644 --- a/kernel/rcu/tree_stall.h +++ b/kernel/rcu/tree_stall.h @@ -275,8 +275,8 @@ static int rcu_print_task_stall(struct rcu_node *rnp, unsigned long flags) break; } raw_spin_unlock_irqrestore_rcu_node(rnp, flags); - for (i--; i; i--) { - t = ts[i]; + while (i) { + t = ts[--i]; if (!try_invoke_on_locked_down_task(t, check_slow_task, &rscr)) pr_cont(" P%d", t->pid); else -- 2.30.2