Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: drop retry loop in amdgpu_hmm_range_get_pages
@ 2026-06-16 13:05 Alex Deucher
  2026-06-16 13:20 ` Greg KH
  2026-06-16 13:20 ` Greg KH
  0 siblings, 2 replies; 5+ messages in thread
From: Alex Deucher @ 2026-06-16 13:05 UTC (permalink / raw)
  To: stable, christian.koenig, gregkh; +Cc: Honglei Huang, Alex Deucher

From: Honglei Huang <honghuan@amd.com>

Since commit c08972f55594 ("drm/amdgpu: fix amdgpu_hmm_range_get_pages")
moved mmu_interval_read_begin() out of the per-chunk loop, the
captured notifier_seq is no longer refreshed across retries. As a
result, the existing -EBUSY retry path can never make progress:

  hmm_range_fault() returns -EBUSY only when
  mmu_interval_check_retry(notifier, notifier_seq) reports that the
  sequence is stale. Once the sequence has advanced, the stored seq
  will never match again, so every subsequent call within the same
  invocation returns -EBUSY immediately.

The "goto retry" therefore degenerates into a busy spin that simply
burns CPU for the full HMM_RANGE_DEFAULT_TIMEOUT (~1s) window before
finally bailing out with -EAGAIN. This is pure latency with no chance
of recovery, and it actively hurts the KFD userptr stack: the caller
ends up blocked for a second while holding mmap_lock, only to return
-EAGAIN to the restore worker (or to userspace) which would have
re-driven the operation immediately anyway.

Drop the retry/timeout entirely and let -EBUSY propagate straight to
out_free_pfns, where it is already translated to -EAGAIN. Recovery is
handled at a higher level: the KFD restore_userptr_worker reschedules
itself, and the userptr ioctl path returns -EAGAIN to userspace.

No functional regression: the previous behaviour on -EBUSY was already
to fail with -EAGAIN after a 1s stall; we just skip the stall.

Fixes: c08972f55594 ("drm/amdgpu: fix amdgpu_hmm_range_get_pages")
Closes: https://gitlab.freedesktop.org/drm/amd/-/work_items/5393
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Honglei Huang <honghuan@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 342981fff32802a819d6fc7cf3c9fedf9f3d9d60)
Cc: stable@vger.kernel.org
---

This patch is from drm-next and fixes a regression in a patch that
went to stable.

 drivers/gpu/drm/amd/amdgpu/amdgpu_hmm.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_hmm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_hmm.c
index e452444b33b0..99bc9ad67d5b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_hmm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_hmm.c
@@ -174,7 +174,6 @@ int amdgpu_hmm_range_get_pages(struct mmu_interval_notifier *notifier,
 	const u64 max_bytes = SZ_2G;
 
 	struct hmm_range *hmm_range = &range->hmm_range;
-	unsigned long timeout;
 	unsigned long *pfns;
 	unsigned long end;
 	int r;
@@ -201,15 +200,9 @@ int amdgpu_hmm_range_get_pages(struct mmu_interval_notifier *notifier,
 		pr_debug("hmm range: start = 0x%lx, end = 0x%lx",
 			hmm_range->start, hmm_range->end);
 
-		timeout = jiffies + msecs_to_jiffies(HMM_RANGE_DEFAULT_TIMEOUT);
-
-retry:
 		r = hmm_range_fault(hmm_range);
-		if (unlikely(r)) {
-			if (r == -EBUSY && !time_after(jiffies, timeout))
-				goto retry;
+		if (unlikely(r))
 			goto out_free_pfns;
-		}
 
 		if (hmm_range->end == end)
 			break;
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] drm/amdgpu: drop retry loop in amdgpu_hmm_range_get_pages
  2026-06-16 13:05 [PATCH] drm/amdgpu: drop retry loop in amdgpu_hmm_range_get_pages Alex Deucher
@ 2026-06-16 13:20 ` Greg KH
  2026-06-18 22:30   ` Deucher, Alexander
  2026-06-16 13:20 ` Greg KH
  1 sibling, 1 reply; 5+ messages in thread
From: Greg KH @ 2026-06-16 13:20 UTC (permalink / raw)
  To: Alex Deucher; +Cc: stable, christian.koenig, Honglei Huang

On Tue, Jun 16, 2026 at 09:05:31AM -0400, Alex Deucher wrote:
> From: Honglei Huang <honghuan@amd.com>
> 
> Since commit c08972f55594 ("drm/amdgpu: fix amdgpu_hmm_range_get_pages")
> moved mmu_interval_read_begin() out of the per-chunk loop, the
> captured notifier_seq is no longer refreshed across retries. As a
> result, the existing -EBUSY retry path can never make progress:
> 
>   hmm_range_fault() returns -EBUSY only when
>   mmu_interval_check_retry(notifier, notifier_seq) reports that the
>   sequence is stale. Once the sequence has advanced, the stored seq
>   will never match again, so every subsequent call within the same
>   invocation returns -EBUSY immediately.
> 
> The "goto retry" therefore degenerates into a busy spin that simply
> burns CPU for the full HMM_RANGE_DEFAULT_TIMEOUT (~1s) window before
> finally bailing out with -EAGAIN. This is pure latency with no chance
> of recovery, and it actively hurts the KFD userptr stack: the caller
> ends up blocked for a second while holding mmap_lock, only to return
> -EAGAIN to the restore worker (or to userspace) which would have
> re-driven the operation immediately anyway.
> 
> Drop the retry/timeout entirely and let -EBUSY propagate straight to
> out_free_pfns, where it is already translated to -EAGAIN. Recovery is
> handled at a higher level: the KFD restore_userptr_worker reschedules
> itself, and the userptr ioctl path returns -EAGAIN to userspace.
> 
> No functional regression: the previous behaviour on -EBUSY was already
> to fail with -EAGAIN after a 1s stall; we just skip the stall.
> 
> Fixes: c08972f55594 ("drm/amdgpu: fix amdgpu_hmm_range_get_pages")
> Closes: https://gitlab.freedesktop.org/drm/amd/-/work_items/5393
> Reviewed-by: Christian König <christian.koenig@amd.com>
> Signed-off-by: Honglei Huang <honghuan@amd.com>
> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
> (cherry picked from commit 342981fff32802a819d6fc7cf3c9fedf9f3d9d60)
> Cc: stable@vger.kernel.org
> ---
> 
> This patch is from drm-next and fixes a regression in a patch that
> went to stable.

But this commit isn't in Linus's tree yet so we can't take it, right?

confused,

greg k-h

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] drm/amdgpu: drop retry loop in amdgpu_hmm_range_get_pages
  2026-06-16 13:05 [PATCH] drm/amdgpu: drop retry loop in amdgpu_hmm_range_get_pages Alex Deucher
  2026-06-16 13:20 ` Greg KH
@ 2026-06-16 13:20 ` Greg KH
  2026-06-18  9:08   ` Thorsten Leemhuis
  1 sibling, 1 reply; 5+ messages in thread
From: Greg KH @ 2026-06-16 13:20 UTC (permalink / raw)
  To: Alex Deucher; +Cc: stable, christian.koenig, Honglei Huang

On Tue, Jun 16, 2026 at 09:05:31AM -0400, Alex Deucher wrote:
> From: Honglei Huang <honghuan@amd.com>
> 
> Since commit c08972f55594 ("drm/amdgpu: fix amdgpu_hmm_range_get_pages")
> moved mmu_interval_read_begin() out of the per-chunk loop, the
> captured notifier_seq is no longer refreshed across retries. As a
> result, the existing -EBUSY retry path can never make progress:
> 
>   hmm_range_fault() returns -EBUSY only when
>   mmu_interval_check_retry(notifier, notifier_seq) reports that the
>   sequence is stale. Once the sequence has advanced, the stored seq
>   will never match again, so every subsequent call within the same
>   invocation returns -EBUSY immediately.
> 
> The "goto retry" therefore degenerates into a busy spin that simply
> burns CPU for the full HMM_RANGE_DEFAULT_TIMEOUT (~1s) window before
> finally bailing out with -EAGAIN. This is pure latency with no chance
> of recovery, and it actively hurts the KFD userptr stack: the caller
> ends up blocked for a second while holding mmap_lock, only to return
> -EAGAIN to the restore worker (or to userspace) which would have
> re-driven the operation immediately anyway.
> 
> Drop the retry/timeout entirely and let -EBUSY propagate straight to
> out_free_pfns, where it is already translated to -EAGAIN. Recovery is
> handled at a higher level: the KFD restore_userptr_worker reschedules
> itself, and the userptr ioctl path returns -EAGAIN to userspace.
> 
> No functional regression: the previous behaviour on -EBUSY was already
> to fail with -EAGAIN after a 1s stall; we just skip the stall.
> 
> Fixes: c08972f55594 ("drm/amdgpu: fix amdgpu_hmm_range_get_pages")

This commit is not anywhere...


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] drm/amdgpu: drop retry loop in amdgpu_hmm_range_get_pages
  2026-06-16 13:20 ` Greg KH
@ 2026-06-18  9:08   ` Thorsten Leemhuis
  0 siblings, 0 replies; 5+ messages in thread
From: Thorsten Leemhuis @ 2026-06-18  9:08 UTC (permalink / raw)
  To: Greg KH, Alex Deucher
  Cc: stable, christian.koenig, Honglei Huang,
	Linux kernel regressions list

On 6/16/26 15:20, Greg KH wrote:
> On Tue, Jun 16, 2026 at 09:05:31AM -0400, Alex Deucher wrote:
>> From: Honglei Huang <honghuan@amd.com>

FWIW, that change in between landed in mainline as 342981fff32802
("drm/amdgpu: drop retry loop in amdgpu_hmm_range_get_pages"), so might
be a good idea to add this while applying:

commit 342981fff32802a819d6fc7cf3c9fedf9f3d9d60 upstream.

>> Since commit c08972f55594 ("drm/amdgpu: fix amdgpu_hmm_range_get_pages")
>> moved mmu_interval_read_begin() out of the per-chunk loop, the
>> captured notifier_seq is no longer refreshed across retries. As a
>> result, the existing -EBUSY retry path can never make progress:
>> [...]
>> No functional regression: the previous behaviour on -EBUSY was already
>> to fail with -EAGAIN after a 1s stall; we just skip the stall.>>
>> Fixes: c08972f55594 ("drm/amdgpu: fix amdgpu_hmm_range_get_pages")
> 
> This commit is not anywhere...

This is 962d684b5dc074 ("drm/amdgpu: fix amdgpu_hmm_range_get_pages")
[v7.1-rc6, v7.0.12], which recently landed in mainline a second time as
c08972f555945c.

Hope this gets things rolling (I just stumbled on a second report about
a regression which should be fixed by this, which is why I thought it
might be worth adding these details to the thread in the hope to get
this into 7.1.y and 7.0.y soon).

Ciao, Thorsten

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH] drm/amdgpu: drop retry loop in amdgpu_hmm_range_get_pages
  2026-06-16 13:20 ` Greg KH
@ 2026-06-18 22:30   ` Deucher, Alexander
  0 siblings, 0 replies; 5+ messages in thread
From: Deucher, Alexander @ 2026-06-18 22:30 UTC (permalink / raw)
  To: Greg KH; +Cc: stable@vger.kernel.org, Koenig, Christian, Huang, Honglei1

Public

> -----Original Message-----
> From: Greg KH <gregkh@linuxfoundation.org>
> Sent: Tuesday, June 16, 2026 9:21 AM
> To: Deucher, Alexander <Alexander.Deucher@amd.com>
> Cc: stable@vger.kernel.org; Koenig, Christian <Christian.Koenig@amd.com>;
> Huang, Honglei1 <Honglei1.Huang@amd.com>
> Subject: Re: [PATCH] drm/amdgpu: drop retry loop in
> amdgpu_hmm_range_get_pages
>
> On Tue, Jun 16, 2026 at 09:05:31AM -0400, Alex Deucher wrote:
> > From: Honglei Huang <honghuan@amd.com>
> >
> > Since commit c08972f55594 ("drm/amdgpu: fix
> > amdgpu_hmm_range_get_pages") moved mmu_interval_read_begin() out
> of
> > the per-chunk loop, the captured notifier_seq is no longer refreshed
> > across retries. As a result, the existing -EBUSY retry path can never make
> progress:
> >
> >   hmm_range_fault() returns -EBUSY only when
> >   mmu_interval_check_retry(notifier, notifier_seq) reports that the
> >   sequence is stale. Once the sequence has advanced, the stored seq
> >   will never match again, so every subsequent call within the same
> >   invocation returns -EBUSY immediately.
> >
> > The "goto retry" therefore degenerates into a busy spin that simply
> > burns CPU for the full HMM_RANGE_DEFAULT_TIMEOUT (~1s) window
> before
> > finally bailing out with -EAGAIN. This is pure latency with no chance
> > of recovery, and it actively hurts the KFD userptr stack: the caller
> > ends up blocked for a second while holding mmap_lock, only to return
> > -EAGAIN to the restore worker (or to userspace) which would have
> > re-driven the operation immediately anyway.
> >
> > Drop the retry/timeout entirely and let -EBUSY propagate straight to
> > out_free_pfns, where it is already translated to -EAGAIN. Recovery is
> > handled at a higher level: the KFD restore_userptr_worker reschedules
> > itself, and the userptr ioctl path returns -EAGAIN to userspace.
> >
> > No functional regression: the previous behaviour on -EBUSY was already
> > to fail with -EAGAIN after a 1s stall; we just skip the stall.
> >
> > Fixes: c08972f55594 ("drm/amdgpu: fix amdgpu_hmm_range_get_pages")
> > Closes: https://gitlab.freedesktop.org/drm/amd/-/work_items/5393
> > Reviewed-by: Christian König <christian.koenig@amd.com>
> > Signed-off-by: Honglei Huang <honghuan@amd.com>
> > Signed-off-by: Alex Deucher <alexander.deucher@amd.com> (cherry picked
> > from commit 342981fff32802a819d6fc7cf3c9fedf9f3d9d60)
> > Cc: stable@vger.kernel.org
> > ---
> >
> > This patch is from drm-next and fixes a regression in a patch that
> > went to stable.
>
> But this commit isn't in Linus's tree yet so we can't take it, right?

It was only in drm-next when I sent this email, but it has since landed in Linux tree now that he has pulled the drm tree.

Alex

>
> confused,
>
> greg k-h

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-06-18 22:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-16 13:05 [PATCH] drm/amdgpu: drop retry loop in amdgpu_hmm_range_get_pages Alex Deucher
2026-06-16 13:20 ` Greg KH
2026-06-18 22:30   ` Deucher, Alexander
2026-06-16 13:20 ` Greg KH
2026-06-18  9:08   ` Thorsten Leemhuis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox