Skip to content

Commit 7f66f09

Browse files
qais-youseffbq
authored andcommitted
rcu: Provide a boot time parameter to control lazy RCU
To allow more flexible arrangements while still provide a single kernel for distros, provide a boot time parameter to enable/disable lazy RCU. Specify: rcutree.enable_rcu_lazy=[y|1|n|0] Which also requires rcu_nocbs=all at boot time to enable/disable lazy RCU. To disable it by default at build time when CONFIG_RCU_LAZY=y, the new CONFIG_RCU_LAZY_DEFAULT_OFF can be used. Signed-off-by: Qais Yousef (Google) <qyousef@layalina.io> Tested-by: Andrea Righi <andrea.righi@canonical.com> Reviewed-by: Paul E. McKenney <paulmck@kernel.org> Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
1 parent 499d7e7 commit 7f66f09

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5034,6 +5034,11 @@
50345034
this kernel boot parameter, forcibly setting it
50355035
to zero.
50365036

5037+
rcutree.enable_rcu_lazy= [KNL]
5038+
To save power, batch RCU callbacks and flush after
5039+
delay, memory pressure or callback list growing too
5040+
big.
5041+
50375042
rcuscale.gp_async= [KNL]
50385043
Measure performance of asynchronous
50395044
grace-period primitives such as call_rcu().

kernel/rcu/Kconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,19 @@ config RCU_LAZY
314314
To save power, batch RCU callbacks and flush after delay, memory
315315
pressure, or callback list growing too big.
316316

317+
Requires rcu_nocbs=all to be set.
318+
319+
Use rcutree.enable_rcu_lazy=0 to turn it off at boot time.
320+
321+
config RCU_LAZY_DEFAULT_OFF
322+
bool "Turn RCU lazy invocation off by default"
323+
depends on RCU_LAZY
324+
default n
325+
help
326+
Allows building the kernel with CONFIG_RCU_LAZY=y yet keep it default
327+
off. Boot time param rcutree.enable_rcu_lazy=1 can be used to switch
328+
it back on.
329+
317330
config RCU_DOUBLE_CHECK_CB_TIME
318331
bool "RCU callback-batch backup time check"
319332
depends on RCU_EXPERT

kernel/rcu/tree.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2753,6 +2753,9 @@ __call_rcu_common(struct rcu_head *head, rcu_callback_t func, bool lazy_in)
27532753
}
27542754

27552755
#ifdef CONFIG_RCU_LAZY
2756+
static bool enable_rcu_lazy __read_mostly = !IS_ENABLED(CONFIG_RCU_LAZY_DEFAULT_OFF);
2757+
module_param(enable_rcu_lazy, bool, 0444);
2758+
27562759
/**
27572760
* call_rcu_hurry() - Queue RCU callback for invocation after grace period, and
27582761
* flush all lazy callbacks (including the new one) to the main ->cblist while
@@ -2778,6 +2781,8 @@ void call_rcu_hurry(struct rcu_head *head, rcu_callback_t func)
27782781
__call_rcu_common(head, func, false);
27792782
}
27802783
EXPORT_SYMBOL_GPL(call_rcu_hurry);
2784+
#else
2785+
#define enable_rcu_lazy false
27812786
#endif
27822787

27832788
/**
@@ -2826,7 +2831,7 @@ EXPORT_SYMBOL_GPL(call_rcu_hurry);
28262831
*/
28272832
void call_rcu(struct rcu_head *head, rcu_callback_t func)
28282833
{
2829-
__call_rcu_common(head, func, IS_ENABLED(CONFIG_RCU_LAZY));
2834+
__call_rcu_common(head, func, enable_rcu_lazy);
28302835
}
28312836
EXPORT_SYMBOL_GPL(call_rcu);
28322837

0 commit comments

Comments
 (0)