Skip to content

Commit

Permalink
scftorture: Block scftorture_invoker() kthreads for offline CPUs
Browse files Browse the repository at this point in the history
Currently, CPU-hotplug operations might result in all but two
of (say) 100 CPUs being offline, which in turn might result in
false-positive diagnostics due to overload.  This commit therefore
causes scftorture_invoker() kthreads for offline CPUs to loop blocking
for 200 milliseconds at a time, thus continuously adjusting the number
of threads to match the number of online CPUs.

Signed-off-by: Paul E. McKenney <[email protected]>
  • Loading branch information
paulmckrcu committed Aug 25, 2020
1 parent de77d4d commit a7c072e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion kernel/scftorture.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,11 +381,14 @@ static void scftorture_invoke_one(struct scf_statistics *scfp, struct torture_ra
// smp_call_function() family of functions.
static int scftorture_invoker(void *arg)
{
int cpu;
DEFINE_TORTURE_RANDOM(rand);
struct scf_statistics *scfp = (struct scf_statistics *)arg;
bool was_offline = false;

VERBOSE_SCFTORTOUT("scftorture_invoker %d: task started", scfp->cpu);
set_cpus_allowed_ptr(current, cpumask_of(scfp->cpu % nr_cpu_ids));
cpu = scfp->cpu % nr_cpu_ids;
set_cpus_allowed_ptr(current, cpumask_of(cpu));
set_user_nice(current, MAX_NICE);
if (holdoff)
schedule_timeout_interruptible(holdoff * HZ);
Expand All @@ -408,6 +411,14 @@ static int scftorture_invoker(void *arg)

do {
scftorture_invoke_one(scfp, &rand);
while (cpu_is_offline(cpu) && !torture_must_stop()) {
schedule_timeout_interruptible(HZ / 5);
was_offline = true;
}
if (was_offline) {
set_cpus_allowed_ptr(current, cpumask_of(cpu));
was_offline = false;
}
} while (!torture_must_stop());

VERBOSE_SCFTORTOUT("scftorture_invoker %d ended", scfp->cpu);
Expand Down

0 comments on commit a7c072e

Please sign in to comment.