From patchwork Wed Oct 23 06:21:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pei Xiao X-Patchwork-Id: 13846516 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 73DB5D2E01A for ; Wed, 23 Oct 2024 06:21:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6A19E6B0085; Wed, 23 Oct 2024 02:21:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 629C66B0088; Wed, 23 Oct 2024 02:21:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4A3896B0089; Wed, 23 Oct 2024 02:21:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 297066B0085 for ; Wed, 23 Oct 2024 02:21:34 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id AFD00AB4F3 for ; Wed, 23 Oct 2024 06:20:59 +0000 (UTC) X-FDA: 82703870004.12.DC43734 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) by imf22.hostedemail.com (Postfix) with ESMTP id CE072C001C for ; Wed, 23 Oct 2024 06:21:08 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=none; spf=pass (imf22.hostedemail.com: domain of xiaopei01@kylinos.cn designates 124.126.103.232 as permitted sender) smtp.mailfrom=xiaopei01@kylinos.cn; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729664289; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8dtwkXB1BsYJW3k+BTv9lWj7JUSTd5mALjVWBt+oIlo=; b=OaeJT149jssd5TIyNIjNC0eJkmynkIJtYqIdigICF+0VW7WO0dbrxjixQCRdtzipLI7yLc aAWTeiyvC3nlYx5o2fKkK/AT8Y6ql5KcUCd1pDyA4WLGPlvtncedq78GlXlEzc/x3goM9X lJntXgMGm52NkplZZcflGKTzDWvr+Ik= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=none; spf=pass (imf22.hostedemail.com: domain of xiaopei01@kylinos.cn designates 124.126.103.232 as permitted sender) smtp.mailfrom=xiaopei01@kylinos.cn; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729664289; a=rsa-sha256; cv=none; b=8dRWhi6wfdgkt5aVCjCHuvi8tZsJYkyUcZe+CLLBsWjYlIstSSr0ewqj6ifr/KRE9N8JVV FyCpbSV7+qXgG5U3hZ1eI7v//fwjzZPk+hr+u83Pkcclhr1O/FSB01CszTtqB+ElVLmoGG VC4L2BO7keFE/t0e5kM1iZSUyH+/1Z4= X-UUID: 06cf927c910711efa216b1d71e6e1362-20241023 X-CTIC-Tags: HR_CC_COUNT, HR_CC_DOMAIN_COUNT, HR_CC_NO_NAME, HR_CTE_8B, HR_CTT_MISS HR_DATE_H, HR_DATE_WKD, HR_DATE_ZONE, HR_FROM_DIGIT_LEN, HR_FROM_NAME HR_SJ_LANG, HR_SJ_LEN, HR_SJ_LETTER, HR_SJ_NOR_SYM, HR_SJ_PHRASE HR_SJ_PHRASE_LEN, HR_SJ_WS, HR_TO_COUNT, HR_TO_DOMAIN_COUNT, HR_TO_NO_NAME IP_TRUSTED, SRC_TRUSTED, DN_TRUSTED, SA_UNTRUSTED, SA_UNFAMILIAR SN_UNTRUSTED, SN_UNFAMILIAR, SPF_NOPASS, DKIM_NOPASS, DMARC_NOPASS CIE_BAD, CIE_GOOD_SPF, GTI_FG_BS, GTI_RG_INFO, GTI_C_BU AMN_T1, AMN_GOOD, AMN_C_TI, AMN_C_BU X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.38,REQID:a7177d0e-955b-4d31-8c79-b40951c37bf4,IP:0,U RL:0,TC:0,Content:0,EDM:25,RT:0,SF:5,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:30 X-CID-INFO: VERSION:1.1.38,REQID:a7177d0e-955b-4d31-8c79-b40951c37bf4,IP:0,URL :0,TC:0,Content:0,EDM:25,RT:0,SF:5,FILE:0,BULK:0,RULE:Release_Ham,ACTION:r elease,TS:30 X-CID-META: VersionHash:82c5f88,CLOUDID:fb46e68ba4aa035b83d1e11ad33e5b48,BulkI D:241023135508YRKI0UUL,BulkQuantity:2,Recheck:0,SF:841|72|19|66|102,TC:nil ,Content:0,EDM:5,IP:nil,URL:0,File:nil,RT:nil,Bulk:40,QS:nil,BEC:nil,COL:0 ,OSI:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_FSD X-UUID: 06cf927c910711efa216b1d71e6e1362-20241023 X-User: xiaopei01@kylinos.cn Received: from xiaopei-pc.. [(10.44.16.150)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA with TLSv1.3 TLS_AES_256_GCM_SHA384 256/256) with ESMTP id 219048297; Wed, 23 Oct 2024 14:21:23 +0800 From: Pei Xiao To: surenb@google.com Cc: akpm@linux-foundation.org, gehao@kylinos.cn, hao.ge@linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org, vbabka@suse.cz, xiaopei01@kylinos.cn, xiaopeitux@foxmail.com, xiongxin@kylinos.cn, yuzhao@google.com Subject: [PATCH] slub_kunit:fix a WARNING due to __kmalloc_cache_noprof incorretly use Date: Wed, 23 Oct 2024 14:21:17 +0800 Message-Id: <0c215961308b0433cd76389fe53d7f7776a32dcb.1729663738.git.xiaopei01@kylinos.cn> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: CE072C001C X-Stat-Signature: d4ggizpx7355ry99nwqugxzgn3n1icqr X-Rspam-User: X-HE-Tag: 1729664468-995184 X-HE-Meta: U2FsdGVkX1+dNeh9WSOSXOrVJ0EL3btbs0t2IZL4oZVVbXjeFmcvZ2tC4pFZR72deMB+KUSswQJjQdBSM4uTBryVag+YeNd+iUr1tN6/Dohw8UHCagV52jcuOR4Q/jHkq65zHtIo6oDzhjPSQIr/M/sYCttuEv/imuLeYp9ASR8XcOVOZ8g/8dPhj0erOBZxLBnxZPpEWBO+sHQz0pqAb4I+TnCKuhg1H6lgE5a44nKwfNIVLCcRY1VzwCcpe+ofVOulwhjiOUA8lqIlNFXv8u0nIpQ+WDaw8AIS89o5TG08iGtB1n/I5RK6n8j7nouGoQ2p2kG61nq7E36fRxaixdn7G5jT3HESKAgGZJJHUTwseQO4moSU/bH9qEncoDnEBCPjEYAw3yl7o2QfeaiChgpgeVMKTU1r+k6qhaal3Ue/GCFx6BNb8pUWRuDOni02E/cyNcy4ECR12Z0jtAp3pscoBV6FlHpVbHp8qcSuVV6gxS9rA4HtE0TndHE0jbSKOjAZxSzzPo+0UlIGGdCpGGtOqcCVq0R1nwas3FZsofDIxXJdI13X4wheBzAag2EzojQhiZZFvMN8RMsXufoEgkAfhLS8z4O8lU/UBILw7cODOJQSRa2SWKz+Efs/0bwu2NoukeuGjULO6u+uCnZGAkwm18jhLuOUHRsMcR59RNzwFf0oJ/dDqNEi+MiS7HO4W8KvMavEYDehz8ZY3WKKSfsyTF5jj0ax9bcl61wU99/lP3uZkl0jgMc8UhG5ympzwO6tYPJ+HmPzSsPA/D8zH/6TmO41eObkEiHJtGsBkjmeQGw4v43K1sDlkEmCt9+tlf2EPMSnp03EzAHup3yNnYVD2Qf8pQma7UIBKlblosVQ1yHHPw9V2wXozm2UPw+m1jmLUkzYqqg27omZBVPmCs329ABAwyhRhq4QESWHOayqlW9mimffLODi7TI3sH4Wnt7EspLks5Ud0je/x1A 8Lick8cd UlLeBasTox5hUvEUgBUs6rgfQYSqkBVejQbNMilXbcIYqTTHYx4rhgeDq8ZqN+aNds/7f/Ydn+5LF5XO70Sm+9vXkZA== 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: 'modprobe slub_kunit',will have a warning [1].The root cause is that __kmalloc_cache_noprof was directly used,which resulted in no alloc_tag being allocated.This caused current->alloc_tag to be null,leading to a warning in alloc_tag_add_check. Let's add an alloc_hook layer to __kmalloc_cache_noprof specifically within lib/slub_kunit.c. [1]. [58162.947016] WARNING: CPU: 2 PID: 6210 at ./include/linux/alloc_tag.h:125 alloc_tagging_slab_alloc_hook+0x268/0x27c [58162.957721] Call trace: [58162.957919] alloc_tagging_slab_alloc_hook+0x268/0x27c [58162.958286] __kmalloc_cache_noprof+0x14c/0x344 [58162.958615] test_kmalloc_redzone_access+0x50/0x10c [slub_kunit] [58162.959045] kunit_try_run_case+0x74/0x184 [kunit] [58162.959401] kunit_generic_run_threadfn_adapter+0x2c/0x4c [kunit] [58162.959841] kthread+0x10c/0x118 [58162.960093] ret_from_fork+0x10/0x20 [58162.960363] ---[ end trace 0000000000000000 ]--- Signed-off-by: Pei Xiao Fixes: a0a44d9175b3 ("mm, slab: don't wrap internal functions with alloc_hooks()") Fixes: a286da323418 ("mm/slub, kunit: Add testcase for krealloc redzone and zeroing") --- lib/slub_kunit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/slub_kunit.c b/lib/slub_kunit.c index 3cd1cc667988..f11691315c2f 100644 --- a/lib/slub_kunit.c +++ b/lib/slub_kunit.c @@ -141,7 +141,7 @@ static void test_kmalloc_redzone_access(struct kunit *test) { struct kmem_cache *s = test_kmem_cache_create("TestSlub_RZ_kmalloc", 32, SLAB_KMALLOC|SLAB_STORE_USER|SLAB_RED_ZONE); - u8 *p = __kmalloc_cache_noprof(s, GFP_KERNEL, 18); + u8 *p = alloc_hooks(__kmalloc_cache_noprof(s, GFP_KERNEL, 18)); kasan_disable_current(); @@ -199,7 +199,7 @@ static void test_krealloc_redzone_zeroing(struct kunit *test) struct kmem_cache *s = test_kmem_cache_create("TestSlub_krealloc", 64, SLAB_KMALLOC|SLAB_STORE_USER|SLAB_RED_ZONE); - p = __kmalloc_cache_noprof(s, GFP_KERNEL, 48); + p = alloc_hooks(__kmalloc_cache_noprof(s, GFP_KERNEL, 48)); memset(p, 0xff, 48); kasan_disable_current();