Skip to contentSkip to conversation

rcutorture: Don't try to disable to RT throttling.

PATCH In review Sebastian Andrzej Siewior 5 participants 16 messages Nov 5 – Nov 13

Subsystems (4)
lore
Share & tools
lore

Sebastian Andrzej Siewior

author maintainer
#0 lore raw

PATCH 1/1 rcutorture: Don't try to disable to RT throttling.

Commit 450efca7182a5 ("rcutorture: Disable RT throttling for boost tests") added the ability to disable RT throttling while rcutorture was run.

Since v6.12 the DL fair_server takes control of throttling and this interface no longer serves this purpose. That sysctl control still exists but serves a different cause.

There is no in-kernel interface to provide this feature, one needs to echo -1 to each /sys/kernel/debug/sched/fair_server/cpu*/runtime file.

Since sysctl_sched_rt_runtime does not do what it once did, remove it from rcutorture.

---
 kernel/rcu/rcu.h        |  2 --
 kernel/rcu/rcutorture.c | 35 -----------------------------------
 2 files changed, 37 deletions(-)
kernel/rcu/rcu.h +0 -2
index d60444bf3a02d..6d1034e49d411 100644
@@ -69,8 +69,6 @@
 /* A complete grace period count */
 #define RCU_SEQ_GP (RCU_SEQ_STATE_MASK + 1)
 
-extern int sysctl_sched_rt_runtime;
-
 /*
  * Return the counter portion of a sequence number previously returned
  * by rcu_seq_snap() or rcu_seq_current().
kernel/rcu/rcutorture.c +0 -35
index 968343be4e0d1..acab425e72ad5 100644
@@ -1333,39 +1333,6 @@ static unsigned long rcutorture_seq_diff(unsigned long new, unsigned long old)
 	return cur_ops->gp_diff(new, old);
 }
 
-/*
- * RCU torture priority-boost testing.  Runs one real-time thread per
- * CPU for moderate bursts, repeatedly starting grace periods and waiting
- * for them to complete.  If a given grace period takes too long, we assume
- * that priority inversion has occurred.
- */
-
-static int old_rt_runtime = -1;
-
-static void rcu_torture_disable_rt_throttle(void)
-{
-	/*
-	 * Disable RT throttling so that rcutorture's boost threads don't get
-	 * throttled. Only possible if rcutorture is built-in otherwise the
-	 * user should manually do this by setting the sched_rt_period_us and
-	 * sched_rt_runtime sysctls.
-	 */
-	if (!IS_BUILTIN(CONFIG_RCU_TORTURE_TEST) || old_rt_runtime != -1)
-		return;
-
-	old_rt_runtime = sysctl_sched_rt_runtime;
-	sysctl_sched_rt_runtime = -1;
-}
-
-static void rcu_torture_enable_rt_throttle(void)
-{
-	if (!IS_BUILTIN(CONFIG_RCU_TORTURE_TEST) || old_rt_runtime == -1)
-		return;
-
-	sysctl_sched_rt_runtime = old_rt_runtime;
-	old_rt_runtime = -1;
-}
-
 static bool rcu_torture_boost_failed(unsigned long gp_state, unsigned long *start)
 {
 	int cpu;
@@ -3390,7 +3357,6 @@ static int rcutorture_booster_cleanup(unsigned int cpu)
 	mutex_lock(&boost_mutex);
 	t = boost_tasks[cpu];
 	boost_tasks[cpu] = NULL;
-	rcu_torture_enable_rt_throttle();
 	mutex_unlock(&boost_mutex);
 
 	/* This must be outside of the mutex, otherwise deadlock! */
@@ -3428,7 +3394,6 @@ static int rcutorture_booster_init(unsigned int cpu)
 
 	/* Don't allow time recalculation while creating a new task. */
 	mutex_lock(&boost_mutex);
-	rcu_torture_disable_rt_throttle();
 	VERBOSE_TOROUT_STRING("Creating rcu_torture_boost task");
 	boost_tasks[cpu] = kthread_run_on_cpu(rcu_torture_boost, NULL,
 					      cpu, "rcu_torture_boost_%u");
Signature · 1 line
2.55.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Sebastian Andrzej Siewior

Commit 450efca7182a5 ("rcutorture: Disable RT throttling for boost tests") added the ability to disable RT throttling while rcutorture was run.

Since v6.12 the DL fair_server takes control of throttling and this interface no longer serves this purpose. That sysctl control still exists but serves a different cause.

Quoted 6 lines

There is no in-kernel interface to provide this feature, one needs to echo -1 to each /sys/kernel/debug/sched/fair_server/cpu*/runtime file.

Since sysctl_sched_rt_runtime does not do what it once did, remove it from rcutorture.

Thanks a ton for this patch!

Quoted 74 lines

---
kernel/rcu/rcu.h | 2 --
kernel/rcu/rcutorture.c | 35 -----------------------------------

2 files changed, 37 deletions(-)
kernel/rcu/rcu.h +0 -2
index d60444bf3a02d..6d1034e49d411 100644
@@ -69,8 +69,6 @@
 /* A complete grace period count */
 #define RCU_SEQ_GP (RCU_SEQ_STATE_MASK + 1)
 
-extern int sysctl_sched_rt_runtime;
-
 /*
 * Return the counter portion of a sequence number previously returned
 * by rcu_seq_snap() or rcu_seq_current().
kernel/rcu/rcutorture.c +0 -33
index 968343be4e0d1..acab425e72ad5 100644
@@ -1333,39 +1333,6 @@ static unsigned long rcutorture_seq_diff(unsigned long new, unsigned long old)
 	return cur_ops->gp_diff(new, old);
 }
 
-/*
- * RCU torture priority-boost testing.  Runs one real-time thread per
- * CPU for moderate bursts, repeatedly starting grace periods and waiting
- * for them to complete.  If a given grace period takes too long, we assume
- * that priority inversion has occurred.
- */
-
-static int old_rt_runtime = -1;
-
-static void rcu_torture_disable_rt_throttle(void)
-{
-	/*
-	 * Disable RT throttling so that rcutorture's boost threads don't get
-	 * throttled. Only possible if rcutorture is built-in otherwise the
-	 * user should manually do this by setting the sched_rt_period_us and
-	 * sched_rt_runtime sysctls.
-	 */
-	if (!IS_BUILTIN(CONFIG_RCU_TORTURE_TEST) || old_rt_runtime != -1)
-		return;
-
-	old_rt_runtime = sysctl_sched_rt_runtime;
-	sysctl_sched_rt_runtime = -1;
-}
-
-static void rcu_torture_enable_rt_throttle(void)
-{
-	if (!IS_BUILTIN(CONFIG_RCU_TORTURE_TEST) || old_rt_runtime == -1)
-		return;
-
-	sysctl_sched_rt_runtime = old_rt_runtime;
-	old_rt_runtime = -1;
-}
-

static bool rcu_torture_boost_failed(unsigned long gp_state, unsigned long *start)

{
	int cpu;
kernel/rcu/rcutorture.c +0 -1
@@ -3390,7 +3357,6 @@ static int rcutorture_booster_cleanup(unsigned int cpu)
 	mutex_lock(&boost_mutex);
 	t = boost_tasks[cpu];
 	boost_tasks[cpu] = NULL;
-	rcu_torture_enable_rt_throttle();
 	mutex_unlock(&boost_mutex);
 
 	/* This must be outside of the mutex, otherwise deadlock! */

kernel/rcu/rcutorture.c static int rcutorture_booster_init(unsigned int cpu) · line 3399

Quoted 7 lines
kernel/rcu/rcutorture.c +0 -1
@@ -3428,7 +3394,6 @@ static int rcutorture_booster_init(unsigned int cpu)
 
 	/* Don't allow time recalculation while creating a new task. */
 	mutex_lock(&boost_mutex);
-	rcu_torture_disable_rt_throttle();
 	VERBOSE_TOROUT_STRING("Creating rcu_torture_boost task");
 	boost_tasks[cpu] = kthread_run_on_cpu(rcu_torture_boost, NULL,
 					      cpu, "rcu_torture_boost_%u");

--- Thanks!

maintainer
#2 lore raw
In reply to Sebastian Andrzej Siewior
Quoted 8 lines · Sebastian Andrzej Siewior

Commit 450efca7182a5 ("rcutorture: Disable RT throttling for boost tests") added the ability to disable RT throttling while rcutorture was run.

Since v6.12 the DL fair_server takes control of throttling and this interface no longer serves this purpose. That sysctl control still exists but serves a different cause.

Quoted 7 lines

There is no in-kernel interface to provide this feature, one needs to echo -1 to each /sys/kernel/debug/sched/fair_server/cpu*/runtime file.

Since sysctl_sched_rt_runtime does not do what it once did, remove it from rcutorture.

Thank you, but ouch... Does this mean that there is no longer any useful in-kernel way to test RCU priority boosting?

Thanx, Paul

Quoted 81 lines
---
 kernel/rcu/rcu.h        |  2 --
 kernel/rcu/rcutorture.c | 35 -----------------------------------
 2 files changed, 37 deletions(-)
kernel/rcu/rcu.h +0 -2
index d60444bf3a02d..6d1034e49d411 100644
@@ -69,8 +69,6 @@
 /* A complete grace period count */
 #define RCU_SEQ_GP (RCU_SEQ_STATE_MASK + 1)
 
-extern int sysctl_sched_rt_runtime;
-
 /*
  * Return the counter portion of a sequence number previously returned
  * by rcu_seq_snap() or rcu_seq_current().
kernel/rcu/rcutorture.c +0 -35
index 968343be4e0d1..acab425e72ad5 100644
@@ -1333,39 +1333,6 @@ static unsigned long rcutorture_seq_diff(unsigned long new, unsigned long old)
 	return cur_ops->gp_diff(new, old);
 }
 
-/*
- * RCU torture priority-boost testing.  Runs one real-time thread per
- * CPU for moderate bursts, repeatedly starting grace periods and waiting
- * for them to complete.  If a given grace period takes too long, we assume
- * that priority inversion has occurred.
- */
-
-static int old_rt_runtime = -1;
-
-static void rcu_torture_disable_rt_throttle(void)
-{
-	/*
-	 * Disable RT throttling so that rcutorture's boost threads don't get
-	 * throttled. Only possible if rcutorture is built-in otherwise the
-	 * user should manually do this by setting the sched_rt_period_us and
-	 * sched_rt_runtime sysctls.
-	 */
-	if (!IS_BUILTIN(CONFIG_RCU_TORTURE_TEST) || old_rt_runtime != -1)
-		return;
-
-	old_rt_runtime = sysctl_sched_rt_runtime;
-	sysctl_sched_rt_runtime = -1;
-}
-
-static void rcu_torture_enable_rt_throttle(void)
-{
-	if (!IS_BUILTIN(CONFIG_RCU_TORTURE_TEST) || old_rt_runtime == -1)
-		return;
-
-	sysctl_sched_rt_runtime = old_rt_runtime;
-	old_rt_runtime = -1;
-}
-
 static bool rcu_torture_boost_failed(unsigned long gp_state, unsigned long *start)
 {
 	int cpu;
@@ -3390,7 +3357,6 @@ static int rcutorture_booster_cleanup(unsigned int cpu)
 	mutex_lock(&boost_mutex);
 	t = boost_tasks[cpu];
 	boost_tasks[cpu] = NULL;
-	rcu_torture_enable_rt_throttle();
 	mutex_unlock(&boost_mutex);
 
 	/* This must be outside of the mutex, otherwise deadlock! */
@@ -3428,7 +3394,6 @@ static int rcutorture_booster_init(unsigned int cpu)
 
 	/* Don't allow time recalculation while creating a new task. */
 	mutex_lock(&boost_mutex);
-	rcu_torture_disable_rt_throttle();
 	VERBOSE_TOROUT_STRING("Creating rcu_torture_boost task");
 	boost_tasks[cpu] = kthread_run_on_cpu(rcu_torture_boost, NULL,
 					      cpu, "rcu_torture_boost_%u");
Signature · 1 line
2.55.0
maintainer
#3 lore raw
Quoted 16 lines · Paul E. McKenney
Quoted 11 lines · Sebastian Andrzej Siewior

Commit 450efca7182a5 ("rcutorture: Disable RT throttling for boost tests") added the ability to disable RT throttling while rcutorture was run.

Since v6.12 the DL fair_server takes control of throttling and this interface no longer serves this purpose. That sysctl control still exists but serves a different cause.

There is no in-kernel interface to provide this feature, one needs to echo -1 to each /sys/kernel/debug/sched/fair_server/cpu*/runtime file.

Quoted 7 lines
Quoted 4 lines

Since sysctl_sched_rt_runtime does not do what it once did, remove it from rcutorture.

Thank you, but ouch... Does this mean that there is no longer any useful in-kernel way to test RCU priority boosting?

There should be a way to disable DL server. Adding Andreas to check if there is a way. But I am wondering if the prio boost tests are working, then is the DL server throttling broken? ;-)

Thanks

Quoted 84 lines

Thanx, Paul

Quoted 81 lines

---
kernel/rcu/rcu.h | 2 --
kernel/rcu/rcutorture.c | 35 -----------------------------------

2 files changed, 37 deletions(-)
kernel/rcu/rcu.h +0 -2
index d60444bf3a02d..6d1034e49d411 100644
@@ -69,8 +69,6 @@
 /* A complete grace period count */
 #define RCU_SEQ_GP (RCU_SEQ_STATE_MASK + 1)
 
-extern int sysctl_sched_rt_runtime;
-
 /*
 * Return the counter portion of a sequence number previously returned
 * by rcu_seq_snap() or rcu_seq_current().
kernel/rcu/rcutorture.c +0 -36
index 968343be4e0d1..acab425e72ad5 100644
@@ -1333,39 +1333,6 @@ static unsigned long rcutorture_seq_diff(unsigned long new, unsigned long old)
   return cur_ops->gp_diff(new, old);
 }
 
-/*
- * RCU torture priority-boost testing.  Runs one real-time thread per
- * CPU for moderate bursts, repeatedly starting grace periods and waiting
- * for them to complete.  If a given grace period takes too long, we assume
- * that priority inversion has occurred.
- */
-
-static int old_rt_runtime = -1;
-
-static void rcu_torture_disable_rt_throttle(void)
-{
-    /*
-     * Disable RT throttling so that rcutorture's boost threads don't get
-     * throttled. Only possible if rcutorture is built-in otherwise the
-     * user should manually do this by setting the sched_rt_period_us and
-     * sched_rt_runtime sysctls.
-     */
-    if (!IS_BUILTIN(CONFIG_RCU_TORTURE_TEST) || old_rt_runtime != -1)
-        return;
-
-    old_rt_runtime = sysctl_sched_rt_runtime;
-    sysctl_sched_rt_runtime = -1;
-}
-
-static void rcu_torture_enable_rt_throttle(void)
-{
-    if (!IS_BUILTIN(CONFIG_RCU_TORTURE_TEST) || old_rt_runtime == -1)
-        return;
-
-    sysctl_sched_rt_runtime = old_rt_runtime;
-    old_rt_runtime = -1;
-}
-
 static bool rcu_torture_boost_failed(unsigned long gp_state, unsigned long *start)
 {
   int cpu;
@@ -3390,7 +3357,6 @@ static int rcutorture_booster_cleanup(unsigned int cpu)
   mutex_lock(&boost_mutex);
   t = boost_tasks[cpu];
   boost_tasks[cpu] = NULL;
-    rcu_torture_enable_rt_throttle();
   mutex_unlock(&boost_mutex);
 
   /* This must be outside of the mutex, otherwise deadlock! */
@@ -3428,7 +3394,6 @@ static int rcutorture_booster_init(unsigned int cpu)
 
   /* Don't allow time recalculation while creating a new task. */
   mutex_lock(&boost_mutex);
-    rcu_torture_disable_rt_throttle();
   VERBOSE_TOROUT_STRING("Creating rcu_torture_boost task");
   boost_tasks[cpu] = kthread_run_on_cpu(rcu_torture_boost, NULL,
                         cpu, "rcu_torture_boost_%u");
--

2.55.0

author maintainer
#4 lore raw
Quoted 16 lines · Joel Fernandes
Quoted 16 lines · Paul E. McKenney
Quoted 11 lines · Sebastian Andrzej Siewior

Commit 450efca7182a5 ("rcutorture: Disable RT throttling for boost tests") added the ability to disable RT throttling while rcutorture was run.

Since v6.12 the DL fair_server takes control of throttling and this interface no longer serves this purpose. That sysctl control still exists but serves a different cause.

There is no in-kernel interface to provide this feature, one needs to echo -1 to each /sys/kernel/debug/sched/fair_server/cpu*/runtime file.

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

Since sysctl_sched_rt_runtime does not do what it once did, remove it from rcutorture.

Thank you, but ouch... Does this mean that there is no longer any useful in-kernel way to test RCU priority boosting?

The DL server is per-CPU so you would need to check each one if throttling is enabled. But RCU priority boosting is independent. If the test requires SCHED_FIFO priorities and disabling throttling to ensure progress we would have to add something assuming userland can't handle this…

Quoted 3 lines

There should be a way to disable DL server. Adding Andreas to check if there is a way. But I am wondering if the prio boost tests are working, then is the DL server throttling broken? ;-)

As I wrote in the commit message,
| for i in $(find /sys/kernel/debug/sched/fair_server -name runtime); do
| echo 0 > $i; done

would do the job from userland. But we don't have an in-kernel interface (yes, I am bit confused if is 0 or -1, I lean towards 0 now). The server _is_ throttling, this works. I will try check tomorrow how rcutorture behaves. The difference is that throttling is per-CPU and not global so it might not have *that* big of an impact.

Quoted 1 line

Thanks

Sebastian

maintainer
#5 lore raw
Quoted 22 lines · Sebastian Andrzej Siewior
Quoted 21 lines · Joel Fernandes
Quoted 21 lines · Paul E. McKenney
Quoted 15 lines · Sebastian Andrzej Siewior

Commit 450efca7182a5 ("rcutorture: Disable RT throttling for boost tests") added the ability to disable RT throttling while rcutorture was run.

Since v6.12 the DL fair_server takes control of throttling and this interface no longer serves this purpose. That sysctl control still exists but serves a different cause.

There is no in-kernel interface to provide this feature, one needs to echo -1 to each /sys/kernel/debug/sched/fair_server/cpu*/runtime file.

Since sysctl_sched_rt_runtime does not do what it once did, remove it from rcutorture.

Quoted 8 lines
Quoted 2 lines
Quoted 2 lines

Thank you, but ouch... Does this mean that there is no longer any useful in-kernel way to test RCU priority boosting?

The DL server is per-CPU so you would need to check each one if throttling is enabled. But RCU priority boosting is independent. If the test requires SCHED_FIFO priorities and disabling throttling to ensure progress we would have to add something assuming userland can't handle this…

Just to restate, the current tests run a CPU-bound kthread at real-time priority for some tens of seconds (controlled by the test_boost_duration module parameter) in order to see if RCU priority boosting correctly boosts the readers higher than that priority. If there is any throttling of any of those CPU-bound kthreads in the meantime, we get a false negative, that is, RCU priority boosting appears to be working when it might not be.

Quoted 3 lines
Quoted 3 lines

There should be a way to disable DL server. Adding Andreas to check if there is a way. But I am wondering if the prio boost tests are working, then is the DL server throttling broken? ;-)

Looking forward to Andreas's info!

Inability to disable throttling would not result in test failure, but instead potentially undeserved test success. ;-)

Quoted 9 lines

As I wrote in the commit message,
| for i in $(find /sys/kernel/debug/sched/fair_server -name runtime); do
| echo 0 > $i; done

would do the job from userland. But we don't have an in-kernel interface (yes, I am bit confused if is 0 or -1, I lean towards 0 now). The server _is_ throttling, this works. I will try check tomorrow how rcutorture behaves. The difference is that throttling is per-CPU and not global so it might not have *that* big of an impact.

In theory, it is possible to extend rcutorture's mkinitrd.sh script to create the /sys/kernel/debug directory and to mount debugfs on it, and then implementing the above bash for loop in C, but in practice that is feeling very hacky at the moment. :-(

Thanx, Paul

#6 lore raw
In reply to Joel Fernandes

Hello,

Quoted 19 lines · Joel Fernandes
Quoted 19 lines · Paul E. McKenney
Quoted 14 lines · Sebastian Andrzej Siewior

Commit 450efca7182a5 ("rcutorture: Disable RT throttling for boost tests") added the ability to disable RT throttling while rcutorture was run.

Since v6.12 the DL fair_server takes control of throttling and this interface no longer serves this purpose. That sysctl control still exists but serves a different cause.

There is no in-kernel interface to provide this feature, one needs to echo -1 to each /sys/kernel/debug/sched/fair_server/cpu*/runtime file.

Since sysctl_sched_rt_runtime does not do what it once did, remove it from rcutorture.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Thank you, but ouch... Does this mean that there is no longer any useful in-kernel way to test RCU priority boosting?

There should be a way to disable DL server. Adding Andreas to check if there is a way. But I am wondering if the prio boost tests are working, then is the DL server throttling broken? ;-)

The existing knob to disable the DL servers is debugfs, writing 0 to each /sys/kernel/debug/sched/fair_server/cpu*/runtime disables the fair server and, with sched_ext, the corresponding knob is in /sys/kernel/debug/sched/fair_server/ext_server/cpu*/runtime.

Small nit: the disable value is 0, not -1 (the handler parses an unsigned).

For rcutorture, I don't think there's a ready-made kernel interface, maybe we could add a sched helper that performs the same operation as the debugfs knobs?

And I think a passing boost test doesn't necessarily mean the DL server is necessarily broken. The server can still give a starved reader enough CPU time to leave its RCU read-side critical section without relying on priority boosting. That can mask a boosting failure, much like the old RT throttling could.

Thanks,
-Andrea

Quoted 87 lines

Thanks

Quoted 84 lines

Thanx, Paul

Quoted 81 lines

---
kernel/rcu/rcu.h | 2 --
kernel/rcu/rcutorture.c | 35 -----------------------------------

2 files changed, 37 deletions(-)
kernel/rcu/rcu.h +0 -2
index d60444bf3a02d..6d1034e49d411 100644
@@ -69,8 +69,6 @@
 /* A complete grace period count */
 #define RCU_SEQ_GP (RCU_SEQ_STATE_MASK + 1)
 
-extern int sysctl_sched_rt_runtime;
-
 /*
 * Return the counter portion of a sequence number previously returned
 * by rcu_seq_snap() or rcu_seq_current().
kernel/rcu/rcutorture.c +0 -36
index 968343be4e0d1..acab425e72ad5 100644
@@ -1333,39 +1333,6 @@ static unsigned long rcutorture_seq_diff(unsigned long new, unsigned long old)
   return cur_ops->gp_diff(new, old);
 }
 
-/*
- * RCU torture priority-boost testing.  Runs one real-time thread per
- * CPU for moderate bursts, repeatedly starting grace periods and waiting
- * for them to complete.  If a given grace period takes too long, we assume
- * that priority inversion has occurred.
- */
-
-static int old_rt_runtime = -1;
-
-static void rcu_torture_disable_rt_throttle(void)
-{
-    /*
-     * Disable RT throttling so that rcutorture's boost threads don't get
-     * throttled. Only possible if rcutorture is built-in otherwise the
-     * user should manually do this by setting the sched_rt_period_us and
-     * sched_rt_runtime sysctls.
-     */
-    if (!IS_BUILTIN(CONFIG_RCU_TORTURE_TEST) || old_rt_runtime != -1)
-        return;
-
-    old_rt_runtime = sysctl_sched_rt_runtime;
-    sysctl_sched_rt_runtime = -1;
-}
-
-static void rcu_torture_enable_rt_throttle(void)
-{
-    if (!IS_BUILTIN(CONFIG_RCU_TORTURE_TEST) || old_rt_runtime == -1)
-        return;
-
-    sysctl_sched_rt_runtime = old_rt_runtime;
-    old_rt_runtime = -1;
-}
-
 static bool rcu_torture_boost_failed(unsigned long gp_state, unsigned long *start)
 {
   int cpu;
@@ -3390,7 +3357,6 @@ static int rcutorture_booster_cleanup(unsigned int cpu)
   mutex_lock(&boost_mutex);
   t = boost_tasks[cpu];
   boost_tasks[cpu] = NULL;
-    rcu_torture_enable_rt_throttle();
   mutex_unlock(&boost_mutex);
 
   /* This must be outside of the mutex, otherwise deadlock! */
@@ -3428,7 +3394,6 @@ static int rcutorture_booster_init(unsigned int cpu)
 
   /* Don't allow time recalculation while creating a new task. */
   mutex_lock(&boost_mutex);
-    rcu_torture_disable_rt_throttle();
   VERBOSE_TOROUT_STRING("Creating rcu_torture_boost task");
   boost_tasks[cpu] = kthread_run_on_cpu(rcu_torture_boost, NULL,
                         cpu, "rcu_torture_boost_%u");
--

2.55.0

maintainer
#7 lore raw
Quoted 29 lines · Andrea Righi

Hello,

Quoted 19 lines · Joel Fernandes
Quoted 19 lines · Paul E. McKenney
Quoted 14 lines · Sebastian Andrzej Siewior

Commit 450efca7182a5 ("rcutorture: Disable RT throttling for boost tests") added the ability to disable RT throttling while rcutorture was run.

Since v6.12 the DL fair_server takes control of throttling and this interface no longer serves this purpose. That sysctl control still exists but serves a different cause.

There is no in-kernel interface to provide this feature, one needs to echo -1 to each /sys/kernel/debug/sched/fair_server/cpu*/runtime file.

Since sysctl_sched_rt_runtime does not do what it once did, remove it from rcutorture.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Thank you, but ouch... Does this mean that there is no longer any useful in-kernel way to test RCU priority boosting?

There should be a way to disable DL server. Adding Andreas to check if there is a way. But I am wondering if the prio boost tests are working, then is the DL server throttling broken? ;-)

Quoted 7 lines

The existing knob to disable the DL servers is debugfs, writing 0 to each /sys/kernel/debug/sched/fair_server/cpu*/runtime disables the fair server and, with sched_ext, the corresponding knob is in /sys/kernel/debug/sched/fair_server/ext_server/cpu*/runtime.

Small nit: the disable value is 0, not -1 (the handler parses an unsigned).

Thank you for the clarification!

Quoted 3 lines

For rcutorture, I don't think there's a ready-made kernel interface, maybe we could add a sched helper that performs the same operation as the debugfs knobs?

I would very much appreciate that. ;-)

Quoted 5 lines

And I think a passing boost test doesn't necessarily mean the DL server is necessarily broken. The server can still give a starved reader enough CPU time to leave its RCU read-side critical section without relying on priority boosting. That can mask a boosting failure, much like the old RT throttling could.

The way that rcutorture deals with this (or attempts to, anyway) is to repeatedly run the boost test, with the interval between consecutive boost tests controled by the test_boost_interval module parameter.

So my concern is that throttling might happen on at least one CPU during each four-second boost test.

(I gave a longer duration in my earlier message, apologies, the shorter test is possible because rcutorture tests for grace periods not completing during the test rather than waiting for an RCU CPU stall warning.)

Thanx, Paul

Quoted 91 lines

Thanks,
-Andrea

Quoted 87 lines

Thanks

Quoted 84 lines

Thanx, Paul

Quoted 81 lines

---
kernel/rcu/rcu.h | 2 --
kernel/rcu/rcutorture.c | 35 -----------------------------------

2 files changed, 37 deletions(-)
kernel/rcu/rcu.h +0 -2
index d60444bf3a02d..6d1034e49d411 100644
@@ -69,8 +69,6 @@
 /* A complete grace period count */
 #define RCU_SEQ_GP (RCU_SEQ_STATE_MASK + 1)
 
-extern int sysctl_sched_rt_runtime;
-
 /*
 * Return the counter portion of a sequence number previously returned
 * by rcu_seq_snap() or rcu_seq_current().
kernel/rcu/rcutorture.c +0 -36
index 968343be4e0d1..acab425e72ad5 100644
@@ -1333,39 +1333,6 @@ static unsigned long rcutorture_seq_diff(unsigned long new, unsigned long old)
   return cur_ops->gp_diff(new, old);
 }
 
-/*
- * RCU torture priority-boost testing.  Runs one real-time thread per
- * CPU for moderate bursts, repeatedly starting grace periods and waiting
- * for them to complete.  If a given grace period takes too long, we assume
- * that priority inversion has occurred.
- */
-
-static int old_rt_runtime = -1;
-
-static void rcu_torture_disable_rt_throttle(void)
-{
-    /*
-     * Disable RT throttling so that rcutorture's boost threads don't get
-     * throttled. Only possible if rcutorture is built-in otherwise the
-     * user should manually do this by setting the sched_rt_period_us and
-     * sched_rt_runtime sysctls.
-     */
-    if (!IS_BUILTIN(CONFIG_RCU_TORTURE_TEST) || old_rt_runtime != -1)
-        return;
-
-    old_rt_runtime = sysctl_sched_rt_runtime;
-    sysctl_sched_rt_runtime = -1;
-}
-
-static void rcu_torture_enable_rt_throttle(void)
-{
-    if (!IS_BUILTIN(CONFIG_RCU_TORTURE_TEST) || old_rt_runtime == -1)
-        return;
-
-    sysctl_sched_rt_runtime = old_rt_runtime;
-    old_rt_runtime = -1;
-}
-
 static bool rcu_torture_boost_failed(unsigned long gp_state, unsigned long *start)
 {
   int cpu;
@@ -3390,7 +3357,6 @@ static int rcutorture_booster_cleanup(unsigned int cpu)
   mutex_lock(&boost_mutex);
   t = boost_tasks[cpu];
   boost_tasks[cpu] = NULL;
-    rcu_torture_enable_rt_throttle();
   mutex_unlock(&boost_mutex);
 
   /* This must be outside of the mutex, otherwise deadlock! */
@@ -3428,7 +3394,6 @@ static int rcutorture_booster_init(unsigned int cpu)
 
   /* Don't allow time recalculation while creating a new task. */
   mutex_lock(&boost_mutex);
-    rcu_torture_disable_rt_throttle();
   VERBOSE_TOROUT_STRING("Creating rcu_torture_boost task");
   boost_tasks[cpu] = kthread_run_on_cpu(rcu_torture_boost, NULL,
                         cpu, "rcu_torture_boost_%u");
--

2.55.0

author maintainer
#8 lore raw
Quoted 5 lines · Paul E. McKenney
Quoted 3 lines

For rcutorture, I don't think there's a ready-made kernel interface, maybe we could add a sched helper that performs the same operation as the debugfs knobs?

I would very much appreciate that. ;-)

This maybe? Since it is built-in only, there is no need to restore the old state, is there?

kernel/rcu/rcutorture.c +4 -0
@@ -1333,6 +1333,8 @@ static unsigned long rcutorture_seq_diff(unsigned long new, unsigned long old)
 	return cur_ops->gp_diff(new, old);
 }
 
+void dl_server_fair_disable(unsigned int cpu);
+
 static bool rcu_torture_boost_failed(unsigned long gp_state, unsigned long *start)
 {
 	int cpu;
@@ -3394,6 +3396,8 @@ static int rcutorture_booster_init(unsigned int cpu)
 
 	/* Don't allow time recalculation while creating a new task. */
 	mutex_lock(&boost_mutex);
+	if (IS_BUILTIN(CONFIG_RCU_TORTURE_TEST))
+		dl_server_fair_disable(cpu);
 	VERBOSE_TOROUT_STRING("Creating rcu_torture_boost task");
 	boost_tasks[cpu] = kthread_run_on_cpu(rcu_torture_boost, NULL,
 					      cpu, "rcu_torture_boost_%u");
kernel/sched/deadline.c +25 -0
index 076a6c2f017bb..45b1251922c4f 100644
@@ -1921,6 +1921,31 @@ int dl_server_apply_params(struct sched_dl_entity *dl_se, u64 runtime, u64 perio
 	return 0;
 }
 
+#ifdef CONFIG_RCU_TORTURE_TEST
+/*
+ * The RCU-TORTURE built-in test will disable fair-server to avoid any
+ * throttling while testing RCU-boosting.
+ * If compiled as module then the user needs to disable it manually before
+ * loading the module.
+ */
+void dl_server_fair_disable(unsigned int cpu);
+
+void dl_server_fair_disable(unsigned int cpu)
+{
+	struct rq *rq = cpu_rq(cpu);
+	int retval;
+
+	scoped_guard (rq_lock_irqsave, rq) {
+		struct sched_dl_entity *dl_se = &rq->fair_server;
+
+		update_rq_clock(rq);
+		dl_server_stop(dl_se);
+		retval = dl_server_apply_params(dl_se, 0, dl_se->dl_period, 0);
+	}
+	WARN_ON_ONCE(retval);
+}
+#endif
+
 /*
  * Add @dl_se's bw to the root-domain accounting.
  *
Signature · 1 line
2.55.0
maintainer
#9 lore raw
Quoted 9 lines · Sebastian Andrzej Siewior
Quoted 5 lines · Paul E. McKenney
Quoted 3 lines

For rcutorture, I don't think there's a ready-made kernel interface, maybe we could add a sched helper that performs the same operation as the debugfs knobs?

I would very much appreciate that. ;-)

This maybe? Since it is built-in only, there is no need to restore the old state, is there?

Hearing no objections, I will start testing this. I am applying both of your patches from this email thread, but please let me know if something else would work better.

I would expect that this command would result in rcutorture complaining about priority-boost failures because SRCU does not support priority boosting.

tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration 15 --configs SRCU-P --bootargs "rcutorture.test_boost=2" --trust-make

But please correct me if I missed a turn in here somewhere.

And yes, in the built-in case we normally don't care about restoring state. The usual situation is that the system (usually a guest OS) is brought down at the end of the test anyway, in contrast to running rcutorture non-builtin, that is, using modprobe and rmmod.

Thanx, Paul

Quoted 59 lines
kernel/rcu/rcutorture.c +4 -0
@@ -1333,6 +1333,8 @@ static unsigned long rcutorture_seq_diff(unsigned long new, unsigned long old)
 	return cur_ops->gp_diff(new, old);
 }
 
+void dl_server_fair_disable(unsigned int cpu);
+
 static bool rcu_torture_boost_failed(unsigned long gp_state, unsigned long *start)
 {
 	int cpu;
@@ -3394,6 +3396,8 @@ static int rcutorture_booster_init(unsigned int cpu)
 
 	/* Don't allow time recalculation while creating a new task. */
 	mutex_lock(&boost_mutex);
+	if (IS_BUILTIN(CONFIG_RCU_TORTURE_TEST))
+		dl_server_fair_disable(cpu);
 	VERBOSE_TOROUT_STRING("Creating rcu_torture_boost task");
 	boost_tasks[cpu] = kthread_run_on_cpu(rcu_torture_boost, NULL,
 					      cpu, "rcu_torture_boost_%u");
kernel/sched/deadline.c +25 -0
index 076a6c2f017bb..45b1251922c4f 100644
@@ -1921,6 +1921,31 @@ int dl_server_apply_params(struct sched_dl_entity *dl_se, u64 runtime, u64 perio
 	return 0;
 }
 
+#ifdef CONFIG_RCU_TORTURE_TEST
+/*
+ * The RCU-TORTURE built-in test will disable fair-server to avoid any
+ * throttling while testing RCU-boosting.
+ * If compiled as module then the user needs to disable it manually before
+ * loading the module.
+ */
+void dl_server_fair_disable(unsigned int cpu);
+
+void dl_server_fair_disable(unsigned int cpu)
+{
+	struct rq *rq = cpu_rq(cpu);
+	int retval;
+
+	scoped_guard (rq_lock_irqsave, rq) {
+		struct sched_dl_entity *dl_se = &rq->fair_server;
+
+		update_rq_clock(rq);
+		dl_server_stop(dl_se);
+		retval = dl_server_apply_params(dl_se, 0, dl_se->dl_period, 0);
+	}
+	WARN_ON_ONCE(retval);
+}
+#endif
+
 /*
  * Add @dl_se's bw to the root-domain accounting.
  *
Signature · 1 line
2.55.0
author maintainer
#10 lore raw
Quoted 6 lines · Paul E. McKenney
Quoted 5 lines · Sebastian Andrzej Siewior
Quoted 4 lines · Paul E. McKenney
Quoted 3 lines

For rcutorture, I don't think there's a ready-made kernel interface, maybe we could add a sched helper that performs the same operation as the debugfs knobs?

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

I would very much appreciate that. ;-)

This maybe? Since it is built-in only, there is no need to restore the old state, is there?

Hearing no objections, I will start testing this. I am applying both of your patches from this email thread, but please let me know if something else would work better.

I have kept the first one and added a proper body for the second. I intend to repost it later today if nothing goes wrong.

Quoted 7 lines

I would expect that this command would result in rcutorture complaining about priority-boost failures because SRCU does not support priority boosting.

tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration 15 --configs SRCU-P --bootargs "rcutorture.test_boost=2" --trust-make

But please correct me if I missed a turn in here somewhere.

SRCU doesn't do boosting so yes.
I just stared at rcu_torture_boost() and I probably miss bits. I would expect this thread to run at SCHED_OTHER and then run at 100% for a period of time within a RCU-read section. Once the RCU machinery decides to start a GP and force a quiescent state it would instruct rcub/ to boost the tasks which stayed in their RCU read section (I *think* to be in RCU-section is enough because the idea was once to get task back on CPU which were scheduled out while in their RCU read section). Once this happens, the task should be with SCHED_FIFO priority and could leave the RCU section, un-boosting itself and passing the test. I don't see RCU-read locks but this might be done differently. I see multiple sched_set_fifo_low(current) but this shouldn't change. (Your priority shouldn't change (becomes lower) if your higher priority is due to priority-boosting.)

Your rcu_torture_boost() runs at FIFO-1. So if it does what I described but at FIFO-1 and rcub runs at FIFO-2 then it should still work. Throttling should just make it go slower.

Quoted 4 lines

And yes, in the built-in case we normally don't care about restoring state. The usual situation is that the system (usually a guest OS) is brought down at the end of the test anyway, in contrast to running rcutorture non-builtin, that is, using modprobe and rmmod.

this makes things easier.

Quoted 1 line

Thanx, Paul

Sebastian

maintainer
#11 lore raw
Quoted 42 lines · Sebastian Andrzej Siewior
Quoted 6 lines · Paul E. McKenney
Quoted 5 lines · Sebastian Andrzej Siewior
Quoted 4 lines · Paul E. McKenney
Quoted 3 lines

For rcutorture, I don't think there's a ready-made kernel interface, maybe we could add a sched helper that performs the same operation as the debugfs knobs?

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

I would very much appreciate that. ;-)

This maybe? Since it is built-in only, there is no need to restore the old state, is there?

Hearing no objections, I will start testing this. I am applying both of your patches from this email thread, but please let me know if something else would work better.

I have kept the first one and added a proper body for the second. I intend to repost it later today if nothing goes wrong.

Quoted 7 lines

I would expect that this command would result in rcutorture complaining about priority-boost failures because SRCU does not support priority boosting.

tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration 15 --configs SRCU-P --bootargs "rcutorture.test_boost=2" --trust-make

But please correct me if I missed a turn in here somewhere.

SRCU doesn't do boosting so yes.
I just stared at rcu_torture_boost() and I probably miss bits. I would expect this thread to run at SCHED_OTHER and then run at 100% for a period of time within a RCU-read section. Once the RCU machinery decides to start a GP and force a quiescent state it would instruct rcub/ to boost the tasks which stayed in their RCU read section (I *think* to be in RCU-section is enough because the idea was once to get task back on CPU which were scheduled out while in their RCU read section). Once this happens, the task should be with SCHED_FIFO priority and could leave the RCU section, un-boosting itself and passing the test. I don't see RCU-read locks but this might be done differently. I see multiple sched_set_fifo_low(current) but this shouldn't change. (Your priority shouldn't change (becomes lower) if your higher priority is due to priority-boosting.)

Quoted 3 lines

Your rcu_torture_boost() runs at FIFO-1. So if it does what I described but at FIFO-1 and rcub runs at FIFO-2 then it should still work. Throttling should just make it go slower.

Unfortunately, my overnight run of TREE03, which does do RCU priority boosting and has for some years, fails with the splat shown at the end of this email. Things go rapidly downhill from there.

For reference, I used this command on a 16-hardware-thread x86 laptop:

tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration 9h --configs TREE03 --bootargs "rcutorture.test_boost=2" --trust-make

The "rcutorture.test_boost=2" is redundant but I was lazy.

Quoted 6 lines
Quoted 4 lines

And yes, in the built-in case we normally don't care about restoring state. The usual situation is that the system (usually a guest OS) is brought down at the end of the test anyway, in contrast to running rcutorture non-builtin, that is, using modprobe and rmmod.

this makes things easier.

Don't worry, it won't happen again. ;-)

Thanx, Paul

Quoted 1 line

Sebastian

------------------------------------------------------------------------

[   35.163107] Oops: divide error: 0000 [#1] SMP PTI
[   35.164020] CPU: 12 UID: 0 PID: 111 Comm: cpuhp/12 Not tainted 7.4.0-rc1-00055-g667ceeb1c083 #35 PREEMPT(full) 
[   35.165977] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.15.0-1 04/01/2014
[   35.167589] RIP: 0010:dl_server_apply_params+0x2fa/0x470
[   35.168677] Code: 00 c1 e0 0a 4c 63 f8 e9 67 fe ff ff 48 8b 43 30 4c 8b 45 50 48 8b 35 55 c9 be 01 48 8b 7d 18 49 29 c0 99 48 21 f7 4c 89 45 50 <f7> 7c 24 2c 81 e7 ff ff 00 00 75 1e 4c 03 04 24 4c 89 45 50 48 8b
[   35.172289] RSP: 0000:ffffa7fd80427d90 EFLAGS: 00010046
[   35.173300] RAX: 0000000000000000 RBX: ffff88c71f52b3a0 RCX: 0000000000000000
[   35.174762] RDX: 0000000000000000 RSI: 000000000000afdd RDI: 0000000000000000
[   35.176165] RBP: ffffffff8840c5c0 R08: 0000000000000000 R09: 0000000000000001
[   35.177664] R10: 0000000000000000 R11: 0000000000000000 R12: 00000000fffffff0
[   35.179115] R13: 000000003b9aca00 R14: 000000000000000c R15: 0000000000000000
[   35.180663] FS:  0000000000000000(0000) GS:ffff88c797138000(0000) knlGS:0000000000000000
[   35.182408] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[   35.183625] CR2: 0000000000000000 CR3: 0000000009430000 CR4: 00000000000006f0
[   35.185179] Call Trace:
[   35.185741]  <TASK>
[   35.186131]  dl_server_fair_disable+0x67/0xa0
[   35.186972]  ? __pfx_rcutorture_booster_init+0x10/0x10
[   35.187993]  rcutorture_booster_init+0x9c/0x1c0
[   35.188828]  cpuhp_invoke_callback+0x2d8/0x480
[   35.189656]  ? __pfx_io_wq_cpu_online+0x10/0x10
[   35.190578]  cpuhp_thread_fun+0x89/0x140
[   35.191415]  smpboot_thread_fn+0xa1/0x260
[   35.192164]  ? __pfx_smpboot_thread_fn+0x10/0x10
[   35.192968]  kthread+0xe7/0x120
[   35.193542]  ? __pfx_kthread+0x10/0x10
[   35.194218]  ret_from_fork+0x1bd/0x220
[   35.194901]  ? __pfx_kthread+0x10/0x10
[   35.195623]  ret_from_fork_asm+0x1a/0x30
[   35.196304]  </TASK>
[   35.196730] Modules linked in:
[   35.197286] ---[ end trace 0000000000000000 ]---
author maintainer
#12 lore raw
Quoted 10 lines · Paul E. McKenney

Unfortunately, my overnight run of TREE03, which does do RCU priority boosting and has for some years, fails with the splat shown at the end of this email. Things go rapidly downhill from there.

For reference, I used this command on a 16-hardware-thread x86 laptop:

tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration 9h --configs TREE03 --bootargs "rcutorture.test_boost=2" --trust-make

The "rcutorture.test_boost=2" is redundant but I was lazy.

I identified the issue. The hotplug notifier runs too early. This is only an issue if the CPU goes up because during "init" the notifier is run while CPU is marked active.
I remember you have a test where the VM/system has X CPUs but you boot with maxcpus=Y where Y < X. In that case the throttler is only disabled on the Y CPUs. If the remaining CPUs are then enabled at runtime then the fair_server remains enabled/ can't be disabled from the hotplug notifier.

Quoted 3 lines
Quoted 1 line

this makes things easier.

Don't worry, it won't happen again. ;-)

However. I could make sure that the fair_server is not enabled on init if the rcu_throttler is built-in. This would make it easier again.

Sebastian

maintainer
#13 lore raw
Quoted 8 lines · Sebastian Andrzej Siewior
Quoted 7 lines · Paul E. McKenney

Unfortunately, my overnight run of TREE03, which does do RCU priority boosting and has for some years, fails with the splat shown at the end of this email. Things go rapidly downhill from there.

For reference, I used this command on a 16-hardware-thread x86 laptop:

Quoted 7 lines
Quoted 3 lines

tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --duration 9h --configs TREE03 --bootargs "rcutorture.test_boost=2" --trust-make

The "rcutorture.test_boost=2" is redundant but I was lazy.

I identified the issue. The hotplug notifier runs too early. This is only an issue if the CPU goes up because during "init" the notifier is run while CPU is marked active.

I hesitate to disable CPU hotplug during RCU priority boosting... Yes, one could argue that real-time workloads shouldn't be doing CPU hotplug. Except that others seem to be working towards making CPU hotplug more friendly to real-time situations.

But what fix did you have in mind?

Quoted 5 lines

I remember you have a test where the VM/system has X CPUs but you boot with maxcpus=Y where Y < X. In that case the throttler is only disabled on the Y CPUs. If the remaining CPUs are then enabled at runtime then the fair_server remains enabled/ can't be disabled from the hotplug notifier.

That is TREE01, and you are right, that might be even more challenging than the TREE03 scenario called out earlier.

I am OK disabling rcutorture testing of RCU priority boosting on TREE01. In fact, there is already a commit headed towards the v7.4 merge window that does just that:

1e924ea92887 ("rcutorture: Disable RCU priority boost testing on non-TREE03 scenarios")

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

this makes things easier.

Don't worry, it won't happen again. ;-)

However. I could make sure that the fair_server is not enabled on init if the rcu_throttler is built-in. This would make it easier again.

At this point, anything that would work and be reasonably robust against future scheduler changes would be very welcome! ;-)

Thanx, Paul

author maintainer
#14 lore raw
Quoted 6 lines · Paul E. McKenney

I hesitate to disable CPU hotplug during RCU priority boosting... Yes, one could argue that real-time workloads shouldn't be doing CPU hotplug. Except that others seem to be working towards making CPU hotplug more friendly to real-time situations.

But what fix did you have in mind?

I was thinking about skipping sched_init_dl_servers() in the built-in case. But now that Joel started to reworking the test, it looks like a better solution.

Sebastian

maintainer
#15 lore raw
Quoted 11 lines · Sebastian Andrzej Siewior
Quoted 6 lines · Paul E. McKenney

I hesitate to disable CPU hotplug during RCU priority boosting... Yes, one could argue that real-time workloads shouldn't be doing CPU hotplug. Except that others seem to be working towards making CPU hotplug more friendly to real-time situations.

But what fix did you have in mind?

I was thinking about skipping sched_init_dl_servers() in the built-in case. But now that Joel started to reworking the test, it looks like a better solution.

Thank you both for your work towards making the scheduler more able to handle this sort of thing and for your support of Joel's approach.

You know, RCU priority boosting seemed *so* simple when I first started working on it! ;-)

Thanx, Paul