Skip to content

Commit d0b654e

Browse files
paulmckrcuFrederic Weisbecker
authored andcommitted
torture: Share torture_random_state with torture_shuffle_tasks()
Both torture_shuffle_tasks() and its caller torture_shuffle() define a torture_random_state structure. This is suboptimal given that torture_shuffle_tasks() runs for a very short period of time. This commit therefore causes torture_shuffle() to pass a pointer to its torture_random_state structure down to torture_shuffle_tasks(). Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
1 parent 0bb80ec commit d0b654e

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

kernel/torture.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -520,9 +520,8 @@ static void torture_shuffle_task_unregister_all(void)
520520
* A special case is when shuffle_idle_cpu = -1, in which case we allow
521521
* the tasks to run on all CPUs.
522522
*/
523-
static void torture_shuffle_tasks(void)
523+
static void torture_shuffle_tasks(struct torture_random_state *trp)
524524
{
525-
DEFINE_TORTURE_RANDOM(rand);
526525
struct shuffle_task *stp;
527526

528527
cpumask_setall(shuffle_tmp_mask);
@@ -543,7 +542,7 @@ static void torture_shuffle_tasks(void)
543542

544543
mutex_lock(&shuffle_task_mutex);
545544
list_for_each_entry(stp, &shuffle_task_list, st_l) {
546-
if (!random_shuffle || torture_random(&rand) & 0x1)
545+
if (!random_shuffle || torture_random(trp) & 0x1)
547546
set_cpus_allowed_ptr(stp->st_t, shuffle_tmp_mask);
548547
}
549548
mutex_unlock(&shuffle_task_mutex);
@@ -562,7 +561,7 @@ static int torture_shuffle(void *arg)
562561
VERBOSE_TOROUT_STRING("torture_shuffle task started");
563562
do {
564563
torture_hrtimeout_jiffies(shuffle_interval, &rand);
565-
torture_shuffle_tasks();
564+
torture_shuffle_tasks(&rand);
566565
torture_shutdown_absorb("torture_shuffle");
567566
} while (!torture_must_stop());
568567
torture_kthread_stopping("torture_shuffle");
@@ -673,7 +672,7 @@ int torture_shutdown_init(int ssecs, void (*cleanup)(void))
673672
if (ssecs > 0) {
674673
shutdown_time = ktime_add(ktime_get(), ktime_set(ssecs, 0));
675674
return torture_create_kthread(torture_shutdown, NULL,
676-
shutdown_task);
675+
shutdown_task);
677676
}
678677
return 0;
679678
}

0 commit comments

Comments
 (0)