From: "Uladzislau Rezki (Sony)" <urezki@gmail.com>
To: "Paul E . McKenney" <paulmck@kernel.org>,
Joel Fernandes <joelagnelf@nvidia.com>,
Frederic Weisbecker <frederic@kernel.org>,
Boqun Feng <boqun.feng@gmail.com>
Cc: RCU <rcu@vger.kernel.org>, LKML <linux-kernel@vger.kernel.org>,
Uladzislau Rezki <urezki@gmail.com>
Subject: [PATCH -next v2 02/11] torture: Add torture_sched_set_normal() for user-specified nice values
Date: Tue, 19 May 2026 21:45:15 +0200 [thread overview]
Message-ID: <20260519194524.158515-3-urezki@gmail.com> (raw)
In-Reply-To: <20260519194524.158515-1-urezki@gmail.com>
From: "Paul E. McKenney" <paulmck@kernel.org>
This new torture_sched_set_normal() function clamps the nice value at
the MIN_NICE..MAX_NICE limits, splatting it these limits are exceeded.
It then invokes sched_set_normal() to set the new value. This prevents
more difficult-to-debug failures within the scheduler.
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
---
include/linux/torture.h | 1 +
kernel/torture.c | 16 ++++++++++++++++
2 files changed, 17 insertions(+)
diff --git a/include/linux/torture.h b/include/linux/torture.h
index 1b59056c3b18..c9b47d138302 100644
--- a/include/linux/torture.h
+++ b/include/linux/torture.h
@@ -129,6 +129,7 @@ void _torture_stop_kthread(char *m, struct task_struct **tp);
#else
#define torture_preempt_schedule() do { } while (0)
#endif
+void torture_sched_set_normal(struct task_struct *t, int nice);
#if IS_ENABLED(CONFIG_RCU_TORTURE_TEST) || IS_MODULE(CONFIG_RCU_TORTURE_TEST) || IS_ENABLED(CONFIG_LOCK_TORTURE_TEST) || IS_MODULE(CONFIG_LOCK_TORTURE_TEST)
long torture_sched_setaffinity(pid_t pid, const struct cpumask *in_mask, bool dowarn);
diff --git a/kernel/torture.c b/kernel/torture.c
index 62c1ac777694..77cb3589b19f 100644
--- a/kernel/torture.c
+++ b/kernel/torture.c
@@ -972,3 +972,19 @@ void _torture_stop_kthread(char *m, struct task_struct **tp)
*tp = NULL;
}
EXPORT_SYMBOL_GPL(_torture_stop_kthread);
+
+/*
+ * Set the specified task's niceness value, saturating at limits.
+ * Saturating noisily, but saturating.
+ */
+void torture_sched_set_normal(struct task_struct *t, int nice)
+{
+ int realnice = nice;
+
+ if (WARN_ON_ONCE(realnice > MAX_NICE))
+ realnice = MAX_NICE;
+ if (WARN_ON_ONCE(realnice < MIN_NICE))
+ realnice = MIN_NICE;
+ sched_set_normal(t, realnice);
+}
+EXPORT_SYMBOL_GPL(torture_sched_set_normal);
--
2.47.3
next prev parent reply other threads:[~2026-05-19 19:45 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-19 19:45 [PATCH -next v2 00/11] Candidate patches for the v7.2 merge window Uladzislau Rezki (Sony)
2026-05-19 19:45 ` [PATCH -next v2 01/11] rcutorture: Fully test lazy RCU Uladzislau Rezki (Sony)
2026-05-19 19:45 ` Uladzislau Rezki (Sony) [this message]
2026-05-19 19:45 ` [PATCH -next v2 03/11] torture: Improve kvm-series.sh header comment Uladzislau Rezki (Sony)
2026-05-19 19:45 ` [PATCH -next v2 04/11] torture: Allow "norm" abbreviation for "normal" Uladzislau Rezki (Sony)
2026-05-19 19:45 ` [PATCH -next v2 05/11] srcu: Fix kerneldoc header comment typo in srcu_down_read_fast() Uladzislau Rezki (Sony)
2026-05-19 19:45 ` [PATCH -next v2 06/11] checkpatch: Undeprecate rcu_read_lock_trace() and rcu_read_unlock_trace() Uladzislau Rezki (Sony)
2026-05-19 19:45 ` [PATCH -next v2 07/11] rcu: Simplify rcu_do_batch() by applying clamp() Uladzislau Rezki (Sony)
2026-05-20 12:26 ` Frederic Weisbecker
2026-05-20 13:54 ` Uladzislau Rezki
2026-05-19 19:45 ` [PATCH -next v2 08/11] rcu: Simplify param_set_next_fqs_jiffies() by applying clamp_val() Uladzislau Rezki (Sony)
2026-05-20 12:31 ` Frederic Weisbecker
2026-05-19 19:45 ` [PATCH -next v2 09/11] rcu: Document rcu_access_pointer() feeding into cmpxchg() Uladzislau Rezki (Sony)
2026-05-20 12:44 ` Frederic Weisbecker
2026-05-19 19:45 ` [PATCH -next v2 10/11] rcu: Latch normal synchronize_rcu() path on flood Uladzislau Rezki (Sony)
2026-05-20 14:43 ` Frederic Weisbecker
2026-05-20 15:16 ` Uladzislau Rezki
2026-05-20 22:28 ` Frederic Weisbecker
2026-05-21 5:23 ` Uladzislau Rezki
2026-05-19 19:45 ` [PATCH -next v2 11/11] rcu-tasks: Fix possible boot-time tests failed for the call_rcu_tasks() Uladzislau Rezki (Sony)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260519194524.158515-3-urezki@gmail.com \
--to=urezki@gmail.com \
--cc=boqun.feng@gmail.com \
--cc=frederic@kernel.org \
--cc=joelagnelf@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=paulmck@kernel.org \
--cc=rcu@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®