From patchwork Thu Jun 23 11:19:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?WWVlIExlZSAo5p2O5bu66Kq8KQ==?= X-Patchwork-Id: 12892110 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 76031C433EF for ; Thu, 23 Jun 2022 11:23:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C575C8E0145; Thu, 23 Jun 2022 07:23:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C075B8E0144; Thu, 23 Jun 2022 07:23:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ACEA58E0145; Thu, 23 Jun 2022 07:23:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 9B7B28E0144 for ; Thu, 23 Jun 2022 07:23:13 -0400 (EDT) Received: from smtpin31.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 6DFD980920 for ; Thu, 23 Jun 2022 11:23:13 +0000 (UTC) X-FDA: 79609264266.31.9C6EFFD Received: from mailgw01.mediatek.com (mailgw01.mediatek.com [216.200.240.184]) by imf12.hostedemail.com (Postfix) with ESMTP id 5574B4001F for ; Thu, 23 Jun 2022 11:23:12 +0000 (UTC) X-UUID: d2946e6c663d40baad0a61ca4e0d7e0a-20220623 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.6,REQID:3da2f226-3a40-4bdf-84b2-3b7732b717a5,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:0c5254ea-f7af-4e69-92ee-0fd74a0c286c,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: d2946e6c663d40baad0a61ca4e0d7e0a-20220623 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1758445860; Thu, 23 Jun 2022 04:23:06 -0700 Received: from mtkmbs10n2.mediatek.inc (172.21.101.183) by MTKMBS62N1.mediatek.inc (172.29.193.41) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 23 Jun 2022 04:19:55 -0700 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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655983393; a=rsa-sha256; cv=none; b=cRFXQZYry2/mYTVnmJL1kTGRT9tdFxnb94m0lqbEyGN65F28S9VjdPkqZTrdfb1KWyiQ3Q EbwG48f33YckBYxRxvBQja2zr7NJKV49YnTRyvOYcr6tJTpjS7GLWuSWL/UVh/LsuUPU6M 0zi8Kr4Jn1xxwhf0r4P4f0oq1lG4YXs= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=mediatek.com; spf=pass (imf12.hostedemail.com: domain of yee.lee@mediatek.com designates 216.200.240.184 as permitted sender) smtp.mailfrom=yee.lee@mediatek.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655983393; 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: in-reply-to:in-reply-to:references:references; bh=sm76w41pAm8PnOIyccnGOO5LV1X4Kpl21+W+/cD3KqE=; b=BIAVGis9yv9keIBMDNO3OQWCYuY7UxpZikaJ6u7ECFhTu7KxxCPRbU+AU/hjkacgfqTrpa cPegLNOcay4V1+QZHL0QK7fIll9Srmf8UeMPmm8/CENec6I5M2nZxaNViPCy/7yAIzbnHZ G17EQha0xWb+ssa7G+aUov1aQJ5MCls= X-Rspamd-Queue-Id: 5574B4001F X-Rspam-User: Authentication-Results: imf12.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=mediatek.com; spf=pass (imf12.hostedemail.com: domain of yee.lee@mediatek.com designates 216.200.240.184 as permitted sender) smtp.mailfrom=yee.lee@mediatek.com X-Rspamd-Server: rspam03 X-Stat-Signature: ud5komcazji4hdkx6qfaucjs69c1tror X-HE-Tag: 1655983392-76772 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: 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 += 2 * PAGE_SIZE; } - /* - * 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; } @@ -831,8 +823,14 @@ void __init kfence_alloc_pool(void) { if (!kfence_sample_interval) return; - - __kfence_pool = 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 = memblock_alloc_try_nid(KFENCE_POOL_SIZE, PAGE_SIZE, + MEMBLOCK_LOW_LIMIT, MEMBLOCK_ALLOC_NOLEAKTRACE, NUMA_NO_NODE); if (!__kfence_pool) pr_err("failed to allocate pool\n");