Skip to content

Commit 4a71be9

Browse files
committed
scftorture: Pause testing after memory-allocation failure
The scftorture test can quickly execute a large number of calls to no-wait smp_call_function(), each of which holds a block of memory until the corresponding handler is invoked. Especially when the longwait module parameter is specified, this can chew up an arbitrarily large amount of memory. This commit therefore blocks after each memory-allocation failure, with the duration a function of longwait. Signed-off-by: Paul E. McKenney <[email protected]>
1 parent 013608c commit 4a71be9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

kernel/scftorture.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ static void scf_handler_1(void *scfc_in)
313313
// Randomly do an smp_call_function*() invocation.
314314
static void scftorture_invoke_one(struct scf_statistics *scfp, struct torture_random_state *trsp)
315315
{
316+
bool allocfail = false;
316317
uintptr_t cpu;
317318
int ret = 0;
318319
struct scf_check *scfcp = NULL;
@@ -327,6 +328,7 @@ static void scftorture_invoke_one(struct scf_statistics *scfp, struct torture_ra
327328
if (!scfcp) {
328329
WARN_ON_ONCE(!IS_ENABLED(CONFIG_KASAN));
329330
atomic_inc(&n_alloc_errs);
331+
allocfail = true;
330332
} else {
331333
scfcp->scfc_cpu = -1;
332334
scfcp->scfc_wait = scfsp->scfs_wait;
@@ -433,7 +435,9 @@ static void scftorture_invoke_one(struct scf_statistics *scfp, struct torture_ra
433435
cpus_read_unlock();
434436
else
435437
preempt_enable();
436-
if (!(torture_random(trsp) & 0xfff))
438+
if (allocfail)
439+
schedule_timeout_idle((1 + longwait) * HZ); // Let no-wait handlers complete.
440+
else if (!(torture_random(trsp) & 0xfff))
437441
schedule_timeout_uninterruptible(1);
438442
}
439443

0 commit comments

Comments
 (0)