Re: [PATCH 00/23] KAISER: unmap most of the kernel from userspace page tables

From: Linus Torvalds
Date: Wed Nov 01 2017 - 18:28:57 EST


On Wed, Nov 1, 2017 at 3:14 PM, Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx> wrote:
>
> I ran some quick tests. When CONFIG_KAISER=y, but "echo 0 >
> kaiser-enabled", the tests that I ran were within the noise vs. a
> vanilla kernel, and that's with *zero* optimization.

I guess the optimal version just ends up switching between two
different entrypoints for the on/off case.

And the not-quite-as-aggressive, but almost-optimal version would just
be a two-byte asm alternative with an unconditional branch to the
movcr3 code and back, and is turned into a noop when it's off.

But since 99%+ of the cost is going to be that cr3 write, even the
stupid "just load value and branch over the cr3 conditionally" is
going to make things hard to measure.

Linus