[PATCH v3 resend 6/6] debug: Toggle lazy at runtime and change flush jiffies
From: Joel Fernandes (Google)
Date: Mon Aug 08 2022 - 23:45:58 EST
Enable/Disable this feature by writing 1 or 0 /proc/sys/vm/rcu_lazy.
Change value of /proc/sys/vm/rcu_lazy_jiffies to change max duration before
flush.
Do not merge, only for debug for reviewers.
Signed-off-by: Joel Fernandes (Google) <joel@xxxxxxxxxxxxxxxxx>
Change-Id: Ia733937531f7a75e75f7b6807319e18c94d70750
---
include/linux/sched/sysctl.h | 3 +++
kernel/rcu/tree_nocb.h | 9 +++++++++
kernel/sysctl.c | 17 +++++++++++++++++
3 files changed, 29 insertions(+)
diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
index 2cd928f15df6..54610f9cd962 100644
--- a/include/linux/sched/sysctl.h
+++ b/include/linux/sched/sysctl.h
@@ -14,6 +14,9 @@ extern unsigned long sysctl_hung_task_timeout_secs;
enum { sysctl_hung_task_timeout_secs = 0 };
#endif
+extern unsigned int sysctl_rcu_lazy;
+extern unsigned int sysctl_rcu_lazy_jiffies;
+
enum sched_tunable_scaling {
SCHED_TUNABLESCALING_NONE,
SCHED_TUNABLESCALING_LOG,
diff --git a/kernel/rcu/tree_nocb.h b/kernel/rcu/tree_nocb.h
index f8d7255f4f0a..2b7d3d87e70b 100644
--- a/kernel/rcu/tree_nocb.h
+++ b/kernel/rcu/tree_nocb.h
@@ -266,6 +266,9 @@ static bool wake_nocb_gp(struct rcu_data *rdp, bool force)
#define LAZY_FLUSH_JIFFIES (10 * HZ)
unsigned long jiffies_till_flush = LAZY_FLUSH_JIFFIES;
+unsigned int sysctl_rcu_lazy_jiffies = LAZY_FLUSH_JIFFIES;
+unsigned int sysctl_rcu_lazy = 1;
+
#ifdef CONFIG_RCU_LAZY
// To be called only from test code.
void rcu_lazy_set_jiffies_till_flush(unsigned long jif)
@@ -292,6 +295,9 @@ static void wake_nocb_gp_defer(struct rcu_data *rdp, int waketype,
struct rcu_data *rdp_gp = rdp->nocb_gp_rdp;
unsigned long mod_jif = 0;
+ /* debug: not for merge */
+ rcu_lazy_set_jiffies_till_flush(sysctl_rcu_lazy_jiffies);
+
raw_spin_lock_irqsave(&rdp_gp->nocb_gp_lock, flags);
/*
@@ -687,6 +693,9 @@ static void nocb_gp_wait(struct rcu_data *my_rdp)
unsigned long wait_gp_seq = 0; // Suppress "use uninitialized" warning.
bool wasempty = false;
+ /* debug: not for merge */
+ rcu_lazy_set_jiffies_till_flush(sysctl_rcu_lazy_jiffies);
+
/*
* Each pass through the following loop checks for CBs and for the
* nearest grace period (if any) to wait for next. The CB kthreads
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index b00f92df0af5..bbe25d635dc0 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -2450,6 +2450,23 @@ static struct ctl_table vm_table[] = {
.extra2 = SYSCTL_ONE,
},
#endif
+#ifdef CONFIG_RCU_LAZY
+ {
+ .procname = "rcu_lazy",
+ .data = &sysctl_rcu_lazy,
+ .maxlen = sizeof(unsigned int),
+ .mode = 0644,
+ .proc_handler = proc_dointvec,
+ },
+ {
+ .procname = "rcu_lazy_jiffies",
+ .data = &sysctl_rcu_lazy_jiffies,
+ .maxlen = sizeof(unsigned int),
+ .mode = 0644,
+ .proc_handler = proc_dointvec,
+ },
+#endif
+
{ }
};
--
2.37.1.559.g78731f0fdb-goog