From mboxrd@z Thu Jan 1 00:00:00 1970 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 DE696C433F5 for ; Mon, 7 Mar 2022 07:45:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 602868D0002; Mon, 7 Mar 2022 02:45:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5B2BC8D0001; Mon, 7 Mar 2022 02:45:30 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4A0C18D0002; Mon, 7 Mar 2022 02:45:30 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0225.hostedemail.com [216.40.44.225]) by kanga.kvack.org (Postfix) with ESMTP id 386E88D0001 for ; Mon, 7 Mar 2022 02:45:30 -0500 (EST) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id D40E4182EFDCF for ; Mon, 7 Mar 2022 07:45:29 +0000 (UTC) X-FDA: 79216805178.23.E970EEA Received: from out30-133.freemail.mail.aliyun.com (out30-133.freemail.mail.aliyun.com [115.124.30.133]) by imf30.hostedemail.com (Postfix) with ESMTP id DE02080004 for ; Mon, 7 Mar 2022 07:45:28 +0000 (UTC) X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R191e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04400;MF=dtcccc@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0V6SREaW_1646639116; Received: from localhost.localdomain(mailfrom:dtcccc@linux.alibaba.com fp:SMTPD_---0V6SREaW_1646639116) by smtp.aliyun-inc.com(127.0.0.1); Mon, 07 Mar 2022 15:45:25 +0800 From: Tianchen Ding To: Alexander Potapenko , Marco Elver , Dmitry Vyukov , Andrew Morton Cc: kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 0/2] provide the flexibility to enable KFENCE Date: Mon, 7 Mar 2022 15:45:14 +0800 Message-Id: <20220307074516.6920-1-dtcccc@linux.alibaba.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: DE02080004 X-Stat-Signature: 76xui4kmyjqywggddyicfw64f56kh3aa Authentication-Results: imf30.hostedemail.com; dkim=none; spf=pass (imf30.hostedemail.com: domain of dtcccc@linux.alibaba.com designates 115.124.30.133 as permitted sender) smtp.mailfrom=dtcccc@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com X-Rspam-User: X-HE-Tag: 1646639128-589306 Content-Transfer-Encoding: quoted-printable 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: This is v3 for (re-)enabling KFENCE. If CONFIG_CONTIG_ALLOC is not supported, we fallback to try alloc_pages_exact(). Allocating pages in this way has limits about MAX_ORDER (default 11). So we will not support allocating kfence pool after system startup with a large KFENCE_NUM_OBJECTS. When handling failures in kfence_init_pool_late(), we pair free_pages_exact() to alloc_pages_exact() for compatibility consideration, though it actually does the same as free_contig_range(). v3: Use alloc_pages_exact() instead of alloc_contig_pages() if CONFIG_CONTIG_ALLOC is not defined. v2: https://lore.kernel.org/all/20220305144858.17040-1-dtcccc@linux.aliba= ba.com/ Take KFENCE_WARN_ON() into account. Do not allow re-enabling KFENCE if it once disabled by warn. Modify func names and comments. RFC/v1: https://lore.kernel.org/all/20220303031505.28495-1-dtcccc@linux.a= libaba.com/ Tianchen Ding (2): kfence: Allow re-enabling KFENCE after system startup kfence: Alloc kfence_pool after system startup mm/kfence/core.c | 126 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 105 insertions(+), 21 deletions(-) --=20 2.27.0