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 AAB65C433F5 for ; Mon, 24 Jan 2022 12:19:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 27CB86B0081; Mon, 24 Jan 2022 07:19:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 22C3F6B0083; Mon, 24 Jan 2022 07:19:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 11B2C6B0085; Mon, 24 Jan 2022 07:19:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0167.hostedemail.com [216.40.44.167]) by kanga.kvack.org (Postfix) with ESMTP id 02B506B0081 for ; Mon, 24 Jan 2022 07:19:05 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id B42BD901AE for ; Mon, 24 Jan 2022 12:19:04 +0000 (UTC) X-FDA: 79065085008.04.2CFF1AB Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf30.hostedemail.com (Postfix) with ESMTP id 60EE68000D for ; Mon, 24 Jan 2022 12:19:03 +0000 (UTC) Received: from kwepemi100026.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Jj87b3ysNz1FCXK; Mon, 24 Jan 2022 20:15:07 +0800 (CST) Received: from kwepemm600017.china.huawei.com (7.193.23.234) by kwepemi100026.china.huawei.com (7.221.188.60) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Mon, 24 Jan 2022 20:18:59 +0800 Received: from [10.174.179.19] (10.174.179.19) by kwepemm600017.china.huawei.com (7.193.23.234) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Mon, 24 Jan 2022 20:18:58 +0800 Content-Type: multipart/alternative; boundary="------------LBsQNxmvK3PJv5A2kezHXevh" Message-ID: <261a5287-af0d-424e-d209-db887d952a74@huawei.com> Date: Mon, 24 Jan 2022 20:18:57 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Subject: Re: [PATCH RFC 3/3] kfence: Make test case compatible with run time set sample interval Content-Language: en-US To: Marco Elver CC: , , , , , , , , , , References: <20220124025205.329752-1-liupeng256@huawei.com> <20220124025205.329752-4-liupeng256@huawei.com> From: "liupeng (DM)" In-Reply-To: X-Originating-IP: [10.174.179.19] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm600017.china.huawei.com (7.193.23.234) X-CFilter-Loop: Reflected X-Stat-Signature: 99w9wrejr1k8h38by3zeu7os3mm7rd4n Authentication-Results: imf30.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf30.hostedemail.com: domain of liupeng256@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=liupeng256@huawei.com X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 60EE68000D X-HE-Tag: 1643026743-661750 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: --------------LBsQNxmvK3PJv5A2kezHXevh Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit On 2022/1/24 16:25, Marco Elver wrote: > On Mon, 24 Jan 2022 at 03:37, 'Peng Liu' via kasan-dev > wrote: >> The parameter kfence_sample_interval can be set via boot parameter >> and late shell command. However, KFENCE test case just use compile >> time CONFIG_KFENCE_SAMPLE_INTERVAL, this will make KFENCE test case >> not run as user desired. This patch will make KFENCE test case >> compatible with run-time-set sample interval. >> >> Signed-off-by: Peng Liu >> --- >> include/linux/kfence.h | 2 ++ >> mm/kfence/core.c | 3 ++- >> mm/kfence/kfence_test.c | 8 ++++---- >> 3 files changed, 8 insertions(+), 5 deletions(-) >> >> diff --git a/include/linux/kfence.h b/include/linux/kfence.h >> index bf91b76b87ee..0fc913a7f017 100644 >> --- a/include/linux/kfence.h >> +++ b/include/linux/kfence.h >> @@ -19,6 +19,8 @@ >> >> extern bool kfence_enabled; >> extern unsigned long kfence_num_objects; >> +extern unsigned long kfence_sample_interval; >> + >> /* >> * We allocate an even number of pages, as it simplifies calculations to map >> * address to metadata indices; effectively, the very first page serves as an >> diff --git a/mm/kfence/core.c b/mm/kfence/core.c >> index 2301923182b8..e2fcae34cc84 100644 >> --- a/mm/kfence/core.c >> +++ b/mm/kfence/core.c >> @@ -50,7 +50,8 @@ >> >> bool kfence_enabled __read_mostly; >> >> -static unsigned long kfence_sample_interval __read_mostly = CONFIG_KFENCE_SAMPLE_INTERVAL; >> +unsigned long kfence_sample_interval __read_mostly = CONFIG_KFENCE_SAMPLE_INTERVAL; >> +EXPORT_SYMBOL(kfence_sample_interval); /* Export for test modules. */ > While it would make some situations more convenient, I've wanted to > avoid exporting a new symbol just for the test. And in most cases it > only makes sense to run the test on a custom debug kernel. > > Why do you need this? To automatically do more tests. > > Should you really need this, I suggest at least using > EXPORT_SYMBOL_GPL. Should you want it, you can resend this patch > standalone detached from the rest. > > Thanks, > -- Marco > . When KFENCE pool size can be adjusted by boot parameters(assumption), automatically test and train KFENCE may be useful. So far, exporting kfence.sample_interval is not necessary. Thanks, -- Peng Liu . --------------LBsQNxmvK3PJv5A2kezHXevh Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: 7bit


On 2022/1/24 16:25, Marco Elver wrote:
On Mon, 24 Jan 2022 at 03:37, 'Peng Liu' via kasan-dev
<kasan-dev@googlegroups.com> wrote:
The parameter kfence_sample_interval can be set via boot parameter
and late shell command. However, KFENCE test case just use compile
time CONFIG_KFENCE_SAMPLE_INTERVAL, this will make KFENCE test case
not run as user desired. This patch will make KFENCE test case
compatible with run-time-set sample interval.

Signed-off-by: Peng Liu <liupeng256@huawei.com>
---
 include/linux/kfence.h  | 2 ++
 mm/kfence/core.c        | 3 ++-
 mm/kfence/kfence_test.c | 8 ++++----
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/include/linux/kfence.h b/include/linux/kfence.h
index bf91b76b87ee..0fc913a7f017 100644
--- a/include/linux/kfence.h
+++ b/include/linux/kfence.h
@@ -19,6 +19,8 @@

 extern bool kfence_enabled;
 extern unsigned long kfence_num_objects;
+extern unsigned long kfence_sample_interval;
+
 /*
  * We allocate an even number of pages, as it simplifies calculations to map
  * address to metadata indices; effectively, the very first page serves as an
diff --git a/mm/kfence/core.c b/mm/kfence/core.c
index 2301923182b8..e2fcae34cc84 100644
--- a/mm/kfence/core.c
+++ b/mm/kfence/core.c
@@ -50,7 +50,8 @@

 bool kfence_enabled __read_mostly;

-static unsigned long kfence_sample_interval __read_mostly = CONFIG_KFENCE_SAMPLE_INTERVAL;
+unsigned long kfence_sample_interval __read_mostly = CONFIG_KFENCE_SAMPLE_INTERVAL;
+EXPORT_SYMBOL(kfence_sample_interval); /* Export for test modules. */
While it would make some situations more convenient, I've wanted to
avoid exporting a new symbol just for the test. And in most cases it
only makes sense to run the test on a custom debug kernel.

Why do you need this?
To automatically do more tests.

Should you really need this, I suggest at least using
EXPORT_SYMBOL_GPL. Should you want it, you can resend this patch
standalone detached from the rest.

Thanks,
-- Marco
.
When KFENCE pool size can be adjusted by boot parameters(assumption),
automatically test and train KFENCE may be useful. So far, exporting
kfence.sample_interval is not necessary. 

Thanks,
-- Peng Liu
.

--------------LBsQNxmvK3PJv5A2kezHXevh--