From nobody Thu Nov 28 16:53:36 2024 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DBE1217B4FC for ; Mon, 30 Sep 2024 08:37:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727685473; cv=none; b=OMC+torNh5puIbGr2tfM7xtck4UORvjGMHgXDApnGzPQez4EQIiGoS1ohwiO0ITn6ZFmQglVcvK7m38ct4IM8L3M31dgeph0MD6GO9wxekhdEsxnV3wL4XpefWOM1YLZKBR/LsvBEFTg2kEj4lqRpbLtJmE36B01qGAdtCmrACU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727685473; c=relaxed/simple; bh=TRsmmRP/EWgsJv7xhYSQr8KrDcVZgvvGzDXsh4rZO7U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KKOdWYdQOwwksWrwh9b0bcVfNTGuyE840Fbx42eZkJ5VF/m1ujgVVOXpaa4mX6JGs9CiE0SGEI+NQPnSqzQIgnPEfZ5BGo6azfhV4DhJjU4erCWMTO0XiO2pRfgdlNJSpED7omGPU/EjI8HhyVaHB4nLDSCtckDet1OH4tzAlkY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=eapi/7j4; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=ZNY4OLn4; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=JtOhNOU6; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=8/CDxZyy; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="eapi/7j4"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="ZNY4OLn4"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="JtOhNOU6"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="8/CDxZyy" 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-out1.suse.de (Postfix) with ESMTPS id E2075218B0; Mon, 30 Sep 2024 08:37:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1727685470; 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=eapi/7j47CIR610xcRtKWaTmoHGo9tQ41p+LljS7/4ctWF12FebGE92rkIQHS6X9YC6n/Y YX7mxFyHEDuS9jLgYxgGc4xVPTk/plfmIoapm+WziYVh7iXEEjXbwZm9ZpXzXXY0aSEhAu F/wAA1JShOoBov2YNMdf3z+eyryuswA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1727685470; 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=ZNY4OLn49qpjeyHj7FJmKolvZwxe4QR0VErbjWZ84tXTTRje2sxEYOLZohougT/VkEXqhj jtHc5vApQulIDiAw== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=JtOhNOU6; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="8/CDxZyy" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1727685469; 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=JtOhNOU6urOKMDlg889U7b+6rrtIhOCKQVNij+lQJl/a/TgKVx/e2oqRtDPYEhGfupvcPK MM0rJFLZv8eX8G+KH4aeYoZf+CPI5GrVqtBY3OvWw0sgUjuGRrEIt9SbgaP+VRFBqY0n1c h9pQpQs+0uU+0BGX3byz8P66mC4dHds= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1727685469; 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=8/CDxZyyA/rjYBHfb7Uid2wz8hwIjQwkA0Dn8TUi4nwChZkpd9+zQw1yqSrzk+4heLlE5V cQNH+6m55W1woGBw== 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 C0ADE13A97; Mon, 30 Sep 2024 08:37:49 +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 SBnFLl1j+mYhHwAAD6G6ig (envelope-from ); Mon, 30 Sep 2024 08:37:49 +0000 From: Vlastimil Babka Date: Mon, 30 Sep 2024 10:37:16 +0200 Subject: [PATCH slab hotfixes 1/2] mm, slab: suppress warnings in test_leak_destroy kunit test Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240930-b4-slub-kunit-fix-v1-1-32ca9dbbbc11@suse.cz> References: <20240930-b4-slub-kunit-fix-v1-0-32ca9dbbbc11@suse.cz> In-Reply-To: <20240930-b4-slub-kunit-fix-v1-0-32ca9dbbbc11@suse.cz> To: Andrew Morton , Christoph Lameter , David Rientjes , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Vlastimil Babka Cc: kernel test robot , Guenter Roeck X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=4054; i=vbabka@suse.cz; h=from:subject:message-id; bh=TRsmmRP/EWgsJv7xhYSQr8KrDcVZgvvGzDXsh4rZO7U=; b=owEBbQGS/pANAwAIAbvgsHXSRYiaAcsmYgBm+mNYIupbfQOMIbodDHrMfP0p13Sj7mMKww+on 0VZNDz4lsmJATMEAAEIAB0WIQR7u8hBFZkjSJZITfG74LB10kWImgUCZvpjWAAKCRC74LB10kWI moqTB/4yOcUChFNz4v0h8ffjMzyiKsgWuPz70yOFy93E0AfuSaY3mqUC4SVx+OEinFKyOoJBKpt bQbR6Sn4JxJ034jdGWYUIbAEhmH0bhkPWV92Dw1HVKxVEXGuBaUvekt9ARvenbhs0IA7iEiaJcN /UJdiV3/UShFK1R/BaROKDPTN+kwN8IobcXcRE/Tf4uCHQzIpVbuo6940GjzHBZ8OUMyGnakW8w D+oZ2Y0QQJd3Wc2m60impMHrLLQAIuRM9yk1ymuU/8yIwDmKOpS38uyQFUx/iZnw46TxFMit3+1 GSy+LWYKeqjeNGVmFdFFp0PSI+qR3lwKjSRu5diKac1Ehdfh X-Developer-Key: i=vbabka@suse.cz; a=openpgp; fpr=A940D434992C2E8E99103D50224FA7E7CC82A664 X-Rspamd-Queue-Id: E2075218B0 X-Spam-Level: X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; SUSPICIOUS_RECIPS(1.50)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; TAGGED_RCPT(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_TO(0.00)[linux-foundation.org,linux.com,google.com,linux.dev,gmail.com,vger.kernel.org,kvack.org,suse.cz]; MID_RHS_MATCH_FROM(0.00)[]; R_RATELIMIT(0.00)[to_ip_from(RLhc4kaujr6ihojcnjq7c1jwbi)]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_SEVEN(0.00)[10]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.cz:+] X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action X-Spam-Score: -3.01 X-Spam-Flag: NO 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_destr= oy()") Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-lkp/202408251723.42f3d902-oliver.sang@in= tel.com Reported-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Closes: https://lore.kernel.org/all/CAB=3D+i9RHHbfSkmUuLshXGY_ifEZg9vCZi3fq= r99+kmmnpDus7Q@mail.gmail.com/ Reported-by: Guenter Roeck Closes: https://lore.kernel.org/all/6fcb1252-7990-4f0d-8027-5e83f0fb9409@ro= eck-us.net/ Signed-off-by: Vlastimil Babka Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- 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..85d51ec09846d4fa219db6bda33= 6c6f0b89e98e4 100644 --- a/lib/slub_kunit.c +++ b/lib/slub_kunit.c @@ -177,13 +177,13 @@ static void test_kfree_rcu(struct kunit *test) =20 static void test_leak_destroy(struct kunit *test) { - struct kmem_cache *s =3D test_kmem_cache_create("TestSlub_kfree_rcu", + struct kmem_cache *s =3D test_kmem_cache_create("TestSlub_leak_destroy", 64, SLAB_NO_MERGE); kmem_cache_alloc(s, GFP_KERNEL); =20 kmem_cache_destroy(s); =20 - KUNIT_EXPECT_EQ(test, 1, slab_errors); + KUNIT_EXPECT_EQ(test, 2, slab_errors); } =20 static int test_init(struct kunit *test) diff --git a/mm/slab.h b/mm/slab.h index f22fb760b2866124d9d873d28b5a7fa6867aeb90..5cf0fbab0b0554ee70f5371772b= c37b290893b8a 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; } =20 +#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 =20 /* diff --git a/mm/slab_common.c b/mm/slab_common.c index 7443244656150325fb2a7d0158a71821e1418062..3d26c257ed8b57c336ec5c38d4b= bd5f5e51d50ff 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); =20 err =3D __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_); =20 list_del(&s->list); =20 diff --git a/mm/slub.c b/mm/slub.c index 21f71cb6cc06d951a657290421f41170bb3c76cf..5b832512044e3ead8ccde2c0230= 8bd8954246db5 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -827,7 +827,7 @@ static bool slab_add_kunit_errors(void) return true; } =20 -static bool slab_in_kunit_test(void) +bool slab_in_kunit_test(void) { struct kunit_resource *resource; =20 @@ -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 =20 static inline unsigned int size_from_object(struct kmem_cache *s) @@ -5436,6 +5435,8 @@ static void list_slab_objects(struct kmem_cache *s, s= truct slab *slab, for_each_object(p, s, addr, slab->objects) { =20 if (!test_bit(__obj_to_index(s, addr, p), object_map)) { + if (slab_add_kunit_errors()) + continue; pr_err("Object 0x%p @offset=3D%tu\n", p, p - addr); print_tracking(s, p); } --=20 2.46.1 From nobody Thu Nov 28 16:53:36 2024 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AD38917B506; Mon, 30 Sep 2024 08:37:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727685474; cv=none; b=KKl09M2R0VnkbTKIWZU2rkDevjU8dfgiTIWqUCjzRdpDIJkYgZmmKjTxCKHeT0W69o2Qh+PeLlnxQJK4RWgaG7bC1ZeL0yXgjXo9f77KWmPSEPUcXf1573XhJNTSqg/WeYDWeu7Ne39Ov2HIMs7vF8DgIobdp/K4wMn/gj5TR/4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727685474; c=relaxed/simple; bh=0WnxLPEui3oDtLBzlhAtJkEteadIcsQlNHVOikq11/s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=LfG9nJE2TB/9rps3qsHZF47nkvxJRMk8JuofZ5+zTnB7sw20N63PdHZxspfLfM1aLDUEM5rey3gPC32gth29ihn44XngCqXSOQTET2AjZNqG3yFTPiN2Z+D/+IdRkXGtnhq5kklguic6mqBi3/1wRRUgTftFS+O7Q6xToBQ9Ueo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=rjLzb/uw; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=a+fD/IqS; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=PQ3SPeHb; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=ieXzy1Ws; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="rjLzb/uw"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="a+fD/IqS"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="PQ3SPeHb"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="ieXzy1Ws" Received: from imap1.dmz-prg2.suse.org (unknown [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 ED95F1F7F6; Mon, 30 Sep 2024 08:37:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1727685471; 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=1H0gPESO/BntkG0B4FSGoHsx0d2Sq64W+wU6e58nb2w=; b=rjLzb/uwGOFEw+Hby88kVfZ6SY9u9G3VwCebC0uBG/wfLFdcGzoLW9/nGKYN8nLJ1IfnoZ 8TsglSwlbyMUSvj1GTFAb3BgQfmECblArMuIo6r0nloHMtOANcBaHUPOswwJ1f7lJUYpFV nJ1vJYemy+HAUJwUw3uBo/VKk2gZ7H8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1727685471; 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=1H0gPESO/BntkG0B4FSGoHsx0d2Sq64W+wU6e58nb2w=; b=a+fD/IqS8IrfYHbEqPLoSF7McWtLoH9HqjXeNJUxaiKqSH6cDuH23b6cFz6hfCUit1hk0G TCNywWatBwD3/OBA== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1727685469; 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=1H0gPESO/BntkG0B4FSGoHsx0d2Sq64W+wU6e58nb2w=; b=PQ3SPeHbkR498u6YpBNmc6BAyZslVulywJ3CcMI9L/dQlwk2vUqvhoB2Jzl3EJZieOv6Gg ryvkLqrkU3fUGjIfyQn7gunbXEvOZuPr+Klak8BBaxSmXULi4k1KX5LfAwEURvBI6jq0f/ ilnq3b8Eo8C3YG+ZHS8o/+uIBMI9NfI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1727685469; 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=1H0gPESO/BntkG0B4FSGoHsx0d2Sq64W+wU6e58nb2w=; b=ieXzy1WsmRbQR0KOCAAEMkokIjqUT2C3bv/cY+uBLi+lUt9v8imJrWllq5HhG/bAZZtN60 5GxU/9v1G7bU1WBA== 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 D0C9813AAA; Mon, 30 Sep 2024 08:37:49 +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 ABOwMl1j+mYhHwAAD6G6ig (envelope-from ); Mon, 30 Sep 2024 08:37:49 +0000 From: Vlastimil Babka Date: Mon, 30 Sep 2024 10:37:17 +0200 Subject: [PATCH slab hotfixes 2/2] kunit: move call to kunit_run_all_tests() after rcu_end_inkernel_boot() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240930-b4-slub-kunit-fix-v1-2-32ca9dbbbc11@suse.cz> References: <20240930-b4-slub-kunit-fix-v1-0-32ca9dbbbc11@suse.cz> In-Reply-To: <20240930-b4-slub-kunit-fix-v1-0-32ca9dbbbc11@suse.cz> To: Andrew Morton , Christoph Lameter , David Rientjes , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Vlastimil Babka Cc: 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-Developer-Signature: v=1; a=openpgp-sha256; l=2159; i=vbabka@suse.cz; h=from:subject:message-id; bh=0WnxLPEui3oDtLBzlhAtJkEteadIcsQlNHVOikq11/s=; b=owEBbQGS/pANAwAIAbvgsHXSRYiaAcsmYgBm+mNb5kW6gBMYJomoCQCnVJVj2vq4E+KW7TR+P v9VoTSjjjuJATMEAAEIAB0WIQR7u8hBFZkjSJZITfG74LB10kWImgUCZvpjWwAKCRC74LB10kWI mmuxCACeREhmlg/rNG4s+kT3WJNgk6FnivDPqNnOL4qEeWBIaPwJLleugyX0FkcYNrF03p70/WB pbKNdzte33X1JZ+yutnxQBs0wb59bq0Cy6NJc2h1MRe/zwbNUPZ8T+SrZwg+RzRYF8uOnmi/Evg PrgWiuYKvoo8av4sqAUo0r1nd3bu88M4blrWPVYYbX7ws1PlO+zA/c73XJUGI4TGo8xwfi1gJDr 1Hc6U6Zsx9qCAVg+8sbG7SVeI1SgqHw4mDqc+Mq7lVU+9fO4r5Wky0LH8loHaH7PJadIY5R/sQD FtUOXqUHggLFkJ8XP/N5cwnK9/61pYbheifxulWZWjhzRjNr X-Developer-Key: i=vbabka@suse.cz; a=openpgp; fpr=A940D434992C2E8E99103D50224FA7E7CC82A664 X-Spam-Score: -2.80 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; SUSPICIOUS_RECIPS(1.50)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; TAGGED_RCPT(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_TWELVE(0.00)[18]; ARC_NA(0.00)[]; RCVD_TLS_ALL(0.00)[]; FREEMAIL_TO(0.00)[linux-foundation.org,linux.com,google.com,linux.dev,gmail.com,vger.kernel.org,kvack.org,suse.cz]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; FROM_HAS_DN(0.00)[]; FREEMAIL_CC(0.00)[roeck-us.net,kernel.org,gmail.com,vger.kernel.org,google.com,googlegroups.com,linux.dev]; MID_RHS_MATCH_FROM(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_DN_SOME(0.00)[] X-Spam-Flag: NO X-Spam-Level: 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. These tests invoke kfree_rcu() and kvfree_rcu_barrier() 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, moving the call to kunit_run_all_tests() a bit later in the boot seems to have fixed the lockup problem according to Guenter's limited testing. No kunit tests should be broken by calling the built-in executor a bit later, as when compiled as modules, they are still executed even later than this. Fixes: 4e1c44b3db79 ("kunit, slub: add test_kfree_rcu() and test_leak_destr= oy()") Reported-by: Guenter Roeck Closes: https://lore.kernel.org/all/6fcb1252-7990-4f0d-8027-5e83f0fb9409@ro= eck-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 --- init/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/init/main.c b/init/main.c index c4778edae7972f512d5eefe8400075ac35a70d1c..7890ebb00e84b8bd7bac28923fb= 1fe571b3e9ee2 100644 --- a/init/main.c +++ b/init/main.c @@ -1489,6 +1489,8 @@ static int __ref kernel_init(void *unused) =20 rcu_end_inkernel_boot(); =20 + kunit_run_all_tests(); + do_sysctl_args(); =20 if (ramdisk_execute_command) { @@ -1579,8 +1581,6 @@ static noinline void __init kernel_init_freeable(void) =20 do_basic_setup(); =20 - kunit_run_all_tests(); - wait_for_initramfs(); console_on_rootfs(); =20 --=20 2.46.1