From: "Fabio M. De Francesco" <fmdefrancesco@gmail.com>
To: dhowells@redhat.com, marc.dionne@auristor.com,
zhaoxiao <zhaoxiao@uniontech.com>
Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org,
zhaoxiao <zhaoxiao@uniontech.com>,
ira.weiny@intel.com
Subject: Re: [PATCH] afs: convert kmap() to kmap_local_page() in mntpt.c
Date: Mon, 15 Aug 2022 16:42:19 +0200 [thread overview]
Message-ID: <1752846.TLkxdtWsSY@opensuse> (raw)
In-Reply-To: <20220812080432.14909-1-zhaoxiao@uniontech.com>
On venerdì 12 agosto 2022 10:04:32 CEST zhaoxiao wrote:
> kmap() is 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 its use in mntpt.c is safe everywhere, it should be preferred.
>
> Therefore, replace kmap() with kmap_local_page() in mntpt.c.
>
> Tested in a QEMU/KVM x86_32 VM, 6GB RAM, booting a kernel with
> HIGHMEM64GB enabled.
>
> Signed-off-by: zhaoxiao <zhaoxiao@uniontech.com>
> ---
> fs/afs/mntpt.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/afs/mntpt.c b/fs/afs/mntpt.c
> index 97f50e9fd9eb..7e3cacb11780 100644
> --- a/fs/afs/mntpt.c
> +++ b/fs/afs/mntpt.c
> @@ -132,11 +132,11 @@ static int afs_mntpt_set_params(struct fs_context *fc,
> struct dentry *mntpt) if (IS_ERR(page))
> return PTR_ERR(page);
>
> - buf = kmap(page);
> + buf = kmap_local_page(page);
> ret = -EINVAL;
> if (buf[size - 1] == '.')
> ret = vfs_parse_fs_string(fc, "source", buf,
size - 1);
> - kunmap(page);
> + kunmap_local(buf);
> put_page(page);
> if (ret < 0)
> return ret;
> --
> 2.20.1
I doubt that zhaoxiao is your legal name.
If I'm not wrong, can you please submit a v2 with the name that you use to
sign documents with legal value? Otherwise, please discard this warning.
Aside from the above, this conversion looks good to me, so feel free to
forward my tag to next version...
Reviewed-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
Thanks,
Fabio
P.S.: I'm adding Ira to the list of recipients. Ira and I have been
working through converting kmap() calls to kmap_local_page(). Please let Ira
or me know if you plan on tacking more conversions so we can mark it
off the list and avoid duplicate works.
prev parent reply other threads:[~2022-08-15 14:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-12 8:04 [PATCH] afs: convert kmap() to kmap_local_page() in mntpt.c zhaoxiao
2022-08-15 14:42 ` Fabio M. De Francesco [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=1752846.TLkxdtWsSY@opensuse \
--to=fmdefrancesco@gmail.com \
--cc=dhowells@redhat.com \
--cc=ira.weiny@intel.com \
--cc=linux-afs@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marc.dionne@auristor.com \
--cc=zhaoxiao@uniontech.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