1

rcu: Rename jiffies_till_flush to jiffies_lazy_flush

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.

Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
Reviewed-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
This commit is contained in:
Frederic Weisbecker 2023-11-15 14:11:26 -05:00 committed by Boqun Feng
parent 41bccc98fb
commit 499d7e7e83
3 changed files with 18 additions and 18 deletions

View File

@ -543,11 +543,11 @@ enum rcutorture_type {
}; };
#if defined(CONFIG_RCU_LAZY) #if defined(CONFIG_RCU_LAZY)
unsigned long rcu_lazy_get_jiffies_till_flush(void); unsigned long rcu_get_jiffies_lazy_flush(void);
void rcu_lazy_set_jiffies_till_flush(unsigned long j); void rcu_set_jiffies_lazy_flush(unsigned long j);
#else #else
static inline unsigned long rcu_lazy_get_jiffies_till_flush(void) { return 0; } static inline unsigned long rcu_get_jiffies_lazy_flush(void) { return 0; }
static inline void rcu_lazy_set_jiffies_till_flush(unsigned long j) { } static inline void rcu_set_jiffies_lazy_flush(unsigned long j) { }
#endif #endif
#if defined(CONFIG_TREE_RCU) #if defined(CONFIG_TREE_RCU)

View File

@ -764,9 +764,9 @@ kfree_scale_init(void)
if (kfree_by_call_rcu) { if (kfree_by_call_rcu) {
/* do a test to check the timeout. */ /* 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(); rcu_barrier();
jif_start = jiffies; jif_start = jiffies;
@ -775,7 +775,7 @@ kfree_scale_init(void)
smp_cond_load_relaxed(&rcu_lazy_test1_cb_called, VAL == 1); 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)) { 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"); pr_alert("ERROR: call_rcu() CBs are not being lazy as expected!\n");

View File

@ -256,6 +256,7 @@ static bool wake_nocb_gp(struct rcu_data *rdp, bool force)
return __wake_nocb_gp(rdp_gp, rdp, force, flags); return __wake_nocb_gp(rdp_gp, rdp, force, flags);
} }
#ifdef CONFIG_RCU_LAZY
/* /*
* LAZY_FLUSH_JIFFIES decides the maximum amount of time that * LAZY_FLUSH_JIFFIES decides the maximum amount of time that
* can elapse before lazy callbacks are flushed. Lazy callbacks * can elapse before lazy callbacks are flushed. Lazy callbacks
@ -264,21 +265,20 @@ static bool wake_nocb_gp(struct rcu_data *rdp, bool force)
* left unsubmitted to RCU after those many jiffies. * left unsubmitted to RCU after those many jiffies.
*/ */
#define LAZY_FLUSH_JIFFIES (10 * HZ) #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. // 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 #endif
/* /*
@ -299,7 +299,7 @@ static void wake_nocb_gp_defer(struct rcu_data *rdp, int waketype,
*/ */
if (waketype == RCU_NOCB_WAKE_LAZY && if (waketype == RCU_NOCB_WAKE_LAZY &&
rdp->nocb_defer_wakeup == RCU_NOCB_WAKE_NOT) { 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 + rcu_get_jiffies_lazy_flush());
WRITE_ONCE(rdp_gp->nocb_defer_wakeup, waketype); WRITE_ONCE(rdp_gp->nocb_defer_wakeup, waketype);
} else if (waketype == RCU_NOCB_WAKE_BYPASS) { } else if (waketype == RCU_NOCB_WAKE_BYPASS) {
mod_timer(&rdp_gp->nocb_timer, jiffies + 2); 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. // flush ->nocb_bypass to ->cblist.
if ((ncbs && !bypass_is_lazy && j != READ_ONCE(rdp->nocb_bypass_first)) || if ((ncbs && !bypass_is_lazy && j != READ_ONCE(rdp->nocb_bypass_first)) ||
(ncbs && bypass_is_lazy && (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) + rcu_get_jiffies_lazy_flush()))) ||
ncbs >= qhimark) { ncbs >= qhimark) {
rcu_nocb_lock(rdp); rcu_nocb_lock(rdp);
*was_alldone = !rcu_segcblist_pend_cbs(&rdp->cblist); *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); lazy_ncbs = READ_ONCE(rdp->lazy_len);
if (bypass_ncbs && (lazy_ncbs == bypass_ncbs) && 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) + rcu_get_jiffies_lazy_flush()) ||
bypass_ncbs > 2 * qhimark)) { bypass_ncbs > 2 * qhimark)) {
flush_bypass = true; flush_bypass = true;
} else if (bypass_ncbs && (lazy_ncbs != bypass_ncbs) && } else if (bypass_ncbs && (lazy_ncbs != bypass_ncbs) &&