summaryrefslogtreecommitdiffstats
path: root/kernel/scftorture.c
diff options
context:
space:
mode:
authorPaul E. McKenney <paulmck@kernel.org>2023-05-16 06:21:02 -0700
committerPaul E. McKenney <paulmck@kernel.org>2023-07-14 15:02:57 -0700
commit4a71be93876171e2d30e413abd33126d8c526791 (patch)
treefced6ee363bb39e06f725b3061ca4f3736fb75df /kernel/scftorture.c
parent013608cd0812bdb21fc26d39ed8fdd2fc76e8b9b (diff)
downloadlinux-4a71be93876171e2d30e413abd33126d8c526791.tar.gz
linux-4a71be93876171e2d30e413abd33126d8c526791.tar.bz2
linux-4a71be93876171e2d30e413abd33126d8c526791.zip
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 <paulmck@kernel.org>
Diffstat (limited to 'kernel/scftorture.c')
-rw-r--r--kernel/scftorture.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/kernel/scftorture.c b/kernel/scftorture.c
index 83c33ba0ca7e..59032aaccd18 100644
--- a/kernel/scftorture.c
+++ b/kernel/scftorture.c
@@ -313,6 +313,7 @@ static void scf_handler_1(void *scfc_in)
// Randomly do an smp_call_function*() invocation.
static void scftorture_invoke_one(struct scf_statistics *scfp, struct torture_random_state *trsp)
{
+ bool allocfail = false;
uintptr_t cpu;
int ret = 0;
struct scf_check *scfcp = NULL;
@@ -327,6 +328,7 @@ static void scftorture_invoke_one(struct scf_statistics *scfp, struct torture_ra
if (!scfcp) {
WARN_ON_ONCE(!IS_ENABLED(CONFIG_KASAN));
atomic_inc(&n_alloc_errs);
+ allocfail = true;
} else {
scfcp->scfc_cpu = -1;
scfcp->scfc_wait = scfsp->scfs_wait;
@@ -433,7 +435,9 @@ static void scftorture_invoke_one(struct scf_statistics *scfp, struct torture_ra
cpus_read_unlock();
else
preempt_enable();
- if (!(torture_random(trsp) & 0xfff))
+ if (allocfail)
+ schedule_timeout_idle((1 + longwait) * HZ); // Let no-wait handlers complete.
+ else if (!(torture_random(trsp) & 0xfff))
schedule_timeout_uninterruptible(1);
}