From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: "Fabio M. De Francesco" <fmdefrancesco@gmail.com>,
"Alex Deucher" <alexander.deucher@amd.com>,
"Christian König" <christian.koenig@amd.com>,
"Pan, Xinhui" <Xinhui.Pan@amd.com>,
"David Airlie" <airlied@linux.ie>,
"Daniel Vetter" <daniel@ffwll.ch>,
"Sumit Semwal" <sumit.semwal@linaro.org>,
"Felix Kuehling" <Felix.Kuehling@amd.com>,
"Nirmoy Das" <nirmoy.das@amd.com>,
"Jonathan Kim" <jonathan.kim@amd.com>,
"Philip Yang" <Philip.Yang@amd.com>,
"Matthew Auld" <matthew.auld@intel.com>,
"Zack Rusin" <zackr@vmware.com>,
amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
linaro-mm-sig@lists.linaro.org
Cc: Ira Weiny <ira.weiny@intel.com>
Subject: Re: [PATCH] drm/amd/amdgpu: Replace kmap() with kmap_local_page()
Date: Sun, 14 Aug 2022 19:14:31 +0200 [thread overview]
Message-ID: <ebb573b8-237f-602e-8d7d-9c49f0bd73be@gmail.com> (raw)
In-Reply-To: <20220812175753.22926-1-fmdefrancesco@gmail.com>
Am 12.08.22 um 19:57 schrieb Fabio M. De Francesco:
> 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 amdgpu/amdgpu_ttm.c is safe, it should be preferred.
>
> Therefore, replace kmap() with kmap_local_page() in amdgpu/amdgpu_ttm.c.
>
> Suggested-by: Ira Weiny <ira.weiny@intel.com>
> Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
For those two use cases that looks good to me. Feel free to add an
Acked-by: Christian König <christian.koenig@amd.com>
Regards,
Christian.
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> index 3b4c19412625..c11657b5915f 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> @@ -2301,9 +2301,9 @@ static ssize_t amdgpu_iomem_read(struct file *f, char __user *buf,
> if (p->mapping != adev->mman.bdev.dev_mapping)
> return -EPERM;
>
> - ptr = kmap(p);
> + ptr = kmap_local_page(p);
> r = copy_to_user(buf, ptr + off, bytes);
> - kunmap(p);
> + kunmap_local(ptr);
> if (r)
> return -EFAULT;
>
> @@ -2352,9 +2352,9 @@ static ssize_t amdgpu_iomem_write(struct file *f, const char __user *buf,
> if (p->mapping != adev->mman.bdev.dev_mapping)
> return -EPERM;
>
> - ptr = kmap(p);
> + ptr = kmap_local_page(p);
> r = copy_from_user(ptr + off, buf, bytes);
> - kunmap(p);
> + kunmap_local(ptr);
> if (r)
> return -EFAULT;
>
prev parent reply other threads:[~2022-08-14 17:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-12 17:57 [PATCH] drm/amd/amdgpu: Replace kmap() with kmap_local_page() Fabio M. De Francesco
2022-08-12 17:57 ` Fabio M. De Francesco
2022-08-14 17:14 ` Christian König [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=ebb573b8-237f-602e-8d7d-9c49f0bd73be@gmail.com \
--to=ckoenig.leichtzumerken@gmail.com \
--cc=Felix.Kuehling@amd.com \
--cc=Philip.Yang@amd.com \
--cc=Xinhui.Pan@amd.com \
--cc=airlied@linux.ie \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=fmdefrancesco@gmail.com \
--cc=ira.weiny@intel.com \
--cc=jonathan.kim@amd.com \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=matthew.auld@intel.com \
--cc=nirmoy.das@amd.com \
--cc=sumit.semwal@linaro.org \
--cc=zackr@vmware.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.