Skip to content

Commit a7c072e

Browse files
committed
scftorture: Block scftorture_invoker() kthreads for offline CPUs
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 <paulmck@kernel.org>
1 parent de77d4d commit a7c072e

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

kernel/scftorture.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,11 +381,14 @@ static void scftorture_invoke_one(struct scf_statistics *scfp, struct torture_ra
381381
// smp_call_function() family of functions.
382382
static int scftorture_invoker(void *arg)
383383
{
384+
int cpu;
384385
DEFINE_TORTURE_RANDOM(rand);
385386
struct scf_statistics *scfp = (struct scf_statistics *)arg;
387+
bool was_offline = false;
386388

387389
VERBOSE_SCFTORTOUT("scftorture_invoker %d: task started", scfp->cpu);
388-
set_cpus_allowed_ptr(current, cpumask_of(scfp->cpu % nr_cpu_ids));
390+
cpu = scfp->cpu % nr_cpu_ids;
391+
set_cpus_allowed_ptr(current, cpumask_of(cpu));
389392
set_user_nice(current, MAX_NICE);
390393
if (holdoff)
391394
schedule_timeout_interruptible(holdoff * HZ);
@@ -408,6 +411,14 @@ static int scftorture_invoker(void *arg)
408411

409412
do {
410413
scftorture_invoke_one(scfp, &rand);
414+
while (cpu_is_offline(cpu) && !torture_must_stop()) {
415+
schedule_timeout_interruptible(HZ / 5);
416+
was_offline = true;
417+
}
418+
if (was_offline) {
419+
set_cpus_allowed_ptr(current, cpumask_of(cpu));
420+
was_offline = false;
421+
}
411422
} while (!torture_must_stop());
412423

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

0 commit comments

Comments
 (0)