From patchwork Mon Sep 30 08:37:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 13815597 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 5009FCF6497 for ; Mon, 30 Sep 2024 08:37:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9849B80018; Mon, 30 Sep 2024 04:37:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 84B1080019; Mon, 30 Sep 2024 04:37:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6930A80018; Mon, 30 Sep 2024 04:37:54 -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 494AF80017 for ; Mon, 30 Sep 2024 04:37:54 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id EC587141CA9 for ; Mon, 30 Sep 2024 08:37:53 +0000 (UTC) X-FDA: 82620751626.17.EC8931D Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf02.hostedemail.com (Postfix) with ESMTP id 9F76980007 for ; Mon, 30 Sep 2024 08:37:51 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b="eapi/7j4"; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=ZNY4OLn4; 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"; dmarc=none; spf=pass (imf02.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=vbabka@suse.cz ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727685452; a=rsa-sha256; cv=none; b=MHKF+gi46LKjMMBdwqFuKohz3MZNWHEyoI4xrd4ZJd9qP800ciVBNEfMywHzvMqX+iXDiv ttRiC8DhFMV3XdkZTu53AvuhdYKX5EOTWO27/Wn1c1NKOgyLq1A03wafkxjAZzWOt9zC8W 7DJJzJNMySy82zjMNcHg2eV9H+j3ePw= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b="eapi/7j4"; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=ZNY4OLn4; 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"; dmarc=none; spf=pass (imf02.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.130 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=1727685452; 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=JgQ88WJb6SfxHq3DtbKbtCJE22E1mXv14WWbdGNLNm+p9pk5ezreRW85jdqoKE/Gwte5rk OryZNGMJ3MjmmcQ0Z9CWLXv5sueFclzk3mBgMnsD+4JCrDwAII8FFI8guJD9YgjNLXQA25 sP3/r7UiX0EE+WO2BaqDf9OKa5Sp6hY= 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== 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 MIME-Version: 1.0 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-Action: no action X-Rspam-User: X-Stat-Signature: gwq59t8k4k3u1uenwwp483fsqy7ad9ta X-Rspamd-Queue-Id: 9F76980007 X-Rspamd-Server: rspam02 X-HE-Tag: 1727685471-260943 X-HE-Meta: U2FsdGVkX1/+Xflk95UmPvTle0ameBq6XfMfKZwYByJnu1gHIywHkkEFWcOAAghV+PjKRnxYkp96YqWKzeFLNiNMJ/wWRq54IL69z1loEIP2mLitcyJU4meusW3Vd6c4u8rxn2vrb98mUuqEuYpKFi1wOx4j1FFhSymOD2LUQRLuVmL0ATRd/Ak/yYC5q1iTKRRJoc/lNhrLcmrb6PQ3OnI81PCzGzITk+/JO0vCfpvV+G0Yt/srfid/0b0Y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FB0Zz5XhHYGy0fc/pkrVrOxvAeczhWm+N4oc1RO919gzX9mAbjDe1ygjR+EoZlTYn5GGGBr8Ysz9BFMGckshOVVWdhTatNzVZoVtO9f1SjL3vzeS2h0EmekUsGnjIMx302p5/T0xDMqwYHXhbWIRLQL3XBjbyyZ0SgaRtyA== 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 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..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); }