From: Philip Yang <yangp@amd.com>
To: "Chen, Xiaogang" <Xiaogang.Chen@amd.com>,
"amd-gfx@lists.freedesktop.org" <amd-gfx@lists.freedesktop.org>
Subject: Re: [PATCH v4] drm/amdkfd: Use huge page size to check split svm range alignment
Date: Mon, 24 Nov 2025 13:45:09 -0500 [thread overview]
Message-ID: <32ce2b72-aa16-4202-9f99-92e3cd4408bc@amd.com> (raw)
In-Reply-To: <PH7PR12MB65616F59BBE5CB4A4DCD34A5E3D0A@PH7PR12MB6561.namprd12.prod.outlook.com>
On 2025-11-24 09:55, Chen, Xiaogang wrote:
> [AMD Official Use Only - AMD Internal Distribution Only]
>
> ping
>
> -----Original Message-----
> From: Xiaogang.Chen <xiaogang.chen@amd.com>
> Sent: Thursday, November 20, 2025 9:51 AM
> To: amd-gfx@lists.freedesktop.org
> Cc: Chen, Xiaogang <Xiaogang.Chen@amd.com>
> Subject: [PATCH v4] drm/amdkfd: Use huge page size to check split svm range alignment
>
> From: Xiaogang Chen <xiaogang.chen@amd.com>
>
> 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.
>
> Signed-off-by: Xiaogang Chen <xiaogang.chen@amd.com>
> ---
> drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 46 +++++++++++++++++++---------
> 1 file changed, 32 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> index 521c14c7a789..7fe9d569d416 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> @@ -1144,30 +1144,48 @@ static int
> svm_range_split_tail(struct svm_range *prange, uint64_t new_last,
> struct list_head *insert_list, struct list_head *remap_list) {
> + unsigned long last_align_down = ALIGN_DOWN(prange->last, 512);
> + unsigned long start_align = ALIGN(prange->start, 512);
> + bool huge_page_mapping = last_align_down > start_align;
> struct svm_range *tail = NULL;
> - int r = svm_range_split(prange, prange->start, new_last, &tail);
> + int r;
>
> - if (!r) {
> - list_add(&tail->list, insert_list);
> - if (!IS_ALIGNED(new_last + 1, 1UL << prange->granularity))
> - list_add(&tail->update_list, remap_list);
> - }
> - return r;
> + r = svm_range_split(prange, prange->start, new_last, &tail);
> +
> + if (r)
> + return r;
> +
> + list_add(&tail->list, insert_list);
> +
> + if (huge_page_mapping && tail->start > start_align &&
> + tail->start < last_align_down && (!IS_ALIGNED(tail->start, 512)))
> + list_add(&tail->update_list, remap_list);
> +
> + return 0;
> }
>
> static int
> svm_range_split_head(struct svm_range *prange, uint64_t new_start,
> struct list_head *insert_list, struct list_head *remap_list) {
> + unsigned long last_align_down = ALIGN_DOWN(prange->last, 512);
> + unsigned long start_align = ALIGN(prange->start, 512);
> + bool huge_page_mapping = last_align_down > start_align;
> struct svm_range *head = NULL;
> - int r = svm_range_split(prange, new_start, prange->last, &head);
> + int r;
>
> - if (!r) {
> - list_add(&head->list, insert_list);
> - if (!IS_ALIGNED(new_start, 1UL << prange->granularity))
> - list_add(&head->update_list, remap_list);
> - }
> - return r;
> + r = svm_range_split(prange, new_start, prange->last, &head);
> +
> + if (r)
> + return r;
> +
> + list_add(&head->list, insert_list);
> +
> + if (huge_page_mapping && head->last > start_align &&
> + head->last < last_align_down && (!IS_ALIGNED(head->last, 512)))
replace all head->last with head->last + 1 in the if condition, or use
new_start instead.
With this fixed, this patch is
Reviewed-by: Philip Yang <Philip.Yang@amd.com>
> + list_add(&head->update_list, remap_list);
> +
> + return 0;
> }
>
> static void
> --
> 2.34.1
>
prev parent reply other threads:[~2025-11-24 18:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-20 15:50 [PATCH v4] drm/amdkfd: Use huge page size to check split svm range alignment Xiaogang.Chen
2025-11-24 14:55 ` Chen, Xiaogang
2025-11-24 18:45 ` Philip Yang [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=32ce2b72-aa16-4202-9f99-92e3cd4408bc@amd.com \
--to=yangp@amd.com \
--cc=Xiaogang.Chen@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
/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