Skip to content

Commit e2a0b78

Browse files
cobrien7paulmckrcu
authored andcommitted
torture: Support randomized shuffling for proxy exec testing
Currently shuffling sets the same cpu affinities for all tasks, which makes us less likely to hit paths involving migrating blocked tasks onto a cpu where they can't run. This patch adds an element of randomness to allow affinities of different writer tasks to diverge. This has helped uncover issues in testing with Proxy Execution Cc: "Paul E. McKenney" <[email protected]> Cc: Josh Triplett <[email protected]> Cc: Joel Fernandes <[email protected]> Cc: Juri Lelli <[email protected]> Cc: Valentin Schneider <[email protected]> Cc: Dietmar Eggemann <[email protected]> Cc: [email protected] Signed-off-by: Connor O'Brien <[email protected]> Signed-off-by: John Stultz <[email protected]> Acked-by: Davidlohr Bueso <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]>
1 parent 9cafe97 commit e2a0b78

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

kernel/torture.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ module_param(verbose_sleep_frequency, int, 0444);
5454
static int verbose_sleep_duration = 1;
5555
module_param(verbose_sleep_duration, int, 0444);
5656

57+
static int random_shuffle;
58+
module_param(random_shuffle, int, 0444);
59+
5760
static char *torture_type;
5861
static int verbose;
5962

@@ -518,6 +521,7 @@ static void torture_shuffle_task_unregister_all(void)
518521
*/
519522
static void torture_shuffle_tasks(void)
520523
{
524+
DEFINE_TORTURE_RANDOM(rand);
521525
struct shuffle_task *stp;
522526

523527
cpumask_setall(shuffle_tmp_mask);
@@ -537,8 +541,10 @@ static void torture_shuffle_tasks(void)
537541
cpumask_clear_cpu(shuffle_idle_cpu, shuffle_tmp_mask);
538542

539543
mutex_lock(&shuffle_task_mutex);
540-
list_for_each_entry(stp, &shuffle_task_list, st_l)
541-
set_cpus_allowed_ptr(stp->st_t, shuffle_tmp_mask);
544+
list_for_each_entry(stp, &shuffle_task_list, st_l) {
545+
if (!random_shuffle || torture_random(&rand) & 0x1)
546+
set_cpus_allowed_ptr(stp->st_t, shuffle_tmp_mask);
547+
}
542548
mutex_unlock(&shuffle_task_mutex);
543549

544550
cpus_read_unlock();

0 commit comments

Comments
 (0)