mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Marco Elver <elver@google.com>
To: Chris Down <chris@chrisdown.name>
Cc: Alexander Potapenko <glider@google.com>,
	Dmitry Vyukov <dvyukov@google.com>,
	 Andrew Morton <akpm@linux-foundation.org>,
	Jonathan Corbet <corbet@lwn.net>,
	 Shuah Khan <skhan@linuxfoundation.org>,
	Randy Dunlap <rdunlap@infradead.org>,
	 kasan-dev@googlegroups.com, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org,  linux-doc@vger.kernel.org,
	kernel-team@meta.com
Subject: Re: [PATCH] kfence: Allow selecting static keys mode at boot
Date: Mon, 16 Nov 2026 08:00:00 +0100	[thread overview]
Message-ID: <CANpmjNNwaeFmVxfPsvdVSc33_DoF_Gcz9DpjGWf6PLD_GZwAyw@mail.gmail.com> (raw)
In-Reply-To: <20261114150201.d428c3847d573be1@chrisdown.name>

On Sun, 15 Nov 2026 at 00:02, Chris Down <chris@chrisdown.name> wrote:
>
> Hi Marco,
>
> Marco Elver writes:
> >On which systems have you found static keys to provide a significant
> >improvement? Can you share benchmarks?
>
> I don't have numbers that show a significant improvement. To be clear,
> the hosts that use static keys have had it set that way since long
> before I started looking at this, so it may well just be cargo culted
> by now :-) Given that, I had a go at measuring the saving on its own.
> It's there, but it's small.
>
>  From a quick check I did in an 8 CPU x86 VM, a
> kmem_cache_alloc()/kmem_cache_free() pair takes 8.0ns in static keys
> mode, which is the same as with KFENCE off. With the dynamic branch it
> takes 8.4ns. A kmalloc()/kfree() pair takes 13.3ns in all three. Both
> are the same with either branch layout.
>
> So static keys saves about half a nanosecond per allocation at best, in
> a loop that does nothing else. At a million allocations a second on a
> CPU, that accounts for 0.05% of it.

Thanks for the investigation. On x86 I thought as much; I'm just not
entirely sure about other architectures, and before deletion, that
might need some investigation.

> >IMHO, I was thinking of deleting the CONFIG_KFENCE_STATIC_KEYS mode,
> >because on most systems, it's not worth the complexity for the small
> >(if any) performance improvement anymore.
>
> I agree, and I think the numbers above are enough evidence for that.
> Deleting it is better than this patch, because all we want is one kernel
> across the fleet, and that gets us there with less code. I'm happy to
> send the removal, if you'd like.

While eventual deletion would be my preference, what you say here
doesn't make sense. "One kernel across the fleet" does not necessitate
deleting this Kconfig option from the upstream kernel. You control
your .config, and the Kconfig option is default-off nor is anyone
forced to enable it.

An intermediate step would be to e.g. not make
CONFIG_KFENCE_STATIC_KEYS selectable on certain architectures where we
are sure it causes more problems (global IPIs on systems with 100s of
CPUs) than performance improvements. We could do that for x86, and I'd
Ack that right away.

  reply	other threads:[~2026-11-16  7:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-27  5:48 Chris Down
2026-10-27  8:31 ` Marco Elver
2026-11-14 23:02   ` Chris Down
2026-11-16  7:00     ` Marco Elver [this message]
2026-11-28 18:22       ` Chris Down

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=CANpmjNNwaeFmVxfPsvdVSc33_DoF_Gcz9DpjGWf6PLD_GZwAyw@mail.gmail.com \
    --to=elver@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=chris@chrisdown.name \
    --cc=corbet@lwn.net \
    --cc=dvyukov@google.com \
    --cc=glider@google.com \
    --cc=kasan-dev@googlegroups.com \
    --cc=kernel-team@meta.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=rdunlap@infradead.org \
    --cc=skhan@linuxfoundation.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

all inboxes | Powered by JetHome®