Skip to content

Commit 0203b48

Browse files
paulmckrcuurezki
authored andcommitted
torture: Add dowarn argument to torture_sched_setaffinity()
Current use cases of torture_sched_setaffinity() are well served by its unconditional warning on error. However, an upcoming use case for a preemption kthread needs to avoid warnings that might otherwise arise when that kthread attempted to bind itself to a CPU on its way offline. This commit therefore adds a dowarn argument that, when false, suppresses the warning. Signed-off-by: Paul E. McKenney <[email protected]> Signed-off-by: Uladzislau Rezki (Sony) <[email protected]>
1 parent fac04ef commit 0203b48

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

include/linux/torture.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ void _torture_stop_kthread(char *m, struct task_struct **tp);
130130
#endif
131131

132132
#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)
133-
long torture_sched_setaffinity(pid_t pid, const struct cpumask *in_mask);
133+
long torture_sched_setaffinity(pid_t pid, const struct cpumask *in_mask, bool dowarn);
134134
#endif
135135

136136
#endif /* __LINUX_TORTURE_H */

kernel/locking/locktorture.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ static const struct kernel_param_ops lt_bind_ops = {
106106
module_param_cb(bind_readers, &lt_bind_ops, &bind_readers, 0644);
107107
module_param_cb(bind_writers, &lt_bind_ops, &bind_writers, 0644);
108108

109-
long torture_sched_setaffinity(pid_t pid, const struct cpumask *in_mask);
109+
long torture_sched_setaffinity(pid_t pid, const struct cpumask *in_mask, bool dowarn);
110110

111111
static struct task_struct *stats_task;
112112
static struct task_struct **writer_tasks;
@@ -1358,7 +1358,7 @@ static int __init lock_torture_init(void)
13581358
if (torture_init_error(firsterr))
13591359
goto unwind;
13601360
if (cpumask_nonempty(bind_writers))
1361-
torture_sched_setaffinity(writer_tasks[i]->pid, bind_writers);
1361+
torture_sched_setaffinity(writer_tasks[i]->pid, bind_writers, true);
13621362

13631363
create_reader:
13641364
if (cxt.cur_ops->readlock == NULL || (j >= cxt.nrealreaders_stress))
@@ -1369,7 +1369,7 @@ static int __init lock_torture_init(void)
13691369
if (torture_init_error(firsterr))
13701370
goto unwind;
13711371
if (cpumask_nonempty(bind_readers))
1372-
torture_sched_setaffinity(reader_tasks[j]->pid, bind_readers);
1372+
torture_sched_setaffinity(reader_tasks[j]->pid, bind_readers, true);
13731373
}
13741374
if (stat_interval > 0) {
13751375
firsterr = torture_create_kthread(lock_torture_stats, NULL,

kernel/rcu/rcutorture.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ static void synchronize_rcu_trivial(void)
857857
int cpu;
858858

859859
for_each_online_cpu(cpu) {
860-
torture_sched_setaffinity(current->pid, cpumask_of(cpu));
860+
torture_sched_setaffinity(current->pid, cpumask_of(cpu), true);
861861
WARN_ON_ONCE(raw_smp_processor_id() != cpu);
862862
}
863863
}

kernel/rcu/update.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -527,12 +527,12 @@ EXPORT_SYMBOL_GPL(do_trace_rcu_torture_read);
527527

528528
#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)
529529
/* Get rcutorture access to sched_setaffinity(). */
530-
long torture_sched_setaffinity(pid_t pid, const struct cpumask *in_mask)
530+
long torture_sched_setaffinity(pid_t pid, const struct cpumask *in_mask, bool dowarn)
531531
{
532532
int ret;
533533

534534
ret = sched_setaffinity(pid, in_mask);
535-
WARN_ONCE(ret, "%s: sched_setaffinity(%d) returned %d\n", __func__, pid, ret);
535+
WARN_ONCE(dowarn && ret, "%s: sched_setaffinity(%d) returned %d\n", __func__, pid, ret);
536536
return ret;
537537
}
538538
EXPORT_SYMBOL_GPL(torture_sched_setaffinity);

0 commit comments

Comments
 (0)