From nobody Tue Oct 7 12:27:30 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0A8E8235050 for ; Wed, 9 Jul 2025 18:03:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752084218; cv=none; b=G2rISzskSSREkG4n2gcS+kzg/q6eU6f7GrTAi3LwS51u8grJ1Ud3xy44iYeXhhg836detd9EWSmke40AKLs90NG6gAu5RQdb4DLRYSxHnLmOuMjKDDTzfPTpQYqiQUEodN7yQQ7xO8aQbiKWV+kZ7SWQRqQ3KsqHPa04Ct9+/vc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752084218; c=relaxed/simple; bh=I8lESwgVV2YmCOlO1spzAwAlpxikzidKRjeQ4dBVCoc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KiFlODcLLOIe5CtYVG51Kx3y7LULkHwJt9RMX7MZ4PDwWMGPU/bJAczTlYki7KqIfvIQoc1Una0knHR1Hz+SMxCBs+a4jLZss9vbiVEIat6xaK8Dly/j8LVhamLXahPXqOmeeoC6Q2JI42tLIuwaCro5Fd4hFb7IZqUXKW9S6K4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dLDec0iU; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dLDec0iU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6E4B8C4CEF4; Wed, 9 Jul 2025 18:03:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752084217; bh=I8lESwgVV2YmCOlO1spzAwAlpxikzidKRjeQ4dBVCoc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dLDec0iUaqX31hf62P3fe76Mb+XtWtkWsBkc2IvUhTxYhlsQG1aj1xMfvr3Ax4tgs cwMKrd9EbdAZ2PEk7EII5hhMZQEhws9IrIwHkBUortBxyJ2UnAyfSkvMyBxc+ciqZH 7dfAlnDlKkLE7sFl/9ee5T381ypM4RPMOCNYKY8f4DxzE4+o8zefReVNiNhH4mQqld C3dJuh+sElsQ6+Ma7CxCfGN6+nyCh8Iup2J39DcLdjZ+l9qzhyWhIchOQybGS3YWKV 7horklqCmPwTM1je4VX48ZKpMEPc2VBqTO17IoD1zTHNAPdupzU5ORbCr32W5e+16/ TAXXwD0Uxv+xw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 1AB2BCE0B9F; Wed, 9 Jul 2025 11:03:37 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: Andrew Morton , Kuniyuki Iwashima , Mateusz Guzik , Petr Mladek , Steven Rostedt , John Ogness , Sergey Senozhatsky , Jon Pan-Doh , Bjorn Helgaas , Karolina Stolarek , "Paul E. McKenney" Subject: [PATCH v6 1/3] lib: Add trivial kunit test for ratelimit Date: Wed, 9 Jul 2025 11:03:33 -0700 Message-Id: <20250709180335.1716384-1-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a simple single-threaded smoke test for lib/ratelimit.c To run on x86: make ARCH=3Dx86_64 mrproper ./tools/testing/kunit/kunit.py run --arch x86_64 --kconfig_add CONFIG_RATE= LIMIT_KUNIT_TEST=3Dy --kconfig_add CONFIG_SMP=3Dy lib_ratelimit This will fail on old ___ratelimit(), and subsequent patches provide the fixes that are required. [ paulmck: Apply timeout and kunit feedback from Petr Mladek. ] Link: https://lore.kernel.org/all/fbe93a52-365e-47fe-93a4-44a44547d601@paul= mck-laptop/ Link: https://lore.kernel.org/all/20250423115409.3425-1-spasswolf@web.de/ Signed-off-by: Paul E. McKenney Reviewed-by: Petr Mladek Cc: Andrew Morton Cc: Kuniyuki Iwashima Cc: Mateusz Guzik Cc: Steven Rostedt Cc: John Ogness Cc: Sergey Senozhatsky Cc: Jon Pan-Doh Cc: Bjorn Helgaas Cc: Karolina Stolarek --- lib/Kconfig.debug | 11 ++++++ lib/tests/Makefile | 1 + lib/tests/test_ratelimit.c | 79 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 lib/tests/test_ratelimit.c diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index ebe33181b6e6e..d69d27f808340 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -3225,6 +3225,17 @@ config TEST_OBJPOOL =20 If unsure, say N. =20 +config RATELIMIT_KUNIT_TEST + tristate "KUnit Test for correctness and stress of ratelimit" if !KUNIT_A= LL_TESTS + depends on KUNIT + default KUNIT_ALL_TESTS + help + This builds the "test_ratelimit" module that should be used + for correctness verification and concurrent testings of rate + limiting. + + If unsure, say N. + config INT_POW_KUNIT_TEST tristate "Integer exponentiation (int_pow) test" if !KUNIT_ALL_TESTS depends on KUNIT diff --git a/lib/tests/Makefile b/lib/tests/Makefile index 56d6450144828..3edc30a515840 100644 --- a/lib/tests/Makefile +++ b/lib/tests/Makefile @@ -46,5 +46,6 @@ obj-$(CONFIG_STRING_KUNIT_TEST) +=3D string_kunit.o obj-$(CONFIG_STRING_HELPERS_KUNIT_TEST) +=3D string_helpers_kunit.o obj-$(CONFIG_USERCOPY_KUNIT_TEST) +=3D usercopy_kunit.o obj-$(CONFIG_UTIL_MACROS_KUNIT) +=3D util_macros_kunit.o +obj-$(CONFIG_RATELIMIT_KUNIT_TEST) +=3D test_ratelimit.o =20 obj-$(CONFIG_TEST_RUNTIME_MODULE) +=3D module/ diff --git a/lib/tests/test_ratelimit.c b/lib/tests/test_ratelimit.c new file mode 100644 index 0000000000000..0374107f5ea89 --- /dev/null +++ b/lib/tests/test_ratelimit.c @@ -0,0 +1,79 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include + +#include +#include + +/* a simple boot-time regression test */ + +#define TESTRL_INTERVAL (5 * HZ) +static DEFINE_RATELIMIT_STATE(testrl, TESTRL_INTERVAL, 3); + +#define test_ratelimited(test, expected) \ + KUNIT_ASSERT_EQ(test, ___ratelimit(&testrl, "test_ratelimit_smoke"), (exp= ected)) + +static void test_ratelimit_smoke(struct kunit *test) +{ + // Check settings. + KUNIT_ASSERT_GE(test, TESTRL_INTERVAL, 100); + + // Test normal operation. + test_ratelimited(test, true); + test_ratelimited(test, true); + test_ratelimited(test, true); + test_ratelimited(test, false); + + schedule_timeout_idle(TESTRL_INTERVAL - 40); + test_ratelimited(test, false); + + schedule_timeout_idle(50); + test_ratelimited(test, true); + + schedule_timeout_idle(2 * TESTRL_INTERVAL); + test_ratelimited(test, true); + test_ratelimited(test, true); + + schedule_timeout_idle(TESTRL_INTERVAL - 40); + test_ratelimited(test, true); + schedule_timeout_idle(50); + test_ratelimited(test, true); + test_ratelimited(test, true); + test_ratelimited(test, true); + test_ratelimited(test, false); + + // Test disabling. + testrl.burst =3D 0; + test_ratelimited(test, false); + testrl.burst =3D 2; + testrl.interval =3D 0; + test_ratelimited(test, true); + test_ratelimited(test, true); + test_ratelimited(test, true); + test_ratelimited(test, true); + test_ratelimited(test, true); + test_ratelimited(test, true); + test_ratelimited(test, true); + + // Testing re-enabling. + testrl.interval =3D TESTRL_INTERVAL; + test_ratelimited(test, true); + test_ratelimited(test, true); + test_ratelimited(test, false); + test_ratelimited(test, false); +} + +static struct kunit_case sort_test_cases[] =3D { + KUNIT_CASE_SLOW(test_ratelimit_smoke), + {} +}; + +static struct kunit_suite ratelimit_test_suite =3D { + .name =3D "lib_ratelimit", + .test_cases =3D sort_test_cases, +}; + +kunit_test_suites(&ratelimit_test_suite); + +MODULE_DESCRIPTION("___ratelimit() KUnit test suite"); +MODULE_LICENSE("GPL"); --=20 2.40.1 From nobody Tue Oct 7 12:27:30 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0A881233735 for ; Wed, 9 Jul 2025 18:03:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752084218; cv=none; b=bWLeNQOBU3fa2I+wnOP0R+LK1OpmzXI5qX6fJIsXULPA+taWMCHGunFyCHNilqI3lIGYSXajI/SoedW/eBYvlWbTlkvTL3f0oLIvyRRr/YQFADkZFIR2waUdasRFJ05Nxc3ocmdirFoOKL0pkeGKcRCvOT8l1JWSsh0h49NRdkg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752084218; c=relaxed/simple; bh=NPA5PmoXyXmbfTpWG4GPEYufU9pz0dSoZa+DAsVxSgU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XM+eWS4vxb5tmifzdOL3Ijlam0bEOjcEzGo/UXyxKYX4ACIncVEkzCIS3DXWd/sVXSjRa2hTW7B3clSQ8WXUUrZdqBOVvGiUf/EqCFNjxNnr/0fEv7dZMcYBnpT0rqRr1KFBFcI0Br1R2A+ZS4BcVjiotDovC52bvYUVYx4dpxI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oDkFUTKU; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oDkFUTKU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7DA6AC4CEF6; Wed, 9 Jul 2025 18:03:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752084217; bh=NPA5PmoXyXmbfTpWG4GPEYufU9pz0dSoZa+DAsVxSgU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oDkFUTKU+pHZdheAHk6Mag9P6EExptkxRNEZgQs0mwuwocmxVE5zA75FqZbMHtrXj kIUIinhe7ePpmroy1FS3YZ9z0GVun6SMQjYsdqJAkAK1GMJxG6r9IbXfsSvkjZaEnp NqhhCmODM6T8JogW+A2Kh+QVKgRrmfdgFkx8gjzINfKsDpDVF1Dgo8oxKdCoYhtHno eeD0PTQNAEP3+DUe8rC9fqND91KBztvtfrvDTY1prti5kuM5/mx2ugbafxHzdOTOyv BMEMFY6rstQEXjGMM9bwVwcpiKcZCqwSDXin0Zgdt89e9VrYhOTx8JsyyN9Wflc1Vq lVVJk3/pwwUOA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 1C086CE087E; Wed, 9 Jul 2025 11:03:37 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: Andrew Morton , Kuniyuki Iwashima , Mateusz Guzik , Petr Mladek , Steven Rostedt , John Ogness , Sergey Senozhatsky , Jon Pan-Doh , Bjorn Helgaas , Karolina Stolarek , "Paul E . McKenney" Subject: [PATCH v6 2/3] lib: Make the ratelimit test more reliable Date: Wed, 9 Jul 2025 11:03:34 -0700 Message-Id: <20250709180335.1716384-2-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Petr Mladek The selftest fails most of the times when running in qemu with a kernel configured with CONFIG_HZ =3D 250: > test_ratelimit_smoke: 1 callbacks suppressed > # test_ratelimit_smoke: ASSERTION FAILED at lib/tests/test_ratelimit.c:28 > Expected ___ratelimit(&testrl, "test_ratelimit_smoke")= =3D=3D (false), but > ___ratelimit(&testrl, "test_ratelimit_smoke") =3D= =3D 1 (0x1) > (false) =3D=3D 0 (0x0) Try to make the test slightly more reliable by calling the problematic ratelimit in the middle of the interval. Signed-off-by: Petr Mladek Signed-off-by: Paul E. McKenney --- lib/tests/test_ratelimit.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/tests/test_ratelimit.c b/lib/tests/test_ratelimit.c index 0374107f5ea89..5d6ec88546005 100644 --- a/lib/tests/test_ratelimit.c +++ b/lib/tests/test_ratelimit.c @@ -24,19 +24,19 @@ static void test_ratelimit_smoke(struct kunit *test) test_ratelimited(test, true); test_ratelimited(test, false); =20 - schedule_timeout_idle(TESTRL_INTERVAL - 40); + schedule_timeout_idle(TESTRL_INTERVAL / 2); test_ratelimited(test, false); =20 - schedule_timeout_idle(50); + schedule_timeout_idle(TESTRL_INTERVAL * 3 / 4); test_ratelimited(test, true); =20 schedule_timeout_idle(2 * TESTRL_INTERVAL); test_ratelimited(test, true); test_ratelimited(test, true); =20 - schedule_timeout_idle(TESTRL_INTERVAL - 40); + schedule_timeout_idle(TESTRL_INTERVAL / 2 ); test_ratelimited(test, true); - schedule_timeout_idle(50); + schedule_timeout_idle(TESTRL_INTERVAL * 3 / 4); test_ratelimited(test, true); test_ratelimited(test, true); test_ratelimited(test, true); --=20 2.40.1 From nobody Tue Oct 7 12:27:30 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CAB142264B0 for ; Wed, 9 Jul 2025 18:03:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752084217; cv=none; b=n5nDBmA+4GdE5D+qlP1oLrZAkeUtctO4lP/par5KqMNqpoMTy0AvFE6tEmfAfC8iziStoqEypaVz+AESHbUqkETuhxrl1X5PWaXksHQzU8uzx/H7itk2VPPX3vvq6e3sjzQE4ugjQ/ClqzuQ0jV6BYpv0SRGvXxcyLjICyJxtqk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752084217; c=relaxed/simple; bh=/F7mjkjuohfh46YDlcOQVurzihzSdvozO8b9E8yCnhw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mbxmk+E8IUMaemvVBJjytKJ8MNjoWAAKNaju6f19ACA9l8HxyLuJQwTUIeLFUUcFO8daRJOsLo4KH9hQOMo0eIFgDy09TrbrTno82nWESTMUBbnMcHVkBfCVDHylbchkM6heQrtIIoPiwEpILZqgY6H50QcGDBW3R057pHd7sck= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ors1ftUb; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ors1ftUb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8BA1BC4CEF7; Wed, 9 Jul 2025 18:03:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752084217; bh=/F7mjkjuohfh46YDlcOQVurzihzSdvozO8b9E8yCnhw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ors1ftUbxRPqDxY+5MMsyLIA9I0E23bfabFtOQkMEESM1CDPosTC5/SVcFovHGcBa rrNN1nsfSVqzAOyxoUrB1qwi6QeO4CCc0Pia9+D+CN7tRsAPMjlm0MLgp1GqAkpkzL Hi+JYSdosn70vnRFn/zimufkUSS8BIWU0Y5E+WXnq9yyvQRfZExL126XCmlIKg/yct wrPKKiPJD+IjWrVTXMHH54ePRieUSrI9otCH+o4JepLTMf8IvQUMjDkbCkL7H7c987 IlTBiweYjNvjpNp1TRVxJxlZSj5HPMXRIFCUs6lB+iEwrvKiSw7HJu+9AFMIA9m3km 87/kWWA0Q957w== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 1F9B2CE0C26; Wed, 9 Jul 2025 11:03:37 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: Andrew Morton , Kuniyuki Iwashima , Mateusz Guzik , Petr Mladek , Steven Rostedt , John Ogness , Sergey Senozhatsky , Jon Pan-Doh , Bjorn Helgaas , Karolina Stolarek , "Paul E. McKenney" Subject: [PATCH v6 3/3] lib: Add stress test for ratelimit Date: Wed, 9 Jul 2025 11:03:35 -0700 Message-Id: <20250709180335.1716384-3-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a simple stress test for lib/ratelimit.c To run on x86: ./tools/testing/kunit/kunit.py run --arch x86_64 --kconfig_add CONFIG_RATE= LIMIT_KUNIT_TEST=3Dy --kconfig_add CONFIG_SMP=3Dy --qemu_args "-smp 4" lib_= ratelimit On a 16-CPU system, the "4" in "-smp 4" can be varied between 1 and 8. Larger numbers have higher probabilities of introducing delays that break the smoke test. In the extreme case, increasing the number to larger than the number of CPUs in the underlying system is an excellent way to get a test failure. Link: https://lore.kernel.org/all/fbe93a52-365e-47fe-93a4-44a44547d601@paul= mck-laptop/ Link: https://lore.kernel.org/all/20250423115409.3425-1-spasswolf@web.de/ Signed-off-by: Paul E. McKenney Cc: Petr Mladek Cc: Andrew Morton Cc: Kuniyuki Iwashima Cc: Mateusz Guzik Cc: Steven Rostedt Cc: John Ogness Cc: Sergey Senozhatsky Cc: Jon Pan-Doh Cc: Bjorn Helgaas Cc: Karolina Stolarek --- lib/tests/test_ratelimit.c | 69 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 2 deletions(-) diff --git a/lib/tests/test_ratelimit.c b/lib/tests/test_ratelimit.c index 5d6ec88546005..bfaeca49304a5 100644 --- a/lib/tests/test_ratelimit.c +++ b/lib/tests/test_ratelimit.c @@ -4,6 +4,8 @@ =20 #include #include +#include +#include =20 /* a simple boot-time regression test */ =20 @@ -63,14 +65,77 @@ static void test_ratelimit_smoke(struct kunit *test) test_ratelimited(test, false); } =20 -static struct kunit_case sort_test_cases[] =3D { +static struct ratelimit_state stressrl =3D RATELIMIT_STATE_INIT_FLAGS("str= essrl", HZ / 10, 3, + RATELIMIT_MSG_ON_RELEASE); + +static int doneflag; +static const int stress_duration =3D 2 * HZ; + +struct stress_kthread { + unsigned long nattempts; + unsigned long nunlimited; + unsigned long nlimited; + unsigned long nmissed; + struct task_struct *tp; +}; + +static int test_ratelimit_stress_child(void *arg) +{ + struct stress_kthread *sktp =3D arg; + + set_user_nice(current, MAX_NICE); + WARN_ON_ONCE(!sktp->tp); + + while (!READ_ONCE(doneflag)) { + sktp->nattempts++; + if (___ratelimit(&stressrl, __func__)) + sktp->nunlimited++; + else + sktp->nlimited++; + cond_resched(); + } + + sktp->nmissed =3D ratelimit_state_reset_miss(&stressrl); + return 0; +} + +static void test_ratelimit_stress(struct kunit *test) +{ + int i; + const int n_stress_kthread =3D cpumask_weight(cpu_online_mask); + struct stress_kthread skt =3D { 0 }; + struct stress_kthread *sktp =3D kcalloc(n_stress_kthread, sizeof(*sktp), = GFP_KERNEL); + + KUNIT_EXPECT_NOT_NULL_MSG(test, sktp, "Memory allocation failure"); + for (i =3D 0; i < n_stress_kthread; i++) { + sktp[i].tp =3D kthread_run(test_ratelimit_stress_child, &sktp[i], "%s/%i= ", + "test_ratelimit_stress_child", i); + KUNIT_EXPECT_NOT_NULL_MSG(test, sktp, "kthread creation failure"); + pr_alert("Spawned test_ratelimit_stress_child %d\n", i); + } + schedule_timeout_idle(stress_duration); + WRITE_ONCE(doneflag, 1); + for (i =3D 0; i < n_stress_kthread; i++) { + kthread_stop(sktp[i].tp); + skt.nattempts +=3D sktp[i].nattempts; + skt.nunlimited +=3D sktp[i].nunlimited; + skt.nlimited +=3D sktp[i].nlimited; + skt.nmissed +=3D sktp[i].nmissed; + } + KUNIT_ASSERT_EQ_MSG(test, skt.nunlimited + skt.nlimited, skt.nattempts, + "Outcomes not equal to attempts"); + KUNIT_ASSERT_EQ_MSG(test, skt.nlimited, skt.nmissed, "Misses not equal to= limits"); +} + +static struct kunit_case ratelimit_test_cases[] =3D { KUNIT_CASE_SLOW(test_ratelimit_smoke), + KUNIT_CASE_SLOW(test_ratelimit_stress), {} }; =20 static struct kunit_suite ratelimit_test_suite =3D { .name =3D "lib_ratelimit", - .test_cases =3D sort_test_cases, + .test_cases =3D ratelimit_test_cases, }; =20 kunit_test_suites(&ratelimit_test_suite); --=20 2.40.1