dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Felix Kuehling <felix.kuehling@gmail.com>
To: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Cc: Alex Sierra <alex.sierra@amd.com>
Subject: [PATCH 07/10] drm/amdkfd: skip migration for pages already in VRAM
Date: Thu, 27 May 2021 16:56:03 -0400	[thread overview]
Message-ID: <20210527205606.2660-7-Felix.Kuehling@amd.com> (raw)
In-Reply-To: <20210527205606.2660-1-Felix.Kuehling@amd.com>

From: Alex Sierra <alex.sierra@amd.com>

Migration skipped for pages that are already in VRAM
domain. These could be the result of previous partial
migrations to SYS RAM, and prefetch back to VRAM.
Ex. Coherent pages in VRAM that were not written/invalidated after
a copy-on-write.

Signed-off-by: Alex Sierra <alex.sierra@amd.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_migrate.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
index 6fd68528c425..8a3f21d76915 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
@@ -329,14 +329,15 @@ svm_migrate_copy_to_vram(struct amdgpu_device *adev, struct svm_range *prange,
 	for (i = j = 0; i < npages; i++) {
 		struct page *spage;
 
-		dst[i] = vram_addr + (j << PAGE_SHIFT);
-		migrate->dst[i] = svm_migrate_addr_to_pfn(adev, dst[i]);
-		svm_migrate_get_vram_page(prange, migrate->dst[i]);
-
-		migrate->dst[i] = migrate_pfn(migrate->dst[i]);
-		migrate->dst[i] |= MIGRATE_PFN_LOCKED;
-
-		if (migrate->src[i] & MIGRATE_PFN_VALID) {
+		spage = migrate_pfn_to_page(migrate->src[i]);
+		if (spage && !is_zone_device_page(spage)) {
+			dst[i] = vram_addr + (j << PAGE_SHIFT);
+			migrate->dst[i] = svm_migrate_addr_to_pfn(adev, dst[i]);
+			svm_migrate_get_vram_page(prange, migrate->dst[i]);
+			migrate->dst[i] = migrate_pfn(migrate->dst[i]);
+			migrate->dst[i] |= MIGRATE_PFN_LOCKED;
+		}
+		if (migrate->dst[i] & MIGRATE_PFN_VALID) {
 			spage = migrate_pfn_to_page(migrate->src[i]);
 			src[i] = dma_map_page(dev, spage, 0, PAGE_SIZE,
 					      DMA_TO_DEVICE);
-- 
2.31.1


  parent reply	other threads:[~2021-05-27 20:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-27 20:55 [PATCH 01/10] drm/amdkfd: device pgmap owner at the svm migrate init Felix Kuehling
2021-05-27 20:55 ` [PATCH 02/10] drm/amdkfd: add owner ref param to get hmm pages Felix Kuehling
2021-05-27 20:55 ` [PATCH 03/10] drm/amdkfd: set owner ref to svm range prefault Felix Kuehling
2021-05-27 20:56 ` [PATCH 04/10] drm/amdgpu: get owner ref in validate and map Felix Kuehling
2021-05-27 20:56 ` [PATCH 05/10] drm/amdkfd: classify and map mixed svm range pages in GPU Felix Kuehling
2021-05-27 20:56 ` [PATCH 06/10] drm/amdkfd: skip invalid pages during migrations Felix Kuehling
2021-05-27 20:56 ` Felix Kuehling [this message]
2021-05-27 20:56 ` [PATCH 08/10] drm/amdkfd: add invalid pages debug at vram migration Felix Kuehling
2021-05-27 20:56 ` [PATCH 09/10] drm/amdkfd: partially actual_loc removed Felix Kuehling
2021-05-27 20:56 ` [PATCH 10/10] drm/amdkfd: protect svm_bo ref in case prange has forked Felix Kuehling

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=20210527205606.2660-7-Felix.Kuehling@amd.com \
    --to=felix.kuehling@gmail.com \
    --cc=alex.sierra@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=dri-devel@lists.freedesktop.org \
    --subject='Re: [PATCH 07/10] drm/amdkfd: skip migration for pages already in VRAM' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).