From patchwork Mon May 24 09:25:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 12276757 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_2 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9DB7BC04FF3 for ; Mon, 24 May 2021 18:00:23 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5E6CB613D2 for ; Mon, 24 May 2021 18:00:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5E6CB613D2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=synaptics.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=csO/NaumGTBtms11xw1h7nDur8+SH5URcaj1wDeHejY=; b=3T71LRRfjj8In9 EHk1zzr1kNbyTpyFsVXadFpgDTzw3bjd+hZ4hARKQeFJoshJCBZfMMmbkCI6yI7F27HX0piFQDTBz uAqM0326FykvdBUaFsFc3Ia2qM+f+dhuIpUnws5uG9gZwAxxRWSxnwjZ3m2oyYMU9T3PGZY4Jj+mG i/FqdfCzF+DzOWRwdGfnfeBuko2/KmdpBRJY/uO6A9lnHdvSp+51m+PSJYcm201VosqFnlCOh9i9Q wxxd+rkFy6ThdXxqUWyOI1OpTaE4/bYb6m2SVqcmQPqtJntZ/IsppaVL+uGUgNc0/+U0BTa/yGdvj U+vnhB0my59l8pzd9UpQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1llEpw-001Muq-K2; Mon, 24 May 2021 17:57:58 +0000 Received: from mail-mw2nam10on2050.outbound.protection.outlook.com ([40.107.94.50] helo=NAM10-MW2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1ll6r0-000nkY-VC for linux-arm-kernel@lists.infradead.org; Mon, 24 May 2021 09:26:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BjhgAeO8wwJW4KWCQ5dJcdiiM3zkqcsTMc6JFrj2uBwgYxjAOYWK/vTB5spDkU/ZDWG+0mFLWpoTkzy60NlSTuFNJxUjqWD/qzxTfEoWMx06QHNc4Q/TtqzoC7bofzvqNLyn/BMUEAs1D5+5q+NQAAcMtfysEjXIBWCW3UsJCafOGBATyzvpoanfP06qg3GqJULx+44+OISsYNGgEkxckGrwN5gb5z4i5bfRcvviAb6VxpXOYbHP2TK2X13DQWc798JjeaZeMmlGiH89vi1F3GRx5PfsaOixfxtJ3exoon3B8SxOeKWzMDn3+rOOSOrstLU9sZoOkP2dQOf4kEREcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6M0nJU/y2MKjtfSlFmSxDKO8kQQbJQf3ehgUixbHk4A=; b=ixj30kcvisQs6iMv8pQKHVnqGadRLMr94irbBwGYYkgbMlddrvUNBHrkW0AtMO0p1JzpYoGqL+xattSTGiARbZKKU24tYNiItDV6FgaJRxs/POgKl/GI07Fea0hq2B9/K/VbEuPe0NP5498V9xh9NXkwEsbGkt3w8NxL6E0T/3sJ0YgAYqWG7pWeKBpQw8Ex3YnAfm3066tThVCl7jlM/5bcWqRvg5o0vA+g2bm7R/vniBPoIH49pKXAlN97GB+5Pn1qD+sRaO4lmhLgAIEarr6KXJZUMqvkkQihwa5pdBEybs+tiuwUYSox2/du+MYzy6SPQx4/1CtQWBLhluaW8Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=synaptics.com; dmarc=pass action=none header.from=synaptics.com; dkim=pass header.d=synaptics.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Synaptics.onmicrosoft.com; s=selector2-Synaptics-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6M0nJU/y2MKjtfSlFmSxDKO8kQQbJQf3ehgUixbHk4A=; b=bQe6+eQavRbTPBlEHoNu5EwVQTDryAlJg9MvZOs3a+mthU2FfQI+cVUTjZP3X87u5mY1YuMnWZTPzWaYKMZAEUGPyuGNclLhm8/gxL34IG/kEEMUI6DSk8UyKMSX9jK7oeEL9RxW/Xwi0/1xcNhUEGpL3t7rmn3Sc596fM3th5I= Authentication-Results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=synaptics.com; Received: from BN9PR03MB6058.namprd03.prod.outlook.com (2603:10b6:408:137::15) by BN9PR03MB6188.namprd03.prod.outlook.com (2603:10b6:408:101::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.23; Mon, 24 May 2021 09:26:27 +0000 Received: from BN9PR03MB6058.namprd03.prod.outlook.com ([fe80::308b:9168:78:9791]) by BN9PR03MB6058.namprd03.prod.outlook.com ([fe80::308b:9168:78:9791%4]) with mapi id 15.20.4150.027; Mon, 24 May 2021 09:26:26 +0000 Date: Mon, 24 May 2021 17:25:29 +0800 From: Jisheng Zhang To: Catalin Marinas , Will Deacon , Alexander Potapenko , Marco Elver , Dmitry Vyukov , Andrew Morton Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org Subject: [PATCH 1/2] kfence: allow providing __kfence_pool in arch specific way Message-ID: <20210524172529.3d23c3e7@xhacker.debian> In-Reply-To: <20210524172433.015b3b6b@xhacker.debian> References: <20210524172433.015b3b6b@xhacker.debian> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) X-Originating-IP: [192.147.44.204] X-ClientProxiedBy: BY5PR17CA0069.namprd17.prod.outlook.com (2603:10b6:a03:167::46) To BN9PR03MB6058.namprd03.prod.outlook.com (2603:10b6:408:137::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from xhacker.debian (192.147.44.204) by BY5PR17CA0069.namprd17.prod.outlook.com (2603:10b6:a03:167::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.26 via Frontend Transport; Mon, 24 May 2021 09:26:23 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 212b5db6-68fb-4623-cbff-08d91e96014d X-MS-TrafficTypeDiagnostic: BN9PR03MB6188: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4941; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MVcBFegMUBkO7fU0YjcOqwYno3UYFc/Jgq9KIewO2toWp82wXWMRVvR/uMP8Pj1iMYKU0RMkWhrYJTCytSnwhV2GLiBCH1FngUvinN+aKSmySXZqACsmpU9Wf3tRQ0vUGeg4u2oTLfMjBBvaqE7ktuRjGPDyOjRPuwoft2fBGgAS02o5jVhvzyhSThtkuH5xjkmqZ+6DM40YzrGosvSJjm0lbvLXLE4dtLigO7nSwRWAx40+o7lqgy5I9Cblf9DjfTVVlr44yVKpYPaqUKqasn5ns7FuuuY0JT1SqOanr2xflKTG3RvXMKU0KTV3p5H5ms3eFHGombtFZrJjbZG3FgIvU0iITX+5Leu0nC2V99Ik7kkGbDCSsAFjj+XXyO/VA4mEv6aQBan/SSmBWYugMGzt6NORGZOYXe07mlY3Rvq5sgpL4DpexV98kMTk2xCOutr6B1E83u1OkOOD5pKuacDXHH/OQmkDCjhFDIEYmpn3GBWWw0N2uCvLOMHnsW8/zRXuTVILHha85Be5vvVAyqVorZlSnX1Uqtz1FTCZ8OzYY5qal0tdhRnow2v82MZbBb5XimXVzI8lmguiitFRoLneW3LjpqvzQA35AXJ2svaOQGO0HVzi577sJXVkJjOX1Uck8KyDS1AA0jgaG0LtqiokWGvU5Ry/fkdZtguTU9k= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN9PR03MB6058.namprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(39850400004)(346002)(376002)(396003)(136003)(366004)(66946007)(1076003)(316002)(66556008)(66476007)(5660300002)(478600001)(2906002)(4326008)(110136005)(7416002)(16526019)(186003)(26005)(8676002)(52116002)(7696005)(956004)(55016002)(6506007)(86362001)(83380400001)(38350700002)(9686003)(38100700002)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 0qMlpUMKtnluZ2JfT5oP48G8nX2hVfICByh/N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RUEyAUe0Bj0gaUdq9w54hbUxX7Ikwko3WQFM6E1FT05DO47y37FUNNrDgtveK8CHKb8rdExeIxVS9M8LxpUqjEU6mYaBUIGcDFNZyS1FWcFB3WA3v0lf5E/LmgD7y3mH0cyGcjA77FW3rmTVuKPika4tfes8x7/S9FZulgk55YiGuyPIHH1nmv0eQpIbfm+I6LY8BhAjbKBlS79+A8dHsO1mDzqZ6+JbHQLdAOGOA4PhsODAo X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-Network-Message-Id: 212b5db6-68fb-4623-cbff-08d91e96014d X-MS-Exchange-CrossTenant-AuthSource: BN9PR03MB6058.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2021 09:26:26.7669 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335d1fbc-2124-4173-9863-17e7051a2a0e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: CZRkAq73ytDBjrW+o+bNwG4TB+9naOak+z8LepMTL09TGP1P8l/gY0vREYptP6xErxvf22sfleFXhzBH+wATbQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR03MB6188 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210524_022631_100861_C6FF1998 X-CRM114-Status: GOOD ( 11.89 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Some architectures may want to allocate the __kfence_pool differently for example, allocate the __kfence_pool earlier before paging_init(). We also delay the memset() to kfence_init_pool(). Signed-off-by: Jisheng Zhang --- mm/kfence/core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mm/kfence/core.c b/mm/kfence/core.c index e18fbbd5d9b4..65f0210edb65 100644 --- a/mm/kfence/core.c +++ b/mm/kfence/core.c @@ -430,6 +430,8 @@ static bool __init kfence_init_pool(void) if (!__kfence_pool) return false; + memset(__kfence_pool, 0, KFENCE_POOL_SIZE); + if (!arch_kfence_init_pool()) goto err; @@ -645,10 +647,10 @@ static DECLARE_DELAYED_WORK(kfence_timer, toggle_allocation_gate); void __init kfence_alloc_pool(void) { - if (!kfence_sample_interval) + if (!kfence_sample_interval || __kfence_pool) return; - __kfence_pool = memblock_alloc(KFENCE_POOL_SIZE, PAGE_SIZE); + __kfence_pool = memblock_alloc_raw(KFENCE_POOL_SIZE, PAGE_SIZE); if (!__kfence_pool) pr_err("failed to allocate pool\n");