From nobody Sat Sep 21 22:50:01 2024 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C866C433EF for ; Thu, 23 Jun 2022 11:20:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231258AbiFWLUK (ORCPT ); Thu, 23 Jun 2022 07:20:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230326AbiFWLUH (ORCPT ); Thu, 23 Jun 2022 07:20:07 -0400 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 041AC4BB8B for ; Thu, 23 Jun 2022 04:20:03 -0700 (PDT) X-UUID: 06e9682c6e8d481e918fcc6f966e18f5-20220623 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.6,REQID:af011d69-7248-4d7d-be3e-479c78a82b58,OB:0,LO B:0,IP:0,URL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,RULE:Release_Ham,ACTI ON:release,TS:0 X-CID-META: VersionHash:b14ad71,CLOUDID:a6c3dc2d-1756-4fa3-be7f-474a6e4be921,C OID:IGNORED,Recheck:0,SF:nil,TC:nil,Content:0,EDM:-3,IP:nil,URL:0,File:nil ,QS:nil,BEC:nil,COL:0 X-UUID: 06e9682c6e8d481e918fcc6f966e18f5-20220623 Received: from mtkexhb02.mediatek.inc [(172.21.101.103)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 2122228748; Thu, 23 Jun 2022 19:19:55 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.3; Thu, 23 Jun 2022 19:19:54 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.3 via Frontend Transport; Thu, 23 Jun 2022 19:19:54 +0800 From: To: CC: Yee Lee , Alexander Potapenko , Marco Elver , Dmitry Vyukov , "Andrew Morton" , Matthias Brugger , "open list:KFENCE" , "open list:MEMORY MANAGEMENT" , "moderated list:ARM/Mediatek SoC support" , "moderated list:ARM/Mediatek SoC support" Subject: [PATCH 1/1] mm: kfence: skip kmemleak alloc in kfence_pool Date: Thu, 23 Jun 2022 19:19:35 +0800 Message-ID: <20220623111937.6491-2-yee.lee@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20220623111937.6491-1-yee.lee@mediatek.com> References: <20220623111937.6491-1-yee.lee@mediatek.com> MIME-Version: 1.0 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Yee Lee Use MEMBLOCK_ALLOC_NOLEAKTRACE to skip kmemleak registration when the kfence pool is allocated from memblock. And the kmemleak_free later can be removed too. Signed-off-by: Yee Lee --- mm/kfence/core.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/mm/kfence/core.c b/mm/kfence/core.c index 4e7cd4c8e687..0d33d83f5244 100644 --- a/mm/kfence/core.c +++ b/mm/kfence/core.c @@ -600,14 +600,6 @@ static unsigned long kfence_init_pool(void) addr +=3D 2 * PAGE_SIZE; } =20 - /* - * The pool is live and will never be deallocated from this point on. - * Remove the pool object from the kmemleak object tree, as it would - * otherwise overlap with allocations returned by kfence_alloc(), which - * are registered with kmemleak through the slab post-alloc hook. - */ - kmemleak_free(__kfence_pool); - return 0; } =20 @@ -831,8 +823,14 @@ void __init kfence_alloc_pool(void) { if (!kfence_sample_interval) return; - - __kfence_pool =3D memblock_alloc(KFENCE_POOL_SIZE, PAGE_SIZE); + /* + * The pool is live and will never be deallocated from this point on. + * Skip the pool object from the kmemleak object allocation, as it would + * otherwise overlap with allocations returned by kfence_alloc(), which + * are registered with kmemleak through the slab post-alloc hook. + */ + __kfence_pool =3D memblock_alloc_try_nid(KFENCE_POOL_SIZE, PAGE_SIZE, + MEMBLOCK_LOW_LIMIT, MEMBLOCK_ALLOC_NOLEAKTRACE, NUMA_NO_NODE); =20 if (!__kfence_pool) pr_err("failed to allocate pool\n"); --=20 2.18.0