Skip to contentSkip to conversation

drm/amdkfd: Use huge page size to check split svm range alignment

PATCH Superseded Xiaogang.Chen 2 participants 3 messages Nov 10, 2025 – Nov 11, 2025

Subsystems (3)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdkfd: Use huge page size to check split svm range alignment

From: Xiaogang Chen <[email protected]>

Fixes 7ef6b2d4b7e5 (drm/amdkfd: remap unaligned svm ranges that have split)

When split svm ranges that have been mapped using huge page should use huge page size(2MB) to check split range alignment, not prange->granularity that means migration granularity.

---
 drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +2 -2
index 521c14c7a789..3af85c232659 100644
@@ -1149,7 +1149,7 @@ svm_range_split_tail(struct svm_range *prange, uint64_t new_last,
 
 	if (!r) {
 		list_add(&tail->list, insert_list);
-		if (!IS_ALIGNED(new_last + 1, 1UL << prange->granularity))
+		if (!IS_ALIGNED(new_last + 1, 512))
 			list_add(&tail->update_list, remap_list);
 	}
 	return r;
@@ -1164,7 +1164,7 @@ svm_range_split_head(struct svm_range *prange, uint64_t new_start,
 
 	if (!r) {
 		list_add(&head->list, insert_list);
-		if (!IS_ALIGNED(new_start, 1UL << prange->granularity))
+		if (!IS_ALIGNED(new_start, 512))
 			list_add(&head->update_list, remap_list);
 	}
 	return r;
Signature · 1 line
2.34.1
#1 lore raw
Quoted 18 lines · Xiaogang.Chen

From: Xiaogang Chen <[email protected]>

Fixes 7ef6b2d4b7e5 (drm/amdkfd: remap unaligned svm ranges that have split)

When split svm ranges that have been mapped using huge page should use huge page size(2MB) to check split range alignment, not prange->granularity that means migration granularity.

---
  drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +0 -0
index 521c14c7a789..3af85c232659 100644

drivers/gpu/drm/amd/amdkfd/kfd_svm.c svm_range_split_tail(struct svm_range *prange, uint64_t new_last, · line 1152

Quoted 5 lines
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +1 -1
@@ -1149,7 +1149,7 @@ svm_range_split_tail(struct svm_range *prange, uint64_t new_last,
 
  	if (!r) {
  		list_add(&tail->list, insert_list);
-		if (!IS_ALIGNED(new_last + 1, 1UL << prange->granularity))
+		if (!IS_ALIGNED(new_last + 1, 512))

we should check the original prange size is larger than 512 pages
          if (!IS_ALIGNED(new_last + 1, 512) && tail->last - prange->start >= 512)

drivers/gpu/drm/amd/amdkfd/kfd_svm.c svm_range_split_head(struct svm_range *prange, uint64_t new_start, · line 1167

Quoted 9 lines
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +1 -1
  			list_add(&tail->update_list, remap_list);
  	}
  	return r;
@@ -1164,7 +1164,7 @@ svm_range_split_head(struct svm_range *prange, uint64_t new_start,
 
  	if (!r) {
  		list_add(&head->list, insert_list);
-		if (!IS_ALIGNED(new_start, 1UL << prange->granularity))
+		if (!IS_ALIGNED(new_start, 512))

if (!IS_ALIGNED(new_start, 512) && prange->last - head->start >= 512)

Regards,

Philip

Quoted 3 lines
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +0 -0
  			list_add(&head->update_list, remap_list);
  	}
  	return r;
#2 lore raw
Quoted 15 lines · Philip Yang
Quoted 13 lines · Xiaogang.Chen

From: Xiaogang Chen <[email protected]>

Fixes 7ef6b2d4b7e5 (drm/amdkfd: remap unaligned svm ranges that have split)

When split svm ranges that have been mapped using huge page should use huge page size(2MB) to check split range alignment, not prange->granularity that means migration granularity.

---
  drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 4 ++--

  1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 12 lines

drivers/gpu/drm/amd/amdkfd/kfd_svm.c svm_range_split_tail(struct svm_range *prange, · line 1152

Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +1 -1
index 521c14c7a789..3af85c232659 100644
@@ -1149,7 +1149,7 @@ svm_range_split_tail(struct svm_range *prange, 
 uint64_t new_last,
         if (!r) {
           list_add(&tail->list, insert_list);
-        if (!IS_ALIGNED(new_last + 1, 1UL << prange->granularity))
+        if (!IS_ALIGNED(new_last + 1, 512))

we should check the original prange size is larger than 512 pages
          if (!IS_ALIGNED(new_last + 1, 512) && tail->last - prange->start >= 512)

ok, but should be following one?

  if (!IS_ALIGNED(tail->start, 512) || (tail->last - tail->start + 1)  <  512)

Quoted 11 lines

drivers/gpu/drm/amd/amdkfd/kfd_svm.c svm_range_split_head(struct svm_range *prange, · line 1167

Quoted 9 lines
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +1 -1
 list_add(&tail->update_list, remap_list);
       }
       return r;
@@ -1164,7 +1164,7 @@ svm_range_split_head(struct svm_range *prange, 
 uint64_t new_start,
         if (!r) {
           list_add(&head->list, insert_list);
-        if (!IS_ALIGNED(new_start, 1UL << prange->granularity))
+        if (!IS_ALIGNED(new_start, 512))

if (!IS_ALIGNED(new_start, 512) && prange->last - head->start >= 512)

same for head case, should use this?

if (!IS_ALIGNED( head->start , 512) || ( head->last - head->start + 1)  < 512)

Regards

Xiaogang

Quoted 7 lines

Regards,

Philip

Quoted 3 lines
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +0 -0
 list_add(&head->update_list, remap_list);
       }
       return r;