All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [FIXES 2/3] drm/i915/userptr: Handle unlocked gup retries
Date: Mon, 11 Nov 2019 14:19:31 +0000	[thread overview]
Message-ID: <57389ded-7186-9d5c-3d46-b8aa0a7e025c@linux.intel.com> (raw)
In-Reply-To: <20191111133205.11590-2-chris@chris-wilson.co.uk>


On 11/11/2019 13:32, Chris Wilson wrote:
> Enable gup to retry and fault the pages outside of the mmap_sem lock in
> our worker. As we are inside our worker, outside of any critical path,
> we can allow the mmap_sem lock to be dropped in order to service a page
> fault; this in turn allows the mm to populate the page using a slow
> fault handler.
> 
> Testcase: igt/gem_userptr/userfault

There are no references or explanation on what does this fix?

Regards,

Tvrtko

> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> ---
>   drivers/gpu/drm/i915/gem/i915_gem_userptr.c | 11 ++++++++---
>   1 file changed, 8 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 dd104b0e2071..54ebc7ab71bc 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_userptr.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_userptr.c
> @@ -459,26 +459,31 @@ __i915_gem_userptr_get_pages_worker(struct work_struct *_work)
>   	if (pvec != NULL) {
>   		struct mm_struct *mm = obj->userptr.mm->mm;
>   		unsigned int flags = 0;
> +		int locked = 0;
>   
>   		if (!i915_gem_object_is_readonly(obj))
>   			flags |= FOLL_WRITE;
>   
>   		ret = -EFAULT;
>   		if (mmget_not_zero(mm)) {
> -			down_read(&mm->mmap_sem);
>   			while (pinned < npages) {
> +				if (!locked) {
> +					down_read(&mm->mmap_sem);
> +					locked = 1;
> +				}
>   				ret = get_user_pages_remote
>   					(work->task, mm,
>   					 obj->userptr.ptr + pinned * PAGE_SIZE,
>   					 npages - pinned,
>   					 flags,
> -					 pvec + pinned, NULL, NULL);
> +					 pvec + pinned, NULL, &locked);
>   				if (ret < 0)
>   					break;
>   
>   				pinned += ret;
>   			}
> -			up_read(&mm->mmap_sem);
> +			if (locked)
> +				up_read(&mm->mmap_sem);
>   			mmput(mm);
>   		}
>   	}
> 
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

WARNING: multiple messages have this Message-ID (diff)
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [Intel-gfx] [FIXES 2/3] drm/i915/userptr: Handle unlocked gup retries
Date: Mon, 11 Nov 2019 14:19:31 +0000	[thread overview]
Message-ID: <57389ded-7186-9d5c-3d46-b8aa0a7e025c@linux.intel.com> (raw)
Message-ID: <20191111141931.CNw-q5X3R46y7ell4DSaSGbU1usZOOuTaWrDjyHMspY@z> (raw)
In-Reply-To: <20191111133205.11590-2-chris@chris-wilson.co.uk>


On 11/11/2019 13:32, Chris Wilson wrote:
> Enable gup to retry and fault the pages outside of the mmap_sem lock in
> our worker. As we are inside our worker, outside of any critical path,
> we can allow the mmap_sem lock to be dropped in order to service a page
> fault; this in turn allows the mm to populate the page using a slow
> fault handler.
> 
> Testcase: igt/gem_userptr/userfault

There are no references or explanation on what does this fix?

Regards,

Tvrtko

> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> ---
>   drivers/gpu/drm/i915/gem/i915_gem_userptr.c | 11 ++++++++---
>   1 file changed, 8 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 dd104b0e2071..54ebc7ab71bc 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_userptr.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_userptr.c
> @@ -459,26 +459,31 @@ __i915_gem_userptr_get_pages_worker(struct work_struct *_work)
>   	if (pvec != NULL) {
>   		struct mm_struct *mm = obj->userptr.mm->mm;
>   		unsigned int flags = 0;
> +		int locked = 0;
>   
>   		if (!i915_gem_object_is_readonly(obj))
>   			flags |= FOLL_WRITE;
>   
>   		ret = -EFAULT;
>   		if (mmget_not_zero(mm)) {
> -			down_read(&mm->mmap_sem);
>   			while (pinned < npages) {
> +				if (!locked) {
> +					down_read(&mm->mmap_sem);
> +					locked = 1;
> +				}
>   				ret = get_user_pages_remote
>   					(work->task, mm,
>   					 obj->userptr.ptr + pinned * PAGE_SIZE,
>   					 npages - pinned,
>   					 flags,
> -					 pvec + pinned, NULL, NULL);
> +					 pvec + pinned, NULL, &locked);
>   				if (ret < 0)
>   					break;
>   
>   				pinned += ret;
>   			}
> -			up_read(&mm->mmap_sem);
> +			if (locked)
> +				up_read(&mm->mmap_sem);
>   			mmput(mm);
>   		}
>   	}
> 
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2019-11-11 14:19 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-11 13:32 [FIXES 1/3] drm/i915/userptr: Try to acquire the page lock around set_page_dirty() Chris Wilson
2019-11-11 13:32 ` [Intel-gfx] " Chris Wilson
2019-11-11 13:32 ` [FIXES 2/3] drm/i915/userptr: Handle unlocked gup retries Chris Wilson
2019-11-11 13:32   ` [Intel-gfx] " Chris Wilson
2019-11-11 14:19   ` Tvrtko Ursulin [this message]
2019-11-11 14:19     ` Tvrtko Ursulin
2019-11-11 14:27     ` Chris Wilson
2019-11-11 14:27       ` [Intel-gfx] " Chris Wilson
2019-11-11 14:32       ` Chris Wilson
2019-11-11 14:32         ` [Intel-gfx] " Chris Wilson
2019-11-11 15:44         ` Tvrtko Ursulin
2019-11-11 15:44           ` [Intel-gfx] " Tvrtko Ursulin
2019-11-11 13:32 ` [FIXES 3/3] drm/i915/execlists: Move reset_active() from schedule-out to schedule-in Chris Wilson
2019-11-11 13:32   ` [Intel-gfx] " Chris Wilson
2019-11-11 16:31   ` Tvrtko Ursulin
2019-11-11 16:31     ` [Intel-gfx] " Tvrtko Ursulin
2019-11-11 16:34     ` Chris Wilson
2019-11-11 16:34       ` [Intel-gfx] " Chris Wilson
2019-11-11 14:12 ` [FIXES 1/3] drm/i915/userptr: Try to acquire the page lock around set_page_dirty() Tvrtko Ursulin
2019-11-11 14:12   ` [Intel-gfx] " Tvrtko Ursulin
2019-11-11 18:33 ` ✗ Fi.CI.BAT: failure for series starting with [FIXES,1/3] " Patchwork
2019-11-11 18:33   ` [Intel-gfx] " 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=57389ded-7186-9d5c-3d46-b8aa0a7e025c@linux.intel.com \
    --to=tvrtko.ursulin@linux.intel.com \
    --cc=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.