Skip to contentSkip to conversation

drm/amdkfd: AIP mGPUs best prefetch location for xnack on

PATCH Superseded Philip Yang 2 participants 6 messages Aug 2, 2021 – Aug 11, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdkfd: AIP mGPUs best prefetch location for xnack on

For xnack on, if range ACCESS or ACCESS_IN_PLACE (AIP) by single GPU, or range is ACCESS_IN_PLACE by mGPUs and all mGPUs connection on xgmi same hive, the best prefetch location is prefetch_loc GPU. Otherwise, the best prefetch location is always CPU because GPU can not map vram of other GPUs through small bar PCIe.

---
 drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 44 +++++++++++++++++-----------
 1 file changed, 27 insertions(+), 17 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +27 -17
index 69237d2ab2ad..6160c301f78b 100644
@@ -2754,22 +2754,29 @@ svm_range_add(struct kfd_process *p, uint64_t start, uint64_t size,
 	return 0;
 }
 
-/* svm_range_best_prefetch_location - decide the best prefetch location
+/**
+ * svm_range_best_prefetch_location - decide the best prefetch location
  * @prange: svm range structure
  *
  * For xnack off:
- * If range map to single GPU, the best acutal location is prefetch loc, which
+ * If range map to single GPU, the best prefetch location is prefetch_loc, which
  * can be CPU or GPU.
  *
- * If range map to multiple GPUs, only if mGPU connection on xgmi same hive,
- * the best actual location could be prefetch_loc GPU. If mGPU connection on
- * PCIe, the best actual location is always CPU, because GPU cannot access vram
- * of other GPUs, assuming PCIe small bar (large bar support is not upstream).
+ * If range is ACCESS or ACCESS_IN_PLACE by mGPUs, only if mGPU connection on
+ * xgmi same hive, the best prefetch location is prefetch_loc GPU. If mGPUs
+ * connection on PCIe, the best prefetch location is always CPU, because GPU
+ * cannot map vram of other GPUs, assuming PCIe small bar (large bar support is
+ * not upstream).
  *
  * For xnack on:
- * The best actual location is prefetch location. If mGPU connection on xgmi
- * same hive, range map to multiple GPUs. Otherwise, the range only map to
- * actual location GPU. Other GPU access vm fault will trigger migration.
+ * If range map to single GPU or is not ACCESS_IN_PLACE by mGPUs, the best
+ * prefetch location is prefetch_loc, other GPU access vm fault will trigger
+ * migration.
+ *
+ * If range is ACCESS_IN_PLACE by mGPUs, only if mGPU connection on xgmi same
+ * hive, the best prefetch location is prefetch_loc GPU. If mGPUs connection on
+ * PCIe, the best prefetch location is always CPU, because GPU cannot map vram
+ * of other GPUs.
  *
  * Context: Process context
  *
@@ -2787,14 +2794,13 @@ svm_range_best_prefetch_location(struct svm_range *prange)
 	struct kfd_process *p;
 	uint32_t gpuidx;
 
-	p = container_of(prange->svms, struct kfd_process, svms);
-
-	/* xnack on */
-	if (p->xnack_enabled)
+	if (!best_loc || best_loc == KFD_IOCTL_SVM_LOCATION_UNDEFINED)
 		goto out;
 
-	/* xnack off */
-	if (!best_loc || best_loc == KFD_IOCTL_SVM_LOCATION_UNDEFINED)
+	p = container_of(prange->svms, struct kfd_process, svms);
+
+	if (p->xnack_enabled &&
+	   bitmap_weight(prange->bitmap_aip, MAX_GPU_INSTANCE) <= 1)
 		goto out;
 
 	bo_adev = svm_range_get_adev_by_id(prange, best_loc);
@@ -2803,8 +2809,12 @@ svm_range_best_prefetch_location(struct svm_range *prange)
 		best_loc = 0;
 		goto out;
 	}
-	bitmap_or(bitmap, prange->bitmap_access, prange->bitmap_aip,
-		  MAX_GPU_INSTANCE);
+
+	if (p->xnack_enabled)
+		bitmap_copy(bitmap, prange->bitmap_aip, MAX_GPU_INSTANCE);
+	else
+		bitmap_or(bitmap, prange->bitmap_access, prange->bitmap_aip,
+			  MAX_GPU_INSTANCE);
 
 	for_each_set_bit(gpuidx, bitmap, MAX_GPU_INSTANCE) {
 		pdd = kfd_process_device_from_gpuidx(p, gpuidx);
Signature · 1 line
2.17.1
maintainer
#1 lore raw

Am 2021-08-02 um 12:28 p.m. schrieb Philip Yang:

Quoted 61 lines

For xnack on, if range ACCESS or ACCESS_IN_PLACE (AIP) by single GPU, or range is ACCESS_IN_PLACE by mGPUs and all mGPUs connection on xgmi same hive, the best prefetch location is prefetch_loc GPU. Otherwise, the best prefetch location is always CPU because GPU can not map vram of other GPUs through small bar PCIe.

---
 drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 44 +++++++++++++++++-----------
 1 file changed, 27 insertions(+), 17 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +16 -12
index 69237d2ab2ad..6160c301f78b 100644
@@ -2754,22 +2754,29 @@ svm_range_add(struct kfd_process *p, uint64_t start, uint64_t size,
 	return 0;
 }
 
-/* svm_range_best_prefetch_location - decide the best prefetch location
+/**
+ * svm_range_best_prefetch_location - decide the best prefetch location
  * @prange: svm range structure
  *
  * For xnack off:
- * If range map to single GPU, the best acutal location is prefetch loc, which
+ * If range map to single GPU, the best prefetch location is prefetch_loc, which
  * can be CPU or GPU.
  *
- * If range map to multiple GPUs, only if mGPU connection on xgmi same hive,
- * the best actual location could be prefetch_loc GPU. If mGPU connection on
- * PCIe, the best actual location is always CPU, because GPU cannot access vram
- * of other GPUs, assuming PCIe small bar (large bar support is not upstream).
+ * If range is ACCESS or ACCESS_IN_PLACE by mGPUs, only if mGPU connection on
+ * xgmi same hive, the best prefetch location is prefetch_loc GPU. If mGPUs
+ * connection on PCIe, the best prefetch location is always CPU, because GPU
+ * cannot map vram of other GPUs, assuming PCIe small bar (large bar support is
+ * not upstream).
  *
  * For xnack on:
- * The best actual location is prefetch location. If mGPU connection on xgmi
- * same hive, range map to multiple GPUs. Otherwise, the range only map to
- * actual location GPU. Other GPU access vm fault will trigger migration.
+ * If range map to single GPU or is not ACCESS_IN_PLACE by mGPUs, the best
+ * prefetch location is prefetch_loc, other GPU access vm fault will trigger
+ * migration.
+ *
+ * If range is ACCESS_IN_PLACE by mGPUs, only if mGPU connection on xgmi same
+ * hive, the best prefetch location is prefetch_loc GPU. If mGPUs connection on
+ * PCIe, the best prefetch location is always CPU, because GPU cannot map vram
+ * of other GPUs.
  *
  * Context: Process context
  *
@@ -2787,14 +2794,13 @@ svm_range_best_prefetch_location(struct svm_range *prange)
 	struct kfd_process *p;
 	uint32_t gpuidx;
 
-	p = container_of(prange->svms, struct kfd_process, svms);
-
-	/* xnack on */

drivers/gpu/drm/amd/amdkfd/kfd_svm.c svm_range_best_prefetch_location(struct svm_range *prange) · line 2803

Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +5 -3
-	if (p->xnack_enabled)
+	if (!best_loc || best_loc == KFD_IOCTL_SVM_LOCATION_UNDEFINED)
 		goto out;
 
-	/* xnack off */
-	if (!best_loc || best_loc == KFD_IOCTL_SVM_LOCATION_UNDEFINED)
+	p = container_of(prange->svms, struct kfd_process, svms);
+
+	if (p->xnack_enabled &&
+	   bitmap_weight(prange->bitmap_aip, MAX_GPU_INSTANCE) <= 1)

I'm not sure why this condition is needed. I think there is an implicit assumption that the prefetch_location is the one GPU that's set in the bitmap_aip. But is that really a safe assumption? If you're prefetching to a different GPU than the one that needs to access the memory in-place, then the access is still going to trigger a page fault, so it's not "in-place".

I think you can just drop this condition. It's a questionable short-cut for something that's handled more correctly in the loop below.

Regards,
  Felix

Quoted 18 lines
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +6 -2
 		goto out;
 
 	bo_adev = svm_range_get_adev_by_id(prange, best_loc);
@@ -2803,8 +2809,12 @@ svm_range_best_prefetch_location(struct svm_range *prange)
 		best_loc = 0;
 		goto out;
 	}
-	bitmap_or(bitmap, prange->bitmap_access, prange->bitmap_aip,
-		  MAX_GPU_INSTANCE);
+
+	if (p->xnack_enabled)
+		bitmap_copy(bitmap, prange->bitmap_aip, MAX_GPU_INSTANCE);
+	else
+		bitmap_or(bitmap, prange->bitmap_access, prange->bitmap_aip,
+			  MAX_GPU_INSTANCE);
 
 	for_each_set_bit(gpuidx, bitmap, MAX_GPU_INSTANCE) {
 		pdd = kfd_process_device_from_gpuidx(p, gpuidx);
#2 lore raw

PATCH v2 1/1 drm/amdkfd: AIP mGPUs best prefetch location for xnack on

In reply to Philip Yang

For xnack on, if range ACCESS or ACCESS_IN_PLACE (AIP) by single GPU, or range is ACCESS_IN_PLACE by mGPUs and all mGPUs connection on xgmi same hive, the best prefetch location is prefetch_loc GPU. Otherwise, the best prefetch location is always CPU because GPU can not map vram of other GPUs through small bar PCIe.

---
 drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 35 +++++++++++++++-------------
 1 file changed, 19 insertions(+), 16 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +19 -16
index f811a3a24cd2..5bd51a15fb00 100644
@@ -2719,22 +2719,26 @@ svm_range_add(struct kfd_process *p, uint64_t start, uint64_t size,
 	return 0;
 }
 
-/* svm_range_best_prefetch_location - decide the best prefetch location
+/**
+ * svm_range_best_prefetch_location - decide the best prefetch location
  * @prange: svm range structure
  *
  * For xnack off:
- * If range map to single GPU, the best acutal location is prefetch loc, which
+ * If range map to single GPU, the best prefetch location is prefetch_loc, which
  * can be CPU or GPU.
  *
- * If range map to multiple GPUs, only if mGPU connection on xgmi same hive,
- * the best actual location could be prefetch_loc GPU. If mGPU connection on
- * PCIe, the best actual location is always CPU, because GPU cannot access vram
- * of other GPUs, assuming PCIe small bar (large bar support is not upstream).
+ * If range is ACCESS or ACCESS_IN_PLACE by mGPUs, only if mGPU connection on
+ * XGMI same hive, the best prefetch location is prefetch_loc GPU, othervise
+ * the best prefetch location is always CPU, because GPU can not map vram of
+ * other GPUs, assuming PCIe small bar (large bar support is not upstream).
  *
  * For xnack on:
- * The best actual location is prefetch location. If mGPU connection on xgmi
- * same hive, range map to multiple GPUs. Otherwise, the range only map to
- * actual location GPU. Other GPU access vm fault will trigger migration.
+ * If range is not ACCESS_IN_PLACE by mGPUs, the best prefetch location is
+ * prefetch_loc, other GPU access will generate vm fault and trigger migration.
+ *
+ * If range is ACCESS_IN_PLACE by mGPUs, only if mGPU connection on XGMI same
+ * hive, the best prefetch location is prefetch_loc GPU, otherwise the best
+ * prefetch location is always CPU, because GPU cannot map vram of other GPUs.
  *
  * Context: Process context
  *
@@ -2754,11 +2758,6 @@ svm_range_best_prefetch_location(struct svm_range *prange)
 
 	p = container_of(prange->svms, struct kfd_process, svms);
 
-	/* xnack on */
-	if (p->xnack_enabled)
-		goto out;
-
-	/* xnack off */
 	if (!best_loc || best_loc == KFD_IOCTL_SVM_LOCATION_UNDEFINED)
 		goto out;
 
@@ -2768,8 +2767,12 @@ svm_range_best_prefetch_location(struct svm_range *prange)
 		best_loc = 0;
 		goto out;
 	}
-	bitmap_or(bitmap, prange->bitmap_access, prange->bitmap_aip,
-		  MAX_GPU_INSTANCE);
+
+	if (p->xnack_enabled)
+		bitmap_copy(bitmap, prange->bitmap_aip, MAX_GPU_INSTANCE);
+	else
+		bitmap_or(bitmap, prange->bitmap_access, prange->bitmap_aip,
+			  MAX_GPU_INSTANCE);
 
 	for_each_set_bit(gpuidx, bitmap, MAX_GPU_INSTANCE) {
 		pdd = kfd_process_device_from_gpuidx(p, gpuidx);
Signature · 1 line
2.17.1
maintainer Reviewed-by on v2 1/1
#3 lore raw

Am 2021-08-09 um 6:21 p.m. schrieb Philip Yang:

Quoted 5 lines

For xnack on, if range ACCESS or ACCESS_IN_PLACE (AIP) by single GPU, or range is ACCESS_IN_PLACE by mGPUs and all mGPUs connection on xgmi same hive, the best prefetch location is prefetch_loc GPU. Otherwise, the best prefetch location is always CPU because GPU can not map vram of other GPUs through small bar PCIe.

I don't think small-bar is really a factor here. Even with large-BAR, our P2P mappings are not coherent like XGMI mappings are. So we wouldn't be able to use P2P even on large-BAR systems. So I would modify this sentence:

Quoted 27 lines

Otherwise, the best
prefetch location is always CPU because GPU can not coherently map vram of other GPUs through PCIe.

---
 drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 35 +++++++++++++++-------------
 1 file changed, 19 insertions(+), 16 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +3 -2
index f811a3a24cd2..5bd51a15fb00 100644
@@ -2719,22 +2719,26 @@ svm_range_add(struct kfd_process *p, uint64_t start, uint64_t size,
 	return 0;
 }
 
-/* svm_range_best_prefetch_location - decide the best prefetch location
+/**
+ * svm_range_best_prefetch_location - decide the best prefetch location
  * @prange: svm range structure
  *
  * For xnack off:
- * If range map to single GPU, the best acutal location is prefetch loc, which
+ * If range map to single GPU, the best prefetch location is prefetch_loc, which

drivers/gpu/drm/amd/amdkfd/kfd_svm.c svm_range_add(struct kfd_process *p, uint64_t start, uint64_t size, · line 2733

Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +4 -4
  * can be CPU or GPU.
  *
- * If range map to multiple GPUs, only if mGPU connection on xgmi same hive,
- * the best actual location could be prefetch_loc GPU. If mGPU connection on
- * PCIe, the best actual location is always CPU, because GPU cannot access vram
- * of other GPUs, assuming PCIe small bar (large bar support is not upstream).
+ * If range is ACCESS or ACCESS_IN_PLACE by mGPUs, only if mGPU connection on
+ * XGMI same hive, the best prefetch location is prefetch_loc GPU, othervise
+ * the best prefetch location is always CPU, because GPU can not map vram of
+ * other GPUs, assuming PCIe small bar (large bar support is not upstream).

Same as above. With that fixed, the patch is

Quoted 41 lines
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +12 -10
  *
  * For xnack on:
- * The best actual location is prefetch location. If mGPU connection on xgmi
- * same hive, range map to multiple GPUs. Otherwise, the range only map to
- * actual location GPU. Other GPU access vm fault will trigger migration.
+ * If range is not ACCESS_IN_PLACE by mGPUs, the best prefetch location is
+ * prefetch_loc, other GPU access will generate vm fault and trigger migration.
+ *
+ * If range is ACCESS_IN_PLACE by mGPUs, only if mGPU connection on XGMI same
+ * hive, the best prefetch location is prefetch_loc GPU, otherwise the best
+ * prefetch location is always CPU, because GPU cannot map vram of other GPUs.
  *
  * Context: Process context
  *
@@ -2754,11 +2758,6 @@ svm_range_best_prefetch_location(struct svm_range *prange)
 
 	p = container_of(prange->svms, struct kfd_process, svms);
 
-	/* xnack on */
-	if (p->xnack_enabled)
-		goto out;
-
-	/* xnack off */
 	if (!best_loc || best_loc == KFD_IOCTL_SVM_LOCATION_UNDEFINED)
 		goto out;
 
@@ -2768,8 +2767,12 @@ svm_range_best_prefetch_location(struct svm_range *prange)
 		best_loc = 0;
 		goto out;
 	}
-	bitmap_or(bitmap, prange->bitmap_access, prange->bitmap_aip,
-		  MAX_GPU_INSTANCE);
+
+	if (p->xnack_enabled)
+		bitmap_copy(bitmap, prange->bitmap_aip, MAX_GPU_INSTANCE);
+	else
+		bitmap_or(bitmap, prange->bitmap_access, prange->bitmap_aip,
+			  MAX_GPU_INSTANCE);
 
 	for_each_set_bit(gpuidx, bitmap, MAX_GPU_INSTANCE) {
 		pdd = kfd_process_device_from_gpuidx(p, gpuidx);
#4 lore raw

PATCH v3 1/1 drm/amdkfd: AIP mGPUs best prefetch location for xnack on

In reply to Philip Yang

For xnack on, if range ACCESS or ACCESS_IN_PLACE (AIP) by single GPU, or range is ACCESS_IN_PLACE by mGPUs and all mGPUs connection on XGMI same hive, the best prefetch location is prefetch_loc GPU. Otherwise, the best prefetch location is always CPU because GPU does not have coherent mapping VRAM of other GPUs even with large-BAR PCIe connection.

---
 drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 35 +++++++++++++++-------------
 1 file changed, 19 insertions(+), 16 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +19 -16
index f811a3a24cd2..4cdca8604d69 100644
@@ -2719,22 +2719,26 @@ svm_range_add(struct kfd_process *p, uint64_t start, uint64_t size,
 	return 0;
 }
 
-/* svm_range_best_prefetch_location - decide the best prefetch location
+/**
+ * svm_range_best_prefetch_location - decide the best prefetch location
  * @prange: svm range structure
  *
  * For xnack off:
- * If range map to single GPU, the best acutal location is prefetch loc, which
+ * If range map to single GPU, the best prefetch location is prefetch_loc, which
  * can be CPU or GPU.
  *
- * If range map to multiple GPUs, only if mGPU connection on xgmi same hive,
- * the best actual location could be prefetch_loc GPU. If mGPU connection on
- * PCIe, the best actual location is always CPU, because GPU cannot access vram
- * of other GPUs, assuming PCIe small bar (large bar support is not upstream).
+ * If range is ACCESS or ACCESS_IN_PLACE by mGPUs, only if mGPU connection on
+ * XGMI same hive, the best prefetch location is prefetch_loc GPU, othervise
+ * the best prefetch location is always CPU, because GPU can not have coherent
+ * mapping VRAM of other GPUs even with large-BAR PCIe connection.
  *
  * For xnack on:
- * The best actual location is prefetch location. If mGPU connection on xgmi
- * same hive, range map to multiple GPUs. Otherwise, the range only map to
- * actual location GPU. Other GPU access vm fault will trigger migration.
+ * If range is not ACCESS_IN_PLACE by mGPUs, the best prefetch location is
+ * prefetch_loc, other GPU access will generate vm fault and trigger migration.
+ *
+ * If range is ACCESS_IN_PLACE by mGPUs, only if mGPU connection on XGMI same
+ * hive, the best prefetch location is prefetch_loc GPU, otherwise the best
+ * prefetch location is always CPU.
  *
  * Context: Process context
  *
@@ -2754,11 +2758,6 @@ svm_range_best_prefetch_location(struct svm_range *prange)
 
 	p = container_of(prange->svms, struct kfd_process, svms);
 
-	/* xnack on */
-	if (p->xnack_enabled)
-		goto out;
-
-	/* xnack off */
 	if (!best_loc || best_loc == KFD_IOCTL_SVM_LOCATION_UNDEFINED)
 		goto out;
 
@@ -2768,8 +2767,12 @@ svm_range_best_prefetch_location(struct svm_range *prange)
 		best_loc = 0;
 		goto out;
 	}
-	bitmap_or(bitmap, prange->bitmap_access, prange->bitmap_aip,
-		  MAX_GPU_INSTANCE);
+
+	if (p->xnack_enabled)
+		bitmap_copy(bitmap, prange->bitmap_aip, MAX_GPU_INSTANCE);
+	else
+		bitmap_or(bitmap, prange->bitmap_access, prange->bitmap_aip,
+			  MAX_GPU_INSTANCE);
 
 	for_each_set_bit(gpuidx, bitmap, MAX_GPU_INSTANCE) {
 		pdd = kfd_process_device_from_gpuidx(p, gpuidx);
Signature · 1 line
2.17.1
maintainer Reviewed-by on v3 1/1
#5 lore raw

Am 2021-08-11 um 10:35 a.m. schrieb Philip Yang:

Quoted 7 lines

For xnack on, if range ACCESS or ACCESS_IN_PLACE (AIP) by single GPU, or range is ACCESS_IN_PLACE by mGPUs and all mGPUs connection on XGMI same hive, the best prefetch location is prefetch_loc GPU. Otherwise, the best prefetch location is always CPU because GPU does not have coherent mapping VRAM of other GPUs even with large-BAR PCIe connection.

Quoted 71 lines
---
 drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 35 +++++++++++++++-------------
 1 file changed, 19 insertions(+), 16 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +19 -16
index f811a3a24cd2..4cdca8604d69 100644
@@ -2719,22 +2719,26 @@ svm_range_add(struct kfd_process *p, uint64_t start, uint64_t size,
 	return 0;
 }
 
-/* svm_range_best_prefetch_location - decide the best prefetch location
+/**
+ * svm_range_best_prefetch_location - decide the best prefetch location
  * @prange: svm range structure
  *
  * For xnack off:
- * If range map to single GPU, the best acutal location is prefetch loc, which
+ * If range map to single GPU, the best prefetch location is prefetch_loc, which
  * can be CPU or GPU.
  *
- * If range map to multiple GPUs, only if mGPU connection on xgmi same hive,
- * the best actual location could be prefetch_loc GPU. If mGPU connection on
- * PCIe, the best actual location is always CPU, because GPU cannot access vram
- * of other GPUs, assuming PCIe small bar (large bar support is not upstream).
+ * If range is ACCESS or ACCESS_IN_PLACE by mGPUs, only if mGPU connection on
+ * XGMI same hive, the best prefetch location is prefetch_loc GPU, othervise
+ * the best prefetch location is always CPU, because GPU can not have coherent
+ * mapping VRAM of other GPUs even with large-BAR PCIe connection.
  *
  * For xnack on:
- * The best actual location is prefetch location. If mGPU connection on xgmi
- * same hive, range map to multiple GPUs. Otherwise, the range only map to
- * actual location GPU. Other GPU access vm fault will trigger migration.
+ * If range is not ACCESS_IN_PLACE by mGPUs, the best prefetch location is
+ * prefetch_loc, other GPU access will generate vm fault and trigger migration.
+ *
+ * If range is ACCESS_IN_PLACE by mGPUs, only if mGPU connection on XGMI same
+ * hive, the best prefetch location is prefetch_loc GPU, otherwise the best
+ * prefetch location is always CPU.
  *
  * Context: Process context
  *
@@ -2754,11 +2758,6 @@ svm_range_best_prefetch_location(struct svm_range *prange)
 
 	p = container_of(prange->svms, struct kfd_process, svms);
 
-	/* xnack on */
-	if (p->xnack_enabled)
-		goto out;
-
-	/* xnack off */
 	if (!best_loc || best_loc == KFD_IOCTL_SVM_LOCATION_UNDEFINED)
 		goto out;
 
@@ -2768,8 +2767,12 @@ svm_range_best_prefetch_location(struct svm_range *prange)
 		best_loc = 0;
 		goto out;
 	}
-	bitmap_or(bitmap, prange->bitmap_access, prange->bitmap_aip,
-		  MAX_GPU_INSTANCE);
+
+	if (p->xnack_enabled)
+		bitmap_copy(bitmap, prange->bitmap_aip, MAX_GPU_INSTANCE);
+	else
+		bitmap_or(bitmap, prange->bitmap_access, prange->bitmap_aip,
+			  MAX_GPU_INSTANCE);
 
 	for_each_set_bit(gpuidx, bitmap, MAX_GPU_INSTANCE) {
 		pdd = kfd_process_device_from_gpuidx(p, gpuidx);