mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-22 02:17:36 -04:00
torture: Add torture_sched_set_normal() for user-specified nice values
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>
This commit is contained in:
committed by
Uladzislau Rezki (Sony)
parent
aa61e8b4fb
commit
59cf5dbcc9
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user