From patchwork Tue Oct 1 16:20:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 13818458 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4000ECEACE7 for ; Tue, 1 Oct 2024 16:21:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D7A3C2800BF; Tue, 1 Oct 2024 12:21:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D25432800C0; Tue, 1 Oct 2024 12:21:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BC9FF2800BF; Tue, 1 Oct 2024 12:21:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 7E7BE2800C0 for ; Tue, 1 Oct 2024 12:21:02 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 184D51214C1 for ; Tue, 1 Oct 2024 16:21:02 +0000 (UTC) X-FDA: 82625547564.13.6257DFB Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf09.hostedemail.com (Postfix) with ESMTP id DB16014001B for ; Tue, 1 Oct 2024 16:20:59 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=AplgA1Xt; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=nmoIQ+CX; dmarc=none; spf=pass (imf09.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=vbabka@suse.cz ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727799556; a=rsa-sha256; cv=none; b=DNwztRPP0+OF9s/vwZzNPAJ5lw3/AfXhVbgXndeKJEdxgIOikyPjslwf9Kze0ZNiJBqap7 LjKugKrQ6i/DcJ3Lcx9GyDkddej/flGbM2N6bjD0OTyy2gR4ZI4hh6+B8ajsqylJh3yqhH UnQQ3D8KzQ61LARAJ3igpN7ERko96CM= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=AplgA1Xt; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=nmoIQ+CX; dmarc=none; spf=pass (imf09.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=vbabka@suse.cz ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727799556; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=bU8OM+Iu2SHVDtuN47aGhbiaVQFgLBj/nNrko3LpMpM=; b=NA4VwAvCZXENcfRVKcxQ2cqBZqtax2notXOah58rCeF9AtFiNSWBcCYx3wd8zVGrNhFzHk NvSWBoT7APP9h5eFq/uPoRdFUWZEtdBaxwFdq6pY50kXYVLtT0pZlv3IO1Q/SNzsbtu1NG +QllkWwF0b1HThPvcI332+SwxOiEZoo= Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id DB1D01F8B6; Tue, 1 Oct 2024 16:20:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1727799656; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bU8OM+Iu2SHVDtuN47aGhbiaVQFgLBj/nNrko3LpMpM=; b=AplgA1XtGYRXzB6PXy7uviOBDeqydI1+9DKBaPwDyWgxprNQNR+mRLU3eAJdfncpUvht8g Eplfl7pP/wzPnicXDDTN87W9WtZvAjeGzybAjMOwsEAnwRTEEfcYhAnoG3SUECAiBUIzGY atzAnPFulgJBkbopKu32Gr+7PQxgVWk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1727799656; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bU8OM+Iu2SHVDtuN47aGhbiaVQFgLBj/nNrko3LpMpM=; b=nmoIQ+CXr6aMq3n3w3gA9SVIiKm5Ar3CYSldzOJWri8NgHg5EN1g+YEfoRY4zsj8j46zmw JT7K6u5z85UwIzBg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id B346C13A8A; Tue, 1 Oct 2024 16:20:56 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 2BNXK2gh/GaHRAAAD6G6ig (envelope-from ); Tue, 01 Oct 2024 16:20:56 +0000 From: Vlastimil Babka Date: Tue, 01 Oct 2024 18:20:48 +0200 Subject: [PATCH slab hotfixes v2 1/2] mm, slab: suppress warnings in test_leak_destroy kunit test MIME-Version: 1.0 Message-Id: <20241001-b4-slub-kunit-fix-v2-1-2d995d3ecb49@suse.cz> References: <20241001-b4-slub-kunit-fix-v2-0-2d995d3ecb49@suse.cz> In-Reply-To: <20241001-b4-slub-kunit-fix-v2-0-2d995d3ecb49@suse.cz> To: Christoph Lameter , David Rientjes Cc: Roman Gushchin , Andrew Morton , Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Vlastimil Babka , kernel test robot , Guenter Roeck X-Mailer: b4 0.14.2 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: DB16014001B X-Stat-Signature: kkz6nk9y9xga5q84ucmiaxxchh8qiz8o X-Rspam-User: X-HE-Tag: 1727799659-6858 X-HE-Meta: U2FsdGVkX18jCCEfeNNbEY+eO7rDoofDjGHOoBJCMOz8+TNZ+ajmMMI4gVyZjFrY+MFar4Bpk9QCo5bCjLpD+FFwWYQ8XlWPDZBhbvoEpC5RgIbZwDMAOwkYiceMCwiS+0RK1+OFFxSD/p7nJ7vaM3GlL6xcx+a1FNAaXvhnHUOr6Tyb1s6rTejzg0gf5QAHkA47rZAQY2NGAy3OpRWP/p2mIkozbBjOwX1A2CQM1B6VNdeUUIAyeFpe8QoHOwKfKEHzuj7HXS4g7jLcjVEGXxb+Hn9vm8mxtIRP+YJ4G4JQA43aq+Qj0KvXAs676bBa2nMqtozu5Fas+3Go10B5IzMMrkkNms+mhGQnzeiC764Bj7paOHE8nTu2VInGe1hoFZpPqrmGBdjC6IM9N23xYgQ7PQ54ocIQ0qfQOBGeMTYuZkpPA5f9t5g8F2SD3EzWzpbxuaBWVkOHgW6mIIl0zrOCxgptotATMaUrK/1GbnFVLQtaVe6fFpCRg7WnBMapHoDqdlMvcCC0e6s81G4VU3ga6dPozgqBpraJkHfDFqVPKKSw60UJ01g/aUidG+Xm2CbF8kEqTjYDNsRBOgwGDSN7C9uqAXEKV4va59OVvho6DIFmbfj7aHqUCXvXR08kYTSVJPLyyyxJWfJ8a2bEEqscDXimZE7H0ZTv9jAMeU/da6vjIxnCDd7czgE84s8LoCn6qiyxjDhijUclfcIccIhSGLoIl+YiVo6UhFXORscTe/3wRVUXnE4boXSesiaQHXmiPLLOGcvD35B7JHcK561yWU+2JI8x0hQ3GjiXbTVvgAJylh/ShnQjTvYFiIM2OG9uv2/Gskmf04TFrusamgMvdP4+6vcG2PKeDLjwQROI43/BW6egE0dNENDvITKIcWOmKOK219OAeGFAwTrdGqBDhIhkvHDnbu/NTrwOFSZ9knh0BQ4nCuegL85XJJ2WdE5h4tMx7BjnvIYbNZ2 LW8jAPXK 9dNl8WusnxbqaOCt9g75gRs5B4vbnHTevPQuFPUqZ8G77ViIZl8dWFw5haMbe0elXTO6VBEkoWclW3JwX1rZqrqVarP6oQXxc1kmXfNhaoME8vExByUQIydCdSFgk1Rxiat/qZmDlcb51lTdZCpj0Jks8jlnWz7gi7Z2LIWo53wYrcdL85dgNqDP2YNwm4L+mQ2Rx4v7oVBYdqLtStK890JX2y1mIWecASIUMSzROggXMh2IAe7sr0vwpQ3+d+DkCUn11ECVvJAQpAilPyntFW4aXI6hQ7q/j/vIRtarn+yB8vNQU44PtyqvV+biM0wWWQlb3GjUjyWZ7g/dnPmBIt+wbt+AmthkNqfCph39gCCDGyuu+FEoF136BuOu4N13lzeEZ6Ks5J/M6GWnLpwvYDLP41x9E8i/uFCpM1C4MuTdLwtP3V2tuLqSB+IoEeg6CJRFcfHpmBgto7y5bi5Jhg/s3b+VwxXQVyQwdwO+LcBYHRVTZSHhkEeUNQA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The test_leak_destroy kunit test intends to test the detection of stray objects in kmem_cache_destroy(), which normally produces a warning. The other slab kunit tests suppress the warnings in the kunit test context, so suppress warnings and related printk output in this test as well. Automated test running environments then don't need to learn to filter the warnings. Also rename the test's kmem_cache, the name was wrongly copy-pasted from test_kfree_rcu. Fixes: 4e1c44b3db79 ("kunit, slub: add test_kfree_rcu() and test_leak_destroy()") Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-lkp/202408251723.42f3d902-oliver.sang@intel.com Reported-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Closes: https://lore.kernel.org/all/CAB=+i9RHHbfSkmUuLshXGY_ifEZg9vCZi3fqr99+kmmnpDus7Q@mail.gmail.com/ Reported-by: Guenter Roeck Closes: https://lore.kernel.org/all/6fcb1252-7990-4f0d-8027-5e83f0fb9409@roeck-us.net/ Signed-off-by: Vlastimil Babka Tested-by: Guenter Roeck --- lib/slub_kunit.c | 4 ++-- mm/slab.h | 6 ++++++ mm/slab_common.c | 5 +++-- mm/slub.c | 5 +++-- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/slub_kunit.c b/lib/slub_kunit.c index 6e3a1e5a7142f797fe20a28967657f50a466d4ee..85d51ec09846d4fa219db6bda336c6f0b89e98e4 100644 --- a/lib/slub_kunit.c +++ b/lib/slub_kunit.c @@ -177,13 +177,13 @@ static void test_kfree_rcu(struct kunit *test) static void test_leak_destroy(struct kunit *test) { - struct kmem_cache *s = test_kmem_cache_create("TestSlub_kfree_rcu", + struct kmem_cache *s = test_kmem_cache_create("TestSlub_leak_destroy", 64, SLAB_NO_MERGE); kmem_cache_alloc(s, GFP_KERNEL); kmem_cache_destroy(s); - KUNIT_EXPECT_EQ(test, 1, slab_errors); + KUNIT_EXPECT_EQ(test, 2, slab_errors); } static int test_init(struct kunit *test) diff --git a/mm/slab.h b/mm/slab.h index f22fb760b2866124d9d873d28b5a7fa6867aeb90..5cf0fbab0b0554ee70f5371772bc37b290893b8a 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -546,6 +546,12 @@ static inline bool kmem_cache_debug_flags(struct kmem_cache *s, slab_flags_t fla return false; } +#if IS_ENABLED(CONFIG_SLUB_DEBUG) && IS_ENABLED(CONFIG_KUNIT) +bool slab_in_kunit_test(void); +#else +static inline bool slab_in_kunit_test(void) { return false; } +#endif + #ifdef CONFIG_SLAB_OBJ_EXT /* diff --git a/mm/slab_common.c b/mm/slab_common.c index 7443244656150325fb2a7d0158a71821e1418062..3d26c257ed8b57c336ec5c38d4bbd5f5e51d50ff 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -508,8 +508,9 @@ void kmem_cache_destroy(struct kmem_cache *s) kasan_cache_shutdown(s); err = __kmem_cache_shutdown(s); - WARN(err, "%s %s: Slab cache still has objects when called from %pS", - __func__, s->name, (void *)_RET_IP_); + if (!slab_in_kunit_test()) + WARN(err, "%s %s: Slab cache still has objects when called from %pS", + __func__, s->name, (void *)_RET_IP_); list_del(&s->list); diff --git a/mm/slub.c b/mm/slub.c index 21f71cb6cc06d951a657290421f41170bb3c76cf..5b832512044e3ead8ccde2c02308bd8954246db5 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -827,7 +827,7 @@ static bool slab_add_kunit_errors(void) return true; } -static bool slab_in_kunit_test(void) +bool slab_in_kunit_test(void) { struct kunit_resource *resource; @@ -843,7 +843,6 @@ static bool slab_in_kunit_test(void) } #else static inline bool slab_add_kunit_errors(void) { return false; } -static inline bool slab_in_kunit_test(void) { return false; } #endif static inline unsigned int size_from_object(struct kmem_cache *s) @@ -5436,6 +5435,8 @@ static void list_slab_objects(struct kmem_cache *s, struct slab *slab, for_each_object(p, s, addr, slab->objects) { if (!test_bit(__obj_to_index(s, addr, p), object_map)) { + if (slab_add_kunit_errors()) + continue; pr_err("Object 0x%p @offset=%tu\n", p, p - addr); print_tracking(s, p); } From patchwork Tue Oct 1 16:20:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 13818459 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0B3DCEACE6 for ; Tue, 1 Oct 2024 16:21:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8E3A82800C2; Tue, 1 Oct 2024 12:21:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 846022800C0; Tue, 1 Oct 2024 12:21:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 697772800C2; Tue, 1 Oct 2024 12:21:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 419A22800C0 for ; Tue, 1 Oct 2024 12:21:03 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id E641C1C6A3C for ; Tue, 1 Oct 2024 16:21:02 +0000 (UTC) X-FDA: 82625547564.09.72DD7B5 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf12.hostedemail.com (Postfix) with ESMTP id 7889D40008 for ; Tue, 1 Oct 2024 16:21:00 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=IvVD1i3P; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=79AnOGlo; spf=pass (imf12.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727799492; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=l/QBF9ogG+rLgjsYlGtd5nYLAr8eD5n5eV3Wh2PFS6s=; b=YiPinBTZM0HEO+o+xcaYjy6s9+XJRBtCdkjue0Yity93IOhVTKapGNX1JUeYrgWhoF95Gk LPwIYdukqJsNxdtO4/2jN7c7zi7eZS8qF4JcJrPIcHbM0DL4tjmYBdkjcavAQ6/V0JFSzs duYWI3aHEhd2/0bD0ag9ZtgdScJVYd4= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=IvVD1i3P; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=79AnOGlo; spf=pass (imf12.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727799492; a=rsa-sha256; cv=none; b=lSOG4L7f0YaQDMQRmF9/pzRpG5S63GFJTs1RTe82ToCUWD5xz6HnB7FM7NsLT1o09dVHAA UFQ2BiV3/KcO7na2TYvOminXFWn5fgT52DsiuQLNW06jqPOuttTxVJPYfPGxwUaQUsI3Zx kECMM9nz+goVbtcPRKjOWBFALCU2Lrs= Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 1756F1FCEB; Tue, 1 Oct 2024 16:20:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1727799657; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=l/QBF9ogG+rLgjsYlGtd5nYLAr8eD5n5eV3Wh2PFS6s=; b=IvVD1i3PZoO/G0+SShUuHjmGbgr04z/JU5VYqn7PyYalIFAZK3wDKdp4SVdGNvIdx6Zn0r XE3ZyuxQd3vOvjZTSSNf8DTYBoROimPtL2+NhzOAgXAZ7jx+D/nfgIIurnlPXJ1gpfkgB3 Du68vOdEIPlMrO1rvkQ5KkaIMvNmdM8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1727799657; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=l/QBF9ogG+rLgjsYlGtd5nYLAr8eD5n5eV3Wh2PFS6s=; b=79AnOGloyFDDJnxc20ufPXTF7TToPL8scRX1tzFKC3c6jBT4T+SgMdZOHniLljNnMFTc3M udE/zrrCO3/hHsDA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id D4AC913A91; Tue, 1 Oct 2024 16:20:56 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id iEqkM2gh/GaHRAAAD6G6ig (envelope-from ); Tue, 01 Oct 2024 16:20:56 +0000 From: Vlastimil Babka Date: Tue, 01 Oct 2024 18:20:49 +0200 Subject: [PATCH slab hotfixes v2 2/2] slub/kunit: skip test_kfree_rcu when the slub kunit test is built-in MIME-Version: 1.0 Message-Id: <20241001-b4-slub-kunit-fix-v2-2-2d995d3ecb49@suse.cz> References: <20241001-b4-slub-kunit-fix-v2-0-2d995d3ecb49@suse.cz> In-Reply-To: <20241001-b4-slub-kunit-fix-v2-0-2d995d3ecb49@suse.cz> To: Christoph Lameter , David Rientjes Cc: Roman Gushchin , Andrew Morton , Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Vlastimil Babka , Guenter Roeck , "Paul E. McKenney" , Boqun Feng , Uladzislau Rezki , rcu@vger.kernel.org, David Gow , Rae Moar , linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, Brendan Higgins X-Mailer: b4 0.14.2 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 7889D40008 X-Stat-Signature: hd5iooryqfo6b8way1qhi59j9fsnbh8n X-Rspam-User: X-HE-Tag: 1727799660-12157 X-HE-Meta: U2FsdGVkX19Dl3HIV3OT0RF2aRyMU6EPYNHNwJ7b5RLDOuUls8f4O5r/4/zqCnJ2crbLX9gXHGr2bXGxokhoXpokxTcZDdpCRXy1aGM2y4sW9D+6BnMv6WI5re5fcGaGjo4cU1NPVOkjGo1c+qyh1NEcnrtdh0lz77/zHZQoNBFZgvaJ3PUK3Ib+h5vwHKwvI8EpmxgbI48BY4XEX44JYc/HdW1VcZ5rPJnAUe//RIx6WfBFyhpYPALOShPeax4OOeMTDf7hiHQJa8TdyUacWNOnZxP0/6QzRIvX9ONNrz83SuqJTOqmy6bcOPOrJ2ERJ6Z2PmhD6eHn6jRtfJZQuYPY9Fx53yMcmvc1NcgfuEzslypEoAOudYxdPbURatu4/QHVrbp0WLR3YwZxgFJiXEGMPdAm2ob7wCQV9MUU87eKZmkRzIrKxMQL+DWqGgaCokmNYrJkwxwRr0iXRgBzXUpRO1Mt+1VwKAWoJXeZAs2E7ozbpwXvncA7ZGU8hptRmgtcLB3cuRSAvT+FSJEmSxnxy7J75vyxFScpzDGCJiXDL5O2U47SJm/TbEAN4YSA3Z08GcLP+etfFToiwMb3eeglDW+qEJQBRiF0XahNf9P0i6B+Oiis5fzn+HREOmOMQEXZXegq77mWh1EmtTcpf7Hw1k62+Tt7EfUVwJLN5NtpVJO96kBRtpSGKpwKOWZoGz21PUORkxLT01DemIHwOViQ+/wvVI9bPa9aAaoXAL3B9+DHJpQlRFm/xyPqLXmLVXeUwjGDniXABp+9FNAtTzLx1bsz6pYw9b0HzMObGb1y0VlrmHYrPSLhZWP3I5aHdrDMTKhUGrr2gsOb8QlWjqZboyw2fsWoZtliAf9TEZuBHMhlI+6/ui151HIyXTnep0eWqNexoRCh81Rb/0/0vnJBlK1SbhsBg+s1CU+QZgE8Og7ymVKdWKOZlNMn7pK8LUDB4SE6f3N51XXbltS 9tTK1bKz 9hT2+sKAlopws4Xgx1IXkcUSak6kj3neBZ/Zp2lyw+DsYDR3maIzy1dJ7IBIxdBWfedwFCFMg+m5f+387UOIilM0R+6TCvmFx4Od5PUeL4/Ge8slBF27kp1mygjIOC5xX6PN5bF/LY0lRULY1CK3VdJb9TtaV/2TA9CIClvA+CQ29PGsWKeSNQu6Tk+YREdIDqGdJW9P8JBWa8heCso4lzo/JU0Es3NaVIXpVmnCiPt9T8RecHDfNs7acEnM5QH25rR8zqyRN6CwmbMW5MD0roeNzQZGR/j3mtnRJNbsHdDz07xHYNo047P7rXVOPsIQn/FOYXzuxYGSVmw52TXh21lpA9SZpZUyqymHd3DmKCsMojBDW4JNq3WGuTF9NGoDXCHIcYNMYTj4xX638cgn1tqOB2AWIJWCZmeW+HCMR6PNne18FNZM0sN896H+OIvmkEEAGVpGmaMSNmFidomX5UIPKgr4iQmCdj0ZZaTmCR20ihjIUhvNwbe/RVSR23B7YP5RxrORzUwkOrLKI9cHFPTHMEinlCGwcBVLWpMGD0uyHgM49VpiDb0r4Ng== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Guenter Roeck reports that the new slub kunit tests added by commit 4e1c44b3db79 ("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: 4e1c44b3db79 ("kunit, slub: add test_kfree_rcu() and test_leak_destroy()") Reported-by: Guenter Roeck Closes: https://lore.kernel.org/all/6fcb1252-7990-4f0d-8027-5e83f0fb9409@roeck-us.net/ Cc: "Paul E. McKenney" Cc: Boqun Feng Cc: Uladzislau Rezki Cc: rcu@vger.kernel.org Cc: Brendan Higgins Cc: David Gow Cc: Rae Moar Cc: linux-kselftest@vger.kernel.org Cc: kunit-dev@googlegroups.com Signed-off-by: Vlastimil Babka Tested-by: Guenter Roeck --- lib/slub_kunit.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/slub_kunit.c b/lib/slub_kunit.c index 85d51ec09846d4fa219db6bda336c6f0b89e98e4..80e39f003344858722a544ad62ed84e885574054 100644 --- a/lib/slub_kunit.c +++ b/lib/slub_kunit.c @@ -164,10 +164,16 @@ struct test_kfree_rcu_struct { static void test_kfree_rcu(struct kunit *test) { - struct kmem_cache *s = test_kmem_cache_create("TestSlub_kfree_rcu", - sizeof(struct test_kfree_rcu_struct), - SLAB_NO_MERGE); - struct test_kfree_rcu_struct *p = kmem_cache_alloc(s, GFP_KERNEL); + struct kmem_cache *s; + struct test_kfree_rcu_struct *p; + + if (IS_BUILTIN(CONFIG_SLUB_KUNIT_TEST)) + kunit_skip(test, "can't do kfree_rcu() when test is built-in"); + + s = test_kmem_cache_create("TestSlub_kfree_rcu", + sizeof(struct test_kfree_rcu_struct), + SLAB_NO_MERGE); + p = kmem_cache_alloc(s, GFP_KERNEL); kfree_rcu(p, rcu); kmem_cache_destroy(s);