From patchwork Tue Nov 12 14:51:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frederic Weisbecker X-Patchwork-Id: 13872349 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 0D13620010B; Tue, 12 Nov 2024 14:52:17 +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=1731423138; cv=none; b=blvAE/txZHXtUw72M2Hd68zBZ6d/ZgLeSA39OGz2r7mYYeUTYJVzsSsRzsbseUOzH+TlrP1VgdboQexrdjTe4Hehuf39FA9cy+wfASEBngPGalkO+/tSnvcHd1rpXDIRQLycgbe/tp2IRuvD09U4bjsTfTyg/0HvGzb4pq4WWUE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731423138; c=relaxed/simple; bh=5UY7zE2xDmZ/aGLmtXPVX1tGAih/WdNZc9gDIB70zsc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=p0ebkmKRY8lLRsXIwTYy9w+Ol4zzpbEK2G2IvP+vSbgpHBxRBu1y6E1SJG4gPZqR0m1LgWx2slKBxYeFfMjPOYm4Q4cxjx5t0SRWwP90XNytfKJ+5BHyd/Rj0qiQ/xK+YCWsFMzZeLsG6eU/IJ48nCcqPdlTCbmJdrsUd3JlvFY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=s9DUX3WW; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="s9DUX3WW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 09482C4CECD; Tue, 12 Nov 2024 14:52:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731423137; bh=5UY7zE2xDmZ/aGLmtXPVX1tGAih/WdNZc9gDIB70zsc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s9DUX3WWJRRloLMHnjLBrMjIzfxWmhraywqbrSLtMP0pBdcsgVNveghEZEOFsYsTS hiaTF3uRo5BmUl1IBbRoX6BrqaBSMxn0gdTIQHOmsCLWTW31LBfPGhzr9A8hJm5l+w Q9tY4WQzCw+FuP7F0PCK3N9N/pmDmEpElM0JkqH757udj3UTKyyZOpw8m6Ly3eJ9Jg gdZbrYV/FHpEKiiapcrlHqRD8S+iSRcH6QRaEj5NguI5pRBvvHF+xizCu5b3hbjZdJ tR+SE4e19PF7tFidMBIpFeZd2zyHFX5GYAri4VhHEdIJqfSfW08qgV9UadYaNcHk0X ex/f0xvtrPdGg== From: Frederic Weisbecker To: LKML Cc: "Paul E. McKenney" , Boqun Feng , Joel Fernandes , Josh Triplett , Lai Jiangshan , Mathieu Desnoyers , Neeraj Upadhyay , Steven Rostedt , Uladzislau Rezki , Zqiang , rcu , Alexei Starovoitov , Andrii Nakryiko , Peter Zijlstra , Kent Overstreet , bpf@vger.kernel.org, Neeraj Upadhyay , Frederic Weisbecker Subject: [PATCH 03/16] srcu: Introduce srcu_gp_is_expedited() helper function Date: Tue, 12 Nov 2024 15:51:46 +0100 Message-ID: <20241112145159.23032-4-frederic@kernel.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241112145159.23032-1-frederic@kernel.org> References: <20241112145159.23032-1-frederic@kernel.org> Precedence: bulk X-Mailing-List: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Paul E. McKenney" Even though the open-coded expressions usually fit on one line, this commit replaces them with a call to a new srcu_gp_is_expedited() helper function in order to improve readability. Signed-off-by: Paul E. McKenney Cc: Alexei Starovoitov Cc: Andrii Nakryiko Cc: Peter Zijlstra Cc: Kent Overstreet Cc: Reviewed-by: Neeraj Upadhyay Signed-off-by: Frederic Weisbecker --- kernel/rcu/srcutree.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c index 2fe0abade9c0..5b1a315f77bc 100644 --- a/kernel/rcu/srcutree.c +++ b/kernel/rcu/srcutree.c @@ -418,6 +418,16 @@ static void check_init_srcu_struct(struct srcu_struct *ssp) spin_unlock_irqrestore_rcu_node(ssp->srcu_sup, flags); } +/* + * Is the current or any upcoming grace period to be expedited? + */ +static bool srcu_gp_is_expedited(struct srcu_struct *ssp) +{ + struct srcu_usage *sup = ssp->srcu_sup; + + return ULONG_CMP_LT(READ_ONCE(sup->srcu_gp_seq), READ_ONCE(sup->srcu_gp_seq_needed_exp)); +} + /* * Returns approximate total of the readers' ->srcu_lock_count[] values * for the rank of per-CPU counters specified by idx. @@ -622,7 +632,7 @@ static unsigned long srcu_get_delay(struct srcu_struct *ssp) unsigned long jbase = SRCU_INTERVAL; struct srcu_usage *sup = ssp->srcu_sup; - if (ULONG_CMP_LT(READ_ONCE(sup->srcu_gp_seq), READ_ONCE(sup->srcu_gp_seq_needed_exp))) + if (srcu_gp_is_expedited(ssp)) jbase = 0; if (rcu_seq_state(READ_ONCE(sup->srcu_gp_seq))) { j = jiffies - 1; @@ -867,7 +877,7 @@ static void srcu_gp_end(struct srcu_struct *ssp) spin_lock_irq_rcu_node(sup); idx = rcu_seq_state(sup->srcu_gp_seq); WARN_ON_ONCE(idx != SRCU_STATE_SCAN2); - if (ULONG_CMP_LT(READ_ONCE(sup->srcu_gp_seq), READ_ONCE(sup->srcu_gp_seq_needed_exp))) + if (srcu_gp_is_expedited(ssp)) cbdelay = 0; WRITE_ONCE(sup->srcu_last_gp_end, ktime_get_mono_fast_ns());