AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Philip Yang <Philip.Yang@amd.com>
To: <amd-gfx@lists.freedesktop.org>
Cc: Philip Yang <Philip.Yang@amd.com>, Felix.Kuehling@amd.com
Subject: [PATCH 5/5] drm/amdkfd: svm deferred work pin mm
Date: Tue, 9 Nov 2021 18:04:32 -0500	[thread overview]
Message-ID: <20211109230432.3947-5-Philip.Yang@amd.com> (raw)
In-Reply-To: <20211109230432.3947-1-Philip.Yang@amd.com>

Make sure mm does not remove when prange deferred work insert mmu range
notifier, to avoid WARNING:

WARNING: CPU: 6 PID: 1787 at mm/mmu_notifier.c:932 __mmu_interval_notifier_insert+0xdd/0xf0
Workqueue: events svm_range_deferred_list_work [amdgpu]
RIP: 0010:__mmu_interval_notifier_insert+0xdd/0xf0
Call Trace:
  svm_range_deferred_list_work+0x156/0x320 [amdgpu]
  process_one_work+0x29f/0x5e0
  worker_thread+0x39/0x3e0

Signed-off-by: Philip Yang <Philip.Yang@amd.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
index 2083a10b35c2..fddf0a93d6f1 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
@@ -1992,6 +1992,13 @@ static void svm_range_deferred_list_work(struct work_struct *work)
 			 prange->start, prange->last, prange->work_item.op);
 
 		mm = prange->work_item.mm;
+		if (!mmget_not_zero(mm)) {
+			pr_debug("skip range %p as mm is gone\n", prange);
+			spin_lock(&svms->deferred_list_lock);
+			list_del_init(&prange->deferred_list);
+			continue;
+		}
+
 retry:
 		mmap_write_lock(mm);
 		mutex_lock(&svms->lock);
@@ -2032,6 +2039,7 @@ static void svm_range_deferred_list_work(struct work_struct *work)
 		svm_range_handle_list_op(svms, prange);
 		mutex_unlock(&svms->lock);
 		mmap_write_unlock(mm);
+		mmput(mm);
 
 		spin_lock(&svms->deferred_list_lock);
 	}
-- 
2.17.1


  parent reply	other threads:[~2021-11-09 23:05 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-09 23:04 [PATCH 1/5] drm/amdgpu: handle IH ring1 overflow Philip Yang
2021-11-09 23:04 ` [PATCH 2/5] drm/amdkfd: check child range to drain retry fault Philip Yang
2021-11-10  3:26   ` Felix Kuehling
2021-11-11 21:55     ` philip yang
2021-11-09 23:04 ` [PATCH 3/5] drm/amdkfd: restore pages race with vma remove Philip Yang
2021-11-10  3:52   ` Felix Kuehling
2021-11-09 23:04 ` [PATCH 4/5] drm/amdkfd: restore pages race with process termination Philip Yang
2021-11-10  4:16   ` Felix Kuehling
2021-11-15 20:50     ` philip yang
2021-11-09 23:04 ` Philip Yang [this message]
2021-11-10  4:51   ` [PATCH 5/5] drm/amdkfd: svm deferred work pin mm Felix Kuehling
2021-11-10 10:15 ` [PATCH 1/5] drm/amdgpu: handle IH ring1 overflow Christian König
2021-11-10 13:59   ` philip yang
2021-11-10 14:31     ` Christian König
2021-11-10 14:44       ` philip yang
2021-11-10 14:54         ` Christian König
2021-11-10 15:45           ` philip yang
2021-11-10 15:48             ` Christian König
2021-11-10 23:36       ` Felix Kuehling
2021-11-11  7:00         ` Christian König
2021-11-11 12:13           ` Felix Kuehling
2021-11-11 13:43             ` Christian König
2021-11-11 13:57               ` Felix Kuehling
2021-11-11 21:31                 ` philip yang

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=20211109230432.3947-5-Philip.Yang@amd.com \
    --to=philip.yang@amd.com \
    --cc=Felix.Kuehling@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