linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Yuanchu Xie <yuanchu@google.com>
To: York Jasper Niebuhr <yjnworkstation@gmail.com>
Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
	 willy@infradead.org, linux-mm@kvack.org
Subject: Re: [PATCH] mm: init_mlocked_on_free_v3
Date: Mon, 1 Apr 2024 15:34:56 -0700	[thread overview]
Message-ID: <CAJj2-QEzUjUP4kp9A-XGyjWzd9ZPmchRqYNZaw5AeYEoB7Z-Og@mail.gmail.com> (raw)
In-Reply-To: <20240329145605.149917-1-yjnworkstation@gmail.com>

On Fri, Mar 29, 2024 at 7:56 AM York Jasper Niebuhr
<yjnworkstation@gmail.com> wrote:
>
> Implements the "init_mlocked_on_free" boot option. When this boot option
> is enabled, any mlock'ed pages are zeroed on free. If
> the pages are munlock'ed beforehand, no initialization takes place.
> This boot option is meant to combat the performance hit of
> "init_on_free" as reported in commit 6471384af2a6 ("mm: security:
> introduce init_on_alloc=1 and init_on_free=1 boot options"). With
I understand the intent of the init_on_alloc and init_on_free options,
but what's the idea behind special-casing on mlock?
Is the idea that mlocking implies something other than "preventing
memory from being swapped out"?

> "init_mlocked_on_free=1" only relevant data is freed while everything
> else is left untouched by the kernel. Correspondingly, this patch
> introduces no performance hit for unmapping non-mlock'ed memory. The
> unmapping overhead for purely mlocked memory was measured to be
> approximately 13%. Realistically, most systems mlock only a fraction of
> the total memory so the real-world system overhead should be close to
> zero.
>
> Optimally, userspace programs clear any key material or other
> confidential memory before exit and munlock the according memory
> regions. If a program crashes, userspace key managers fail to do this
> job. Accordingly, no munlock operations are performed so the data is
> caught and zeroed by the kernel. Should the program not crash, all
> memory will ideally be munlocked so no overhead is caused.
>
> CONFIG_INIT_MLOCKED_ON_FREE_DEFAULT_ON can be set to enable
> "init_mlocked_on_free" by default.
>
> Signed-off-by: York Jasper Niebuhr <yjnworkstation@gmail.com>
FYI, git format-patch takes a -v parameter to specify the version of
the patch series. and scripts/checkpatch.pl should catch some of the
formatting and style issues.

I also accidentally forgot to reply all, sorry about the noise York.

Thanks,
Yuanchu Xie


  reply	other threads:[~2024-04-01 22:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-29 14:56 York Jasper Niebuhr
2024-04-01 22:34 ` Yuanchu Xie [this message]
2024-04-02 10:43 ` David Hildenbrand
2024-06-01 14:09   ` Lance Yang
2024-06-01 15:34     ` David Hildenbrand
  -- strict thread matches above, loose matches on Subject: below --
2024-03-29 11:54 York Jasper Niebuhr
2024-03-29 12:26 ` Matthew Wilcox

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=CAJj2-QEzUjUP4kp9A-XGyjWzd9ZPmchRqYNZaw5AeYEoB7Z-Og@mail.gmail.com \
    --to=yuanchu@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=willy@infradead.org \
    --cc=yjnworkstation@gmail.com \
    /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