Skip to content

Commit cac39b0

Browse files
committed
slub/kunit: skip test_kfree_rcu when the slub kunit test is built-in
Guenter Roeck reports that the new slub kunit tests added by commit 4e1c44b ("kunit, slub: add test_kfree_rcu() and test_leak_destroy()") cause a lockup on boot on several architectures when the kunit tests are configured to be built-in and not modules. The test_kfree_rcu test invokes kfree_rcu() and boot sequence inspection showed the runner for built-in kunit tests kunit_run_all_tests() is called before setting system_state to SYSTEM_RUNNING and calling rcu_end_inkernel_boot(), so this seems like a likely cause. So while I was unable to reproduce the problem myself, skipping the test when the slub_kunit module is built-in should avoid the issue. An alternative fix that was moving the call to kunit_run_all_tests() a bit later in the boot was tried, but has broken tests with functions marked as __init due to free_initmem() already being done. Fixes: 4e1c44b ("kunit, slub: add test_kfree_rcu() and test_leak_destroy()") Reported-by: Guenter Roeck <linux@roeck-us.net> Closes: https://lore.kernel.org/all/6fcb1252-7990-4f0d-8027-5e83f0fb9409@roeck-us.net/ Cc: Paul E. McKenney <paulmck@kernel.org> Cc: Boqun Feng <boqun.feng@gmail.com> Cc: Uladzislau Rezki <urezki@gmail.com> Cc: rcu@vger.kernel.org Cc: Brendan Higgins <brendanhiggins@google.com> Cc: David Gow <davidgow@google.com> Cc: Rae Moar <rmoar@google.com> Cc: linux-kselftest@vger.kernel.org Cc: kunit-dev@googlegroups.com Tested-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
1 parent 3f1dd33 commit cac39b0

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

lib/slub_kunit.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,16 @@ struct test_kfree_rcu_struct {
164164

165165
static void test_kfree_rcu(struct kunit *test)
166166
{
167-
struct kmem_cache *s = test_kmem_cache_create("TestSlub_kfree_rcu",
168-
sizeof(struct test_kfree_rcu_struct),
169-
SLAB_NO_MERGE);
170-
struct test_kfree_rcu_struct *p = kmem_cache_alloc(s, GFP_KERNEL);
167+
struct kmem_cache *s;
168+
struct test_kfree_rcu_struct *p;
169+
170+
if (IS_BUILTIN(CONFIG_SLUB_KUNIT_TEST))
171+
kunit_skip(test, "can't do kfree_rcu() when test is built-in");
172+
173+
s = test_kmem_cache_create("TestSlub_kfree_rcu",
174+
sizeof(struct test_kfree_rcu_struct),
175+
SLAB_NO_MERGE);
176+
p = kmem_cache_alloc(s, GFP_KERNEL);
171177

172178
kfree_rcu(p, rcu);
173179
kmem_cache_destroy(s);

0 commit comments

Comments
 (0)