Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Deepin-Kernel-SIG] [Upstream] [linux 6.6-y] rcu: Provide a boot time parameter to control lazy RCU #532

Merged
merged 2 commits into from
Dec 26, 2024

Conversation

opsiff
Copy link
Member

@opsiff opsiff commented Dec 24, 2024

Just provide a option to control lazy rcu, when enable lazy rcu in config.
Now we are not enable it, but maybe in future.

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

joelagnel and others added 2 commits December 24, 2024 17:23
mainline inclusion
from mainline-v6.7-rc1
category: performance

The return keyword is not needed here.

Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
(cherry picked from commit 4502138)
mainline inclusion
from mainline-v6.9-rc1
category: performance

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>
(cherry picked from commit 7f66f09)
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
@@ -2753,6 +2753,9 @@ __call_rcu_common(struct rcu_head *head, rcu_callback_t func, bool lazy_in)
}

#ifdef CONFIG_RCU_LAZY
static bool enable_rcu_lazy __read_mostly = !IS_ENABLED(CONFIG_RCU_LAZY_DEFAULT_OFF);
module_param(enable_rcu_lazy, bool, 0444);

/**
* call_rcu_hurry() - Queue RCU callback for invocation after grace period, and

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: Prefer a maximum 75 chars per line (possible unwrapped commit description?)

@deepin-ci-robot
Copy link

deepin pr auto review

代码审查意见:

  1. kernel/rcu/tree.c文件中,enable_rcu_lazy变量被定义为__read_mostly,这意味着它将在大多数情况下被读取,但只在需要时写入。这有助于减少缓存未命中,提高性能。但是,如果这个变量在运行时需要频繁更新,那么这种优化可能不会带来显著的好处。

  2. module_param(enable_rcu_lazy, bool, 0444);这行代码允许在模块加载时通过命令行参数设置enable_rcu_lazy的值。这是一个好的做法,因为它提供了灵活性。但是,应该确保在设置这个参数时,系统有足够的权限来修改它。

  3. kernel/rcu/tree.c文件中,#else分支定义了enable_rcu_lazyfalse,这意味着如果CONFIG_RCU_LAZY没有被启用,那么enable_rcu_lazy将始终为false。这可能会导致一些依赖于enable_rcu_lazy的代码在CONFIG_RCU_LAZY未启用时无法正常工作。

  4. kernel/rcu/tree.c文件中,call_rcu函数的实现中,enable_rcu_lazy被用作一个布尔值。这是一个好的做法,因为它使得代码更加清晰和易于理解。但是,应该确保在所有可能的情况下,enable_rcu_lazy的值都是正确的。

  5. Documentation/admin-guide/kernel-parameters.txt文件中,新增的rcutree.enable_rcu_lazy参数的描述应该更加详细,包括如何使用这个参数以及它的默认行为。

  6. kernel/rcu/Kconfig文件中,RCU_LAZY_DEFAULT_OFF配置选项的默认值被设置为n,这意味着RCU_LAZY默认是启用的。这可能会导致一些用户在不知道的情况下启用了这个特性,可能会带来意外的副作用。建议将默认值设置为y,除非有特殊的原因需要默认禁用这个特性。

  7. kernel/rcu/Kconfig文件中,RCU_LAZY配置选项的描述应该更加详细,包括它的作用、优点和可能的缺点。

  8. kernel/rcu/Kconfig文件中,RCU_LAZY配置选项依赖于rcu_nocbs=all,这意味着如果rcu_nocbs没有被设置为all,那么RCU_LAZY将无法启用。这可能会导致一些用户无法启用RCU_LAZY,因为他们可能没有设置rcu_nocbs=all。建议重新考虑这个依赖关系,或者提供一种方法来允许用户在不设置rcu_nocbs=all的情况下启用RCU_LAZY

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from opsiff. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@opsiff opsiff merged commit b267bca into linux-6.6.y Dec 26, 2024
7 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants