From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796384256; b=ls4mAweW2ch6kso+i3YEGXuPdIo4YwPbkTNPsCDKrCtSbjOLs8EqQIEEcy5YPSDaV+ep 4mopDSs2ibgv8VmQpL0zxQsH90gKGI9Eckjn5+3LgreyyArfTCLeBSFcv1ON321c4I03+ RsoNp8mXG3JbeNkzJbtkUjqWwiMOyZQJep/ck2cCxjtafPxw8ADe/komakYdX+XG74gx2 SR36NO3yhPVwxY1cOXfWBiFStoLkSJ8RYcfJx8x2uWffedcT2KE6RetO1NOFFxTWdxycY 83RPoqQmN2XVSaccwNt911GcdN9XQycD6oplu7mCEruFVQ5bwrudAYOGA0YbeNrM+7A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384256; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=amNaa/xQONddZqUbl3rkarMFzrSLVTzG2R848JdXepA=; b=xy69sdgmLwuQFYqyZ2LG0yXQ15yeZZPfq8BbyH4LAaNiv1iGeBFEVyCto9ZSK5u7SOGV LeZPcLzN7nS8JjxT6BQe+jnphVJOBrqgA6nZ9t6jkirUrtVq3IWCannuD+wFg1b63zQB+ pkp6IC5swpi36M0Lv38LnslzLzm93hpxWCA1mFlOBKurgFvnPt/8LsXMI4aWvGL6TOPNl AwPfaEdTWkAPFCHX//xrdsD300j8EjyNHv6nqu4G2NvWyVcnARgnzYTRhHb6+4fbhXfzk TG/3Eg5EeHLGxanr32B/wT5bwODHDV/iWJhpIvY5G83SR5eDEZXVFRG636/U4Ia+FMw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=eh5Ae54U; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 43F2F606A322; Fri, 4 Dec 2026 11:37:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=eh5Ae54U Received: by smtp.kernel.org (Postfix) with ESMTPSA id B43391F000C2; Fri, 4 Dec 2026 11:37:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384256; bh=amNaa/xQONddZqUbl3rkarMFzrSLVTzG2R848JdXepA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=eh5Ae54U8VkSg8rj2Cu29mRx4POpG+Jhuv8omYN2KUqDCS1gHXfes2rPeZ0rgxVDn +OBk3rNzFuLvsJH/yYvMcoqJvas5mq8HntxVsXT+4kfqTXibj3WNXHiI5kLEY6aZY+ UD/T2TuP2zIvzB+P8PLBPi0nLzXPpvoLQh5eE55U= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Nathan Chancellor , Joel Fernandes , Sasha Levin Subject: [PATCH 6.12 544/555] rcu/nocb: Avoid unsequenced accesses to jiffies in show_rcu_nocb_state() Date: Fri, 4 Dec 2026 19:09:47 +0900 Message-ID: <20261204100629.333370697@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Nathan Chancellor commit c3f98ff6309a29979e1867bc3c9d4172755ca122 upstream. After a recent improvement in clang to warn on unsequenced accesses to volatile variables [1], an instance appears in show_rcu_nocb_state(), which can break the build with CONFIG_WERROR=y / W=e: In file included from kernel/rcu/tree.c:5123: kernel/rcu/tree_nocb.h:1651:3: error: unsequenced accesses to volatile qualified 'jiffies' [-Werror,-Wunsequenced] 1650 | jiffies - rdp->nocb_bypass_first, | ~~~~~~~ 1651 | jiffies - rdp->nocb_nobypass_last, | ^ Per C11 5.1.2.3.2, accessing a volatile object is a side effect. Per C11 6.5.2, unsequenced side effects on the same scalar object are undefined behavior. Per C11 6.5.2.2.10/12, the evaluation of arguments in a function call is indeterminately sequenced, meaning any side effects in the arguments are unsequenced. Add a local variable to hold the value of jiffies before the function call so that there are no unsequenced side effects, clearing up the warning. Cc: stable@vger.kernel.org Fixes: f7a81b12d6af ("rcu/nocb: Print no-CBs diagnostics when rcutorture writer unduly delayed") Closes: https://github.com/ClangBuiltLinux/linux/issues/2192 Link: https://github.com/llvm/llvm-project/commit/955715460eaf9188c241c74750637fc82dfcc423 [1] Signed-off-by: Nathan Chancellor Reviewed-by: Joel Fernandes Signed-off-by: Joel Fernandes [nathan: Fix conflicts] Signed-off-by: Nathan Chancellor Signed-off-by: Sasha Levin --- kernel/rcu/tree_nocb.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/rcu/tree_nocb.h b/kernel/rcu/tree_nocb.h index e11ca88677bbb..3d184bbd13ef0 100644 --- a/kernel/rcu/tree_nocb.h +++ b/kernel/rcu/tree_nocb.h @@ -1538,6 +1538,7 @@ static void show_rcu_nocb_state(struct rcu_data *rdp) struct rcu_segcblist *rsclp = &rdp->cblist; bool waslocked; bool wassleep; + unsigned long j; if (rdp->nocb_gp_rdp == rdp) show_rcu_nocb_gp_state(rdp); @@ -1549,6 +1550,7 @@ static void show_rcu_nocb_state(struct rcu_data *rdp) sprintf(bufw, "%ld", rsclp->gp_seq[RCU_WAIT_TAIL]); sprintf(bufr, "%ld", rsclp->gp_seq[RCU_NEXT_READY_TAIL]); + j = jiffies; pr_info(" CB %d^%d->%d %c%c%c%c%c F%ld L%ld C%d %c%c%s%c%s%c%c q%ld %c CPU %d%s\n", rdp->cpu, rdp->nocb_gp_rdp->cpu, nocb_next_rdp ? nocb_next_rdp->cpu : -1, @@ -1557,8 +1559,8 @@ static void show_rcu_nocb_state(struct rcu_data *rdp) "lL"[raw_spin_is_locked(&rdp->nocb_lock)], "sS"[!!rdp->nocb_cb_sleep], ".W"[swait_active(&rdp->nocb_cb_wq)], - jiffies - rdp->nocb_bypass_first, - jiffies - rdp->nocb_nobypass_last, + j - rdp->nocb_bypass_first, + j - rdp->nocb_nobypass_last, rdp->nocb_nobypass_count, ".D"[rcu_segcblist_ready_cbs(rsclp)], ".W"[!rcu_segcblist_segempty(rsclp, RCU_WAIT_TAIL)], -- 2.53.0