linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Fabio M. De Francesco" <fmdefrancesco@gmail.com>
To: Kees Cook <keescook@chromium.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
	Eric Biederman <ebiederm@xmission.com>,
	linux-fsdevel@vger.kernel.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, Ira Weiny <ira.weiny@intel.com>
Subject: Re: [PATCH v2] fs: Replace kmap{,_atomic}() with kmap_local_page()
Date: Sat, 13 Aug 2022 15:36:53 +0200	[thread overview]
Message-ID: <8143586.NyiUUSuA9g@opensuse> (raw)
In-Reply-To: <20220803182856.28246-1-fmdefrancesco@gmail.com>

On mercoledì 3 agosto 2022 20:28:56 CEST Fabio M. De Francesco wrote:
> The use of kmap() and kmap_atomic() are being deprecated in favor of
> kmap_local_page().
> 
> There are two main problems with kmap(): (1) It comes with an overhead as
> mapping space is restricted and protected by a global lock for
> synchronization and (2) it also requires global TLB invalidation when the
> kmap’s pool wraps and it might block when the mapping space is fully
> utilized until a slot becomes available.
> 
> With kmap_local_page() the mappings are per thread, CPU local, can take
> page faults, and can be called from any context (including interrupts).
> It is faster than kmap() in kernels with HIGHMEM enabled. Furthermore,
> the tasks can be preempted and, when they are scheduled to run again, the
> kernel virtual addresses are restored and are still valid.
> 
> Since the use of kmap_local_page() in exec.c is safe, it should be
> preferred everywhere in exec.c.
> 
> As said, since kmap_local_page() can be also called from atomic context,
> and since remove_arg_zero() doesn't (and shouldn't ever) rely on an
> implicit preempt_disable(), this function can also safely replace
> kmap_atomic().
> 
> Therefore, replace kmap() and kmap_atomic() with kmap_local_page() in
> fs/exec.c.
> 
> Tested with xfstests on a QEMU/KVM x86_32 VM, 6GB RAM, booting a kernel
> with HIGHMEM64GB enabled.
> 
> Cc: Eric W. Biederman <ebiederm@xmission.com>
> Suggested-by: Ira Weiny <ira.weiny@intel.com>
> Reviewed-by: Ira Weiny <ira.weiny@intel.com>
> Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
> ---
> 
> v1->v2: Added more information to the commit log to address some
> objections expressed by Eric W. Biederman[1] in reply to v1. No changes
> have been made to the code. Forwarded a tag from Ira Weiny (thanks!).
> 
> [1]
> https://lore.kernel.org/lkml/8735fmqcfz.fsf@email.froward.int.ebiederm.org/
>
>  fs/exec.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 

Hi Kees,

After that thread about the report from Syzbot, and the subsequent discussion, 
I noticed that you didn't yet take this other patch for exec.c.

I suppose that the two patches would better go out together. So I'm writing 
for sending a gentle ping.

As I said, no changes have been made to the code with respect to v1 (which I 
submitted in June). However, later I thought that adding more information 
might have helped reviewers and maintainers to better understand the why of 
this patch.

Thanks,

Fabio
 





  reply	other threads:[~2022-08-13 13:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-03 18:28 Fabio M. De Francesco
2022-08-13 13:36 ` Fabio M. De Francesco [this message]
2022-08-16 19:08   ` Kees Cook
2022-08-16 19:13 ` Kees Cook

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=8143586.NyiUUSuA9g@opensuse \
    --to=fmdefrancesco@gmail.com \
    --cc=ebiederm@xmission.com \
    --cc=ira.weiny@intel.com \
    --cc=keescook@chromium.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=viro@zeniv.linux.org.uk \
    /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