From patchwork Fri Sep 8 20:35:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frederic Weisbecker X-Patchwork-Id: 137810 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ab0a:0:b0:3f2:4152:657d with SMTP id m10csp834572vqo; Fri, 8 Sep 2023 15:55:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHjsedtQXVWXIl3aSl7sbRG8vVOnTwSWqKzQJASAuzcxdETYGR1gDthhO/qtyuQC8c/c6qc X-Received: by 2002:a05:6808:2815:b0:3a8:6693:135d with SMTP id et21-20020a056808281500b003a86693135dmr3653935oib.49.1694213739536; Fri, 08 Sep 2023 15:55:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694213739; cv=none; d=google.com; s=arc-20160816; b=Xt76ar2s+FVGgJ7KGYpjl0fYNRDshSJrKm9rOzVu8bxcUC5AzldaV7USy5uHlYbHTa VXlRnREtco1ScszSdsATPkupPGoJk5qAbmxWQ/IH8ioGYAZf8t7itclP+CYFPgDD0cYJ tXtv7oxiSRICVERJN+eWTO2x83iMATJ/dAq/gJBTG0igpmcv8++cFZchhX05w3+3R2JL DAWQwcGwkPGa+F2Au9e7IGiBx8M2VCeDwYvrRcU4JE93URwh4rIAJ56GP8p0AFADhVoX HG8z23STAgFfyW4RrGT+0ZUlEspveOOFcmmVLRnO3uyMkyDHshQl/0piUy3AQ4Xb0x4/ mK8Q== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/zlJ7ne+Yi+AZ1wV8mKuWizqNMvyeIKVqhrzo4m1Dhw=; fh=b/0dXqvz0kAo+07ch4KNz5dZ+JhJoOmBzkQIhQsuGPg=; b=r16ebK4ZTdZQ1UsddwYLsmux6spfngz+2QIQMVKN37rBHy12YEbaCBCnXxX9iq6Pcr e2dDL2vQtjUeNQS4UGM8Vwv101tj3KTjbjbf8wGzjMdoFq6W64m2Gh3GVuG2HrdXpaHq u6Pg53xPP7C56DRcuIndF4LzN/JaNErKH2AZmcz6LPX6AnnwL+Xnvn6dosYvntTbMFbK JgSknBwORmj5uYIunTRcBCE/8f2so6LyhapATgLOp8qbM/yz0BGeskrJt9vH6ag/y6ID aYqj9GB6x1QwpjjZj1y7GcQn/u3J5CCpLwRlORTomCqEgWl8ctl2mFUFAYbmaXtgbWuV YnOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ce3J97XH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bg26-20020a056a02011a00b0054fbd904b6dsi2039676pgb.500.2023.09.08.15.55.37; Fri, 08 Sep 2023 15:55:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ce3J97XH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344078AbjIHUgX (ORCPT + 16 others); Fri, 8 Sep 2023 16:36:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233048AbjIHUgW (ORCPT ); Fri, 8 Sep 2023 16:36:22 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69601B2; Fri, 8 Sep 2023 13:36:18 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 136E9C433CC; Fri, 8 Sep 2023 20:36:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694205378; bh=Zu1FseTcB8ucaQhbROvFuH9zDir/2M+hapV0YqGSd20=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ce3J97XH0oLc7QOib+7DQ/wHo3Jhw1lL1t8k3AbgKGJ/Yb61Sjq+agUCLWVvGPJm5 Ccc8O2a2Kn+X4nH9CL9PvG/sZTKgC87JXPjazn0+nobFMOuJ4e/nxG4/ZRoGXbhmUc gXmofbYu25ZhA50QS964E7BRuGe1vMmHX8TTA7JJsRDd8GzFafPWMUF90WVflxyhQZ ayMv51DVu1PkhwW9PbuOOnukUxvb+UAy0JiDhwTZCfp1oc9U/XdeQEjBt1ktM0qdlz rIfip7CC6D4LsLLV+tczwSUW2yZnPzAjUvc/6EX9JcejTY/K0zUf3f3l8jGnmHSraw myNgxLgUlj2xg== From: Frederic Weisbecker To: "Paul E . McKenney" Cc: LKML , Frederic Weisbecker , rcu , Uladzislau Rezki , Neeraj Upadhyay , Boqun Feng , Joel Fernandes Subject: [PATCH 02/10] rcu: Rename jiffies_till_flush to jiffies_lazy_flush Date: Fri, 8 Sep 2023 22:35:55 +0200 Message-ID: <20230908203603.5865-3-frederic@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908203603.5865-1-frederic@kernel.org> References: <20230908203603.5865-1-frederic@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776511865711864500 X-GMAIL-MSGID: 1776511865711864500 The variable name jiffies_till_flush is too generic and therefore: * It may shadow a global variable * It doesn't tell on what it operates Make the name more precise, along with the related APIs. Signed-off-by: Frederic Weisbecker --- kernel/rcu/rcu.h | 8 ++++---- kernel/rcu/rcuscale.c | 6 +++--- kernel/rcu/tree_nocb.h | 20 ++++++++++---------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/kernel/rcu/rcu.h b/kernel/rcu/rcu.h index 56a8466a11a2..4ac4daae9917 100644 --- a/kernel/rcu/rcu.h +++ b/kernel/rcu/rcu.h @@ -541,11 +541,11 @@ enum rcutorture_type { }; #if defined(CONFIG_RCU_LAZY) -unsigned long rcu_lazy_get_jiffies_till_flush(void); -void rcu_lazy_set_jiffies_till_flush(unsigned long j); +unsigned long rcu_get_jiffies_lazy_flush(void); +void rcu_set_jiffies_lazy_flush(unsigned long j); #else -static inline unsigned long rcu_lazy_get_jiffies_till_flush(void) { return 0; } -static inline void rcu_lazy_set_jiffies_till_flush(unsigned long j) { } +static inline unsigned long rcu_get_jiffies_lazy_flush(void) { return 0; } +static inline void rcu_set_jiffies_lazy_flush(unsigned long j) { } #endif #if defined(CONFIG_TREE_RCU) diff --git a/kernel/rcu/rcuscale.c b/kernel/rcu/rcuscale.c index ffdb30495e3c..8db4fedaaa1e 100644 --- a/kernel/rcu/rcuscale.c +++ b/kernel/rcu/rcuscale.c @@ -764,9 +764,9 @@ kfree_scale_init(void) if (kfree_by_call_rcu) { /* do a test to check the timeout. */ - orig_jif = rcu_lazy_get_jiffies_till_flush(); + orig_jif = rcu_get_jiffies_lazy_flush(); - rcu_lazy_set_jiffies_till_flush(2 * HZ); + rcu_set_jiffies_lazy_flush(2 * HZ); rcu_barrier(); jif_start = jiffies; @@ -775,7 +775,7 @@ kfree_scale_init(void) smp_cond_load_relaxed(&rcu_lazy_test1_cb_called, VAL == 1); - rcu_lazy_set_jiffies_till_flush(orig_jif); + rcu_set_jiffies_lazy_flush(orig_jif); if (WARN_ON_ONCE(jiffies_at_lazy_cb - jif_start < 2 * HZ)) { pr_alert("ERROR: call_rcu() CBs are not being lazy as expected!\n"); diff --git a/kernel/rcu/tree_nocb.h b/kernel/rcu/tree_nocb.h index 5598212d1f27..b9eab359c597 100644 --- a/kernel/rcu/tree_nocb.h +++ b/kernel/rcu/tree_nocb.h @@ -264,21 +264,21 @@ static bool wake_nocb_gp(struct rcu_data *rdp, bool force) * left unsubmitted to RCU after those many jiffies. */ #define LAZY_FLUSH_JIFFIES (10 * HZ) -static unsigned long jiffies_till_flush = LAZY_FLUSH_JIFFIES; +static unsigned long jiffies_lazy_flush = LAZY_FLUSH_JIFFIES; #ifdef CONFIG_RCU_LAZY // To be called only from test code. -void rcu_lazy_set_jiffies_till_flush(unsigned long jif) +void rcu_set_jiffies_lazy_flush(unsigned long jif) { - jiffies_till_flush = jif; + jiffies_lazy_flush = jif; } -EXPORT_SYMBOL(rcu_lazy_set_jiffies_till_flush); +EXPORT_SYMBOL(rcu_set_jiffies_lazy_flush); -unsigned long rcu_lazy_get_jiffies_till_flush(void) +unsigned long rcu_get_jiffies_lazy_flush(void) { - return jiffies_till_flush; + return jiffies_lazy_flush; } -EXPORT_SYMBOL(rcu_lazy_get_jiffies_till_flush); +EXPORT_SYMBOL(rcu_get_jiffies_lazy_flush); #endif /* @@ -299,7 +299,7 @@ static void wake_nocb_gp_defer(struct rcu_data *rdp, int waketype, */ if (waketype == RCU_NOCB_WAKE_LAZY && rdp->nocb_defer_wakeup == RCU_NOCB_WAKE_NOT) { - mod_timer(&rdp_gp->nocb_timer, jiffies + jiffies_till_flush); + mod_timer(&rdp_gp->nocb_timer, jiffies + jiffies_lazy_flush); WRITE_ONCE(rdp_gp->nocb_defer_wakeup, waketype); } else if (waketype == RCU_NOCB_WAKE_BYPASS) { mod_timer(&rdp_gp->nocb_timer, jiffies + 2); @@ -482,7 +482,7 @@ static bool rcu_nocb_try_bypass(struct rcu_data *rdp, struct rcu_head *rhp, // flush ->nocb_bypass to ->cblist. if ((ncbs && !bypass_is_lazy && j != READ_ONCE(rdp->nocb_bypass_first)) || (ncbs && bypass_is_lazy && - (time_after(j, READ_ONCE(rdp->nocb_bypass_first) + jiffies_till_flush))) || + (time_after(j, READ_ONCE(rdp->nocb_bypass_first) + jiffies_lazy_flush))) || ncbs >= qhimark) { rcu_nocb_lock(rdp); *was_alldone = !rcu_segcblist_pend_cbs(&rdp->cblist); @@ -723,7 +723,7 @@ static void nocb_gp_wait(struct rcu_data *my_rdp) lazy_ncbs = READ_ONCE(rdp->lazy_len); if (bypass_ncbs && (lazy_ncbs == bypass_ncbs) && - (time_after(j, READ_ONCE(rdp->nocb_bypass_first) + jiffies_till_flush) || + (time_after(j, READ_ONCE(rdp->nocb_bypass_first) + jiffies_lazy_flush) || bypass_ncbs > 2 * qhimark)) { flush_bypass = true; } else if (bypass_ncbs && (lazy_ncbs != bypass_ncbs) &&