lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue,  3 Aug 2021 23:54:37 +0100
From:   Valentin Schneider <valentin.schneider@....com>
To:     linux-kernel@...r.kernel.org, rcu@...r.kernel.org,
        linux-rt-users@...r.kernel.org
Cc:     Ingo Molnar <mingo@...nel.org>,
        Peter Zijlstra <peterz@...radead.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Steven Rostedt <rostedt@...dmis.org>,
        Daniel Bristot de Oliveira <bristot@...hat.com>,
        Frederic Weisbecker <frederic@...nel.org>,
        "Paul E. McKenney" <paulmck@...nel.org>,
        Josh Triplett <josh@...htriplett.org>,
        Davidlohr Bueso <dave@...olabs.net>,
        Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
        Lai Jiangshan <jiangshanlai@...il.com>,
        Joel Fernandes <joel@...lfernandes.org>
Subject: [PATCH 2/2] rcutorture: Nudge ksoftirqd priority for RCU boost testing

As pointed out by commit 5e59fba573e6 ("rcutorture: Fix testing of RCU
priority boosting"), timer expiry needs to run at a priority higher than
that of the rcu_torture_boost threads (FIFO1) for RCU boost testing to
function. If that's not the case, the rcu_torture_boost threads will
prevent the wakeup of the RCU grace-period kthread, which means no boosting
will be initiated.

Instead of setting this up manually, check the priority of ksoftirqd before
starting the RCU boost test and nudge if required.

Note that this does not attempt to save and restore the scheduler
parameters of ksoftirqd.

Signed-off-by: Valentin Schneider <valentin.schneider@....com>
---
 kernel/rcu/rcutorture.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
index 680f66b65f14..3dd5fa75f469 100644
--- a/kernel/rcu/rcutorture.c
+++ b/kernel/rcu/rcutorture.c
@@ -948,12 +948,26 @@ static int rcu_torture_boost(void *arg)
 	unsigned long endtime;
 	unsigned long oldstarttime;
 	struct rcu_boost_inflight rbi = { .inflight = 0 };
+	struct task_struct *ksoftirqd = this_cpu_ksoftirqd();
 
 	VERBOSE_TOROUT_STRING("rcu_torture_boost started");
 
 	/* Set real-time priority. */
 	sched_set_fifo_low(current);
 
+	/*
+	 * Boost testing requires TIMER_SOFTIRQ to run at a higher priority
+	 * than the CPU-hogging torture kthreads, otherwise said threads
+	 * will never let timer expiry for the RCU GP kthread happen, which will
+	 * prevent any boosting.
+	 */
+	if (current->normal_prio < ksoftirqd->normal_prio) {
+		struct sched_param sp = { .sched_priority = 2 };
+
+		pr_alert("%s(): Adjusting %s priority\n", __func__, ksoftirqd->comm);
+		sched_setscheduler_nocheck(ksoftirqd, SCHED_FIFO, &sp);
+	}
+
 	init_rcu_head_on_stack(&rbi.rcu);
 	/* Each pass through the following loop does one boost-test cycle. */
 	do {
-- 
2.25.1

Powered by blists - more mailing lists