intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: intel-gfx@lists.freedesktop.org
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Subject: [Intel-gfx] [PATCH] drm/i915/gem: Avoid waiting inside mmu_notifier_invalidate_range
Date: Fri, 22 May 2020 04:01:09 +0100	[thread overview]
Message-ID: <20200522030109.4845-1-chris@chris-wilson.co.uk> (raw)

Since the userptr may be invalidated from inside a reclaim path, we
cannot wait on unbinding the object as we may hold any number of locks,
including the active reference of the object we are trying to
invalidate. E.g.

[<0>] __i915_active_wait+0x70/0xc0 [i915]
[<0>] i915_vma_unbind+0x2f/0x110 [i915]
[<0>] i915_gem_object_unbind+0x17c/0x350 [i915]
[<0>] userptr_mn_invalidate_range_start+0xb6/0x140 [i915]
[<0>] __mmu_notifier_invalidate_range_start+0x105/0x150
[<0>] try_to_unmap_one+0x7fb/0x900
[<0>] rmap_walk_file+0xe4/0x240
[<0>] try_to_unmap+0x85/0xc0
[<0>] shrink_page_list+0x885/0xe80
[<0>] shrink_inactive_list+0x155/0x260
[<0>] shrink_lruvec+0x4ec/0x5f0
[<0>] shrink_node+0x15b/0x410
[<0>] try_to_free_pages+0x169/0x3a0
[<0>] __alloc_pages_slowpath.constprop.0+0x251/0xa00
[<0>] __alloc_pages_nodemask+0x144/0x170
[<0>] new_slab+0x259/0x280
[<0>] ___slab_alloc.isra.0.constprop.0+0x3dd/0x460
[<0>] __slab_alloc.isra.0.constprop.0+0x9/0x10
[<0>] kmem_cache_alloc+0x11a/0x130
[<0>] alloc_pd+0x17/0x60 [i915]
[<0>] __gen8_ppgtt_alloc+0x2d7/0x350 [i915]
[<0>] gen8_ppgtt_alloc+0x35/0x70 [i915]
[<0>] ppgtt_bind_vma+0x29/0x70 [i915]

This situation only occurs when the lru page shrinker tries to sacrifice
one the objects it is trying to allocate for. However, we do have to
wait for an active object so that we can revoke access to the page
range.

Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/1702
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/gem/i915_gem_userptr.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_userptr.c b/drivers/gpu/drm/i915/gem/i915_gem_userptr.c
index 8b0708708671..a398d817543e 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_userptr.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_userptr.c
@@ -126,9 +126,11 @@ userptr_mn_invalidate_range_start(struct mmu_notifier *_mn,
 		}
 		spin_unlock(&mn->lock);
 
-		ret = i915_gem_object_unbind(obj,
-					     I915_GEM_OBJECT_UNBIND_ACTIVE |
-					     I915_GEM_OBJECT_UNBIND_BARRIER);
+		ret = i915_gem_object_wait(obj,
+					   I915_WAIT_ALL,
+					   MAX_SCHEDULE_TIMEOUT);
+		if (ret == 0)
+			ret = i915_gem_object_unbind(obj, 0);
 		if (ret == 0)
 			ret = __i915_gem_object_put_pages(obj);
 		i915_gem_object_put(obj);
-- 
2.20.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

             reply	other threads:[~2020-05-22  3:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-22  3:01 Chris Wilson [this message]
2020-05-22  4:07 ` [Intel-gfx] ✓ Fi.CI.BAT: success for drm/i915/gem: Avoid waiting inside mmu_notifier_invalidate_range Patchwork
2020-05-22 22:49 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork

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=20200522030109.4845-1-chris@chris-wilson.co.uk \
    --to=chris@chris-wilson.co.uk \
    --cc=intel-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;
as well as URLs for NNTP newsgroup(s).