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 68265C433F5 for ; Mon, 7 Feb 2022 08:55:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AEB556B0078; Mon, 7 Feb 2022 03:55:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A99DD6B007B; Mon, 7 Feb 2022 03:55:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 988DF6B007D; Mon, 7 Feb 2022 03:55:54 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0049.hostedemail.com [216.40.44.49]) by kanga.kvack.org (Postfix) with ESMTP id 855836B0078 for ; Mon, 7 Feb 2022 03:55:54 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 3AE1C181B048D for ; Mon, 7 Feb 2022 08:55:54 +0000 (UTC) X-FDA: 79115376228.19.E0660F9 Received: from mail-yb1-f171.google.com (mail-yb1-f171.google.com [209.85.219.171]) by imf08.hostedemail.com (Postfix) with ESMTP id CC5E6160004 for ; Mon, 7 Feb 2022 08:55:53 +0000 (UTC) Received: by mail-yb1-f171.google.com with SMTP id c6so37869274ybk.3 for ; Mon, 07 Feb 2022 00:55:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=knF2fFP9aIoGTNmgPKFlIdzkXuLeb4VSUzI7AmunKNY=; b=kjKQjXhqwEwzFPGB6U7llci4Uyu0GDktsh9CriN7LUAxMChIRo0PfU0thwAaw7TEV0 eqCQDKSViTSVsvrwmtQtElbEyfpkPhnyg4gPW1DbIanejHpDHkfG/4K2wXFclclpkWzI 6WWHlSneOzKtnn8OzsMKXLagS1YERguBWMQh1qbU+fUkMIO42i0rVSiMI/6AnVSMVSkP QIAO7fAtsQeLrnZrgbbX9hklHmvYu1UJxrrxfeJ11kickjSzmqyKZiEW+JH0AbcMcCp7 WeBBZbhdpkYxU/69NVf1lZzL3bs3DuayqvwzIEsIba6Y/YaBjtid3TAMYdo7sfNwHMiQ LMBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=knF2fFP9aIoGTNmgPKFlIdzkXuLeb4VSUzI7AmunKNY=; b=r+uSt4eo9JuBK1SRIMBEG+GfddX9n47rXikhv68G1SqMA8iUJfp7WFC+ERfnBuvD70 DjJv3SVBKX//GetnMVraJcqU1fCoDB7ONPoivxU5MxV1HskFNvbaV1adCcHPqFL3lgb2 iXBmIVOAiK/a9LK1yNK7fG2phU6KHLu1qV64CxIBHNxNMfvTHS5dkqzruZ6ajTZjlGUT kSTT32vU2q/tb5O1bn9+mPSnWa1T/tWuoRi6o0mXr+8tDSEQ6RitbuGxOsgoWjS+2oFY RX6C790i2NNssAeE0BRLv3cpifDn58DuISP3XEtuDKKx1cMRGuQGhuRVcv6Sdjtif+Ux +/qA== X-Gm-Message-State: AOAM533Zlu0WvgmQLFsPvE+mF/UN4m3fBbDGPQMSo9tIax2LLKudHKgd gduRCtKHUhWQVB5uYCJ38Cm9bn7oU60K8jotY5D3mA== X-Google-Smtp-Source: ABdhPJyWH7PhtKu+j316v5w82AR7rHUJWXjLEcMawUmUXMQHsH7DXQJajqIi03ZoF4QFGuosxGiLrl/nfBv2NmF3nwQ= X-Received: by 2002:a81:c505:: with SMTP id k5mr6144103ywi.264.1644224152818; Mon, 07 Feb 2022 00:55:52 -0800 (PST) MIME-Version: 1.0 References: <20220207034432.185532-1-liupeng256@huawei.com> In-Reply-To: <20220207034432.185532-1-liupeng256@huawei.com> From: Marco Elver Date: Mon, 7 Feb 2022 09:55:41 +0100 Message-ID: Subject: Re: [PATCH v3] kfence: Make test case compatible with run time set sample interval To: Peng Liu Cc: glider@google.com, dvyukov@google.com, corbet@lwn.net, sumit.semwal@linaro.org, christian.koenig@amd.com, akpm@linux-foundation.org, kasan-dev@googlegroups.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linaro-mm-sig@lists.linaro.org, linux-mm@kvack.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: CC5E6160004 X-Stat-Signature: 1b7jbommb4t9b1gpg8s9je6temowd6wo Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=kjKQjXhq; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf08.hostedemail.com: domain of elver@google.com designates 209.85.219.171 as permitted sender) smtp.mailfrom=elver@google.com X-Rspam-User: nil X-HE-Tag: 1644224153-386004 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: On Mon, 7 Feb 2022 at 04:29, 'Peng Liu' via kasan-dev wrote: > > The parameter kfence_sample_interval can be set via boot parameter > and late shell command, which is convenient for automated tests and > KFENCE parameter optimization. However, KFENCE test case just uses > compile-time CONFIG_KFENCE_SAMPLE_INTERVAL, which will make KFENCE > test case not run as users desired. Export kfence_sample_interval, > so that KFENCE test case can use run-time-set sample interval. > > Signed-off-by: Peng Liu Reviewed-by: Marco Elver Thank you. > --- > v2->v3: > - Revise change log description > v1->v2: > - Use EXPORT_SYMBOL_GPL replace EXPORT_SYMBOL > > 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 4b5e3679a72c..f49e64222628 100644 > --- a/include/linux/kfence.h > +++ b/include/linux/kfence.h > @@ -17,6 +17,8 @@ > #include > #include > > +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 5ad40e3add45..13128fa13062 100644 > --- a/mm/kfence/core.c > +++ b/mm/kfence/core.c > @@ -47,7 +47,8 @@ > > static 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_GPL(kfence_sample_interval); /* Export for test modules. */ > > #ifdef MODULE_PARAM_PREFIX > #undef MODULE_PARAM_PREFIX > diff --git a/mm/kfence/kfence_test.c b/mm/kfence/kfence_test.c > index a22b1af85577..50dbb815a2a8 100644 > --- a/mm/kfence/kfence_test.c > +++ b/mm/kfence/kfence_test.c > @@ -268,13 +268,13 @@ static void *test_alloc(struct kunit *test, size_t size, gfp_t gfp, enum allocat > * 100x the sample interval should be more than enough to ensure we get > * a KFENCE allocation eventually. > */ > - timeout = jiffies + msecs_to_jiffies(100 * CONFIG_KFENCE_SAMPLE_INTERVAL); > + timeout = jiffies + msecs_to_jiffies(100 * kfence_sample_interval); > /* > * Especially for non-preemption kernels, ensure the allocation-gate > * timer can catch up: after @resched_after, every failed allocation > * attempt yields, to ensure the allocation-gate timer is scheduled. > */ > - resched_after = jiffies + msecs_to_jiffies(CONFIG_KFENCE_SAMPLE_INTERVAL); > + resched_after = jiffies + msecs_to_jiffies(kfence_sample_interval); > do { > if (test_cache) > alloc = kmem_cache_alloc(test_cache, gfp); > @@ -608,7 +608,7 @@ static void test_gfpzero(struct kunit *test) > int i; > > /* Skip if we think it'd take too long. */ > - KFENCE_TEST_REQUIRES(test, CONFIG_KFENCE_SAMPLE_INTERVAL <= 100); > + KFENCE_TEST_REQUIRES(test, kfence_sample_interval <= 100); > > setup_test_cache(test, size, 0, NULL); > buf1 = test_alloc(test, size, GFP_KERNEL, ALLOCATE_ANY); > @@ -739,7 +739,7 @@ static void test_memcache_alloc_bulk(struct kunit *test) > * 100x the sample interval should be more than enough to ensure we get > * a KFENCE allocation eventually. > */ > - timeout = jiffies + msecs_to_jiffies(100 * CONFIG_KFENCE_SAMPLE_INTERVAL); > + timeout = jiffies + msecs_to_jiffies(100 * kfence_sample_interval); > do { > void *objects[100]; > int i, num = kmem_cache_alloc_bulk(test_cache, GFP_ATOMIC, ARRAY_SIZE(objects), > -- > 2.18.0.huawei.25 > > -- > You received this message because you are subscribed to the Google Groups "kasan-dev" group. > To unsubscribe from this group and stop receiving emails from it, send an email to kasan-dev+unsubscribe@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msgid/kasan-dev/20220207034432.185532-1-liupeng256%40huawei.com.