diff options
author | Iulia Manda <iulia.manda21@gmail.com> | 2014-03-17 09:21:21 -0400 |
---|---|---|
committer | Paul E. McKenney <paulmck@linux.vnet.ibm.com> | 2014-05-14 12:46:14 -0400 |
commit | 5ed63b199c5b58ed150ce50f1ea68de54669b13f (patch) | |
tree | 36e46770633ba73bbcd5450aa1e12ba6213a0cd7 /kernel | |
parent | 64e4b43ae050146fcfafe696e61efc306f73d449 (diff) |
torture: Notice if an all-zero cpumask is passed inside a critical section
In torture_shuffle_tasks function, the check if an all-zero mask can
be passed to set_cpus_allowed_ptr() is redundant after clearing the
shuffle_idle_cpu bit. If the mask had more than one bit set, after
clearing a bit it has at least one bit set. If the mask had only
one bit set, a check is made at the beginning, where the function
returns, as there is no need to shuffle only one cpu.
Also, this code is executed inside a critical section, delimited by
get_online_cpus(), and put_online_cpus(), preventing CPUs from leaving between
the check of num_online_cpus and the calls to set_cpus_allowed_ptr() function.
Signed-off-by: Iulia Manda <iulia.manda21@gmail.com>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/torture.c | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/kernel/torture.c b/kernel/torture.c index bc0ee382b3c8..ae1723a4c751 100644 --- a/kernel/torture.c +++ b/kernel/torture.c | |||
@@ -335,13 +335,8 @@ static void torture_shuffle_tasks(void) | |||
335 | shuffle_idle_cpu = cpumask_next(shuffle_idle_cpu, shuffle_tmp_mask); | 335 | shuffle_idle_cpu = cpumask_next(shuffle_idle_cpu, shuffle_tmp_mask); |
336 | if (shuffle_idle_cpu >= nr_cpu_ids) | 336 | if (shuffle_idle_cpu >= nr_cpu_ids) |
337 | shuffle_idle_cpu = -1; | 337 | shuffle_idle_cpu = -1; |
338 | if (shuffle_idle_cpu != -1) { | 338 | else |
339 | cpumask_clear_cpu(shuffle_idle_cpu, shuffle_tmp_mask); | 339 | cpumask_clear_cpu(shuffle_idle_cpu, shuffle_tmp_mask); |
340 | if (cpumask_empty(shuffle_tmp_mask)) { | ||
341 | put_online_cpus(); | ||
342 | return; | ||
343 | } | ||
344 | } | ||
345 | 340 | ||
346 | mutex_lock(&shuffle_task_mutex); | 341 | mutex_lock(&shuffle_task_mutex); |
347 | list_for_each_entry(stp, &shuffle_task_list, st_l) | 342 | list_for_each_entry(stp, &shuffle_task_list, st_l) |