From: Alexander Potapenko <glider@google.com>
To: Marco Elver <elver@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Dmitry Vyukov <dvyukov@google.com>,
kasan-dev <kasan-dev@googlegroups.com>,
LKML <linux-kernel@vger.kernel.org>,
Linux Memory Management List <linux-mm@kvack.org>
Subject: Re: [PATCH] kfence: allow use of a deferrable timer
Date: Tue, 8 Mar 2022 13:26:50 +0100 [thread overview]
Message-ID: <CAG_fn=X4JbFSHa1155CJasnH-4ECsqPijoT3WjYHAmJzK=AwFg@mail.gmail.com> (raw)
In-Reply-To: <20220308122023.3068150-1-elver@google.com>
[-- Attachment #1: Type: text/plain, Size: 3223 bytes --]
On Tue, Mar 8, 2022 at 1:20 PM Marco Elver <elver@google.com> wrote:
> Allow the use of a deferrable timer, which does not force CPU wake-ups
> when the system is idle. A consequence is that the sample interval
> becomes very unpredictable, to the point that it is not guaranteed that
> the KFENCE KUnit test still passes.
>
> Nevertheless, on power-constrained systems this may be preferable, so
> let's give the user the option should they accept the above trade-off.
>
> Signed-off-by: Marco Elver <elver@google.com>
>
Reviewed-by: Alexander Potapenko <glider@google.com>
> ---
> lib/Kconfig.kfence | 12 ++++++++++++
> mm/kfence/core.c | 15 +++++++++++++--
> 2 files changed, 25 insertions(+), 2 deletions(-)
>
> diff --git a/lib/Kconfig.kfence b/lib/Kconfig.kfence
> index 912f252a41fc..1cf2ea2a1ac7 100644
> --- a/lib/Kconfig.kfence
> +++ b/lib/Kconfig.kfence
> @@ -45,6 +45,18 @@ config KFENCE_NUM_OBJECTS
> pages are required; with one containing the object and two
> adjacent
> ones used as guard pages.
>
> +config KFENCE_DEFERRABLE
> + bool "Use a deferrable timer to trigger allocations" if EXPERT
> + help
> + Use a deferrable timer to trigger allocations. This avoids
> forcing
> + CPU wake-ups if the system is idle, at the risk of a less
> predictable
> + sample interval.
> +
> + Warning: The KUnit test suite fails with this option enabled -
> due to
> + the unpredictability of the sample interval!
> +
> + Say N if you are unsure.
> +
> config KFENCE_STATIC_KEYS
> bool "Use static keys to set up allocations" if EXPERT
> depends on JUMP_LABEL
> diff --git a/mm/kfence/core.c b/mm/kfence/core.c
> index f126b53b9b85..451277b41bfb 100644
> --- a/mm/kfence/core.c
> +++ b/mm/kfence/core.c
> @@ -95,6 +95,10 @@ module_param_cb(sample_interval,
> &sample_interval_param_ops, &kfence_sample_inte
> static unsigned long kfence_skip_covered_thresh __read_mostly = 75;
> module_param_named(skip_covered_thresh, kfence_skip_covered_thresh,
> ulong, 0644);
>
> +/* If true, use a deferrable timer at the risk of unpredictable sample
> intervals. */
> +static bool kfence_deferrable __read_mostly =
> IS_ENABLED(CONFIG_KFENCE_DEFERRABLE);
> +module_param_named(deferrable, kfence_deferrable, bool, 0444);
>
Could you please add a line or two to Documentation/dev-tools/kfence.rst as
well?
--
Alexander Potapenko
Software Engineer
Google Germany GmbH
Erika-Mann-Straße, 33
80636 München
Geschäftsführer: Paul Manicle, Liana Sebastian
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Diese E-Mail ist vertraulich. Falls Sie diese fälschlicherweise erhalten
haben sollten, leiten Sie diese bitte nicht an jemand anderes weiter,
löschen Sie alle Kopien und Anhänge davon und lassen Sie mich bitte wissen,
dass die E-Mail an die falsche Person gesendet wurde.
This e-mail is confidential. If you received this communication by mistake,
please don't forward it to anyone else, please erase all copies and
attachments, and please let me know that it has gone to the wrong person.
[-- Attachment #2: Type: text/html, Size: 4085 bytes --]
prev parent reply other threads:[~2022-03-08 12:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-08 12:20 Marco Elver
2022-03-08 12:26 ` Alexander Potapenko [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAG_fn=X4JbFSHa1155CJasnH-4ECsqPijoT3WjYHAmJzK=AwFg@mail.gmail.com' \
--to=glider@google.com \
--cc=akpm@linux-foundation.org \
--cc=dvyukov@google.com \
--cc=elver@google.com \
--cc=kasan-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox