diff mbox

drm/i915/selftests: Drop struct_mutex around lowlevel pggtt allocation

Message ID 20180703100754.21218-1-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Chris Wilson July 3, 2018, 10:07 a.m. UTC
For a ppgtt that we are constructing, there is no struct_mutex
dependence so skip it. In the process, also ping the scheduler
frequently to try and avoid the NMI watchdog.

Suggested-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
References: https://bugs.freedesktop.org/show_bug.cgi?id=107094
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 drivers/gpu/drm/i915/selftests/i915_gem_gtt.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

Comments

Tvrtko Ursulin July 3, 2018, 10:55 a.m. UTC | #1
On 03/07/2018 11:07, Chris Wilson wrote:
> For a ppgtt that we are constructing, there is no struct_mutex
> dependence so skip it. In the process, also ping the scheduler
> frequently to try and avoid the NMI watchdog.
> 
> Suggested-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> References: https://bugs.freedesktop.org/show_bug.cgi?id=107094
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> ---
>   drivers/gpu/drm/i915/selftests/i915_gem_gtt.c | 13 ++++++-------
>   1 file changed, 6 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
> index a28ee0cc6a63..fff26bd05f71 100644
> --- a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
> +++ b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
> @@ -142,12 +142,9 @@ static int igt_ppgtt_alloc(void *arg)
>   	if (!USES_PPGTT(dev_priv))
>   		return 0;
>   
> -	mutex_lock(&dev_priv->drm.struct_mutex);
>   	ppgtt = __hw_ppgtt_create(dev_priv);
> -	if (IS_ERR(ppgtt)) {
> -		err = PTR_ERR(ppgtt);
> -		goto err_unlock;
> -	}
> +	if (IS_ERR(ppgtt))
> +		return PTR_ERR(ppgtt);
>   
>   	if (!ppgtt->vm.allocate_va_range)
>   		goto err_ppgtt_cleanup;
> @@ -166,6 +163,8 @@ static int igt_ppgtt_alloc(void *arg)
>   			goto err_ppgtt_cleanup;
>   		}
>   
> +		cond_resched();
> +

This test is also long running? Seeing how it allocates in growing 
chunks I expected it would finish quick, but it would not?

Regards,

Tvrtko

>   		ppgtt->vm.clear_range(&ppgtt->vm, 0, size);
>   	}
>   
> @@ -183,13 +182,13 @@ static int igt_ppgtt_alloc(void *arg)
>   			}
>   			goto err_ppgtt_cleanup;
>   		}
> +
> +		cond_resched();
>   	}
>   
>   err_ppgtt_cleanup:
>   	ppgtt->vm.cleanup(&ppgtt->vm);
>   	kfree(ppgtt);
> -err_unlock:
> -	mutex_unlock(&dev_priv->drm.struct_mutex);
>   	return err;
>   }
>   
>
Chris Wilson July 3, 2018, 11 a.m. UTC | #2
Quoting Tvrtko Ursulin (2018-07-03 11:55:28)
> 
> On 03/07/2018 11:07, Chris Wilson wrote:
> > For a ppgtt that we are constructing, there is no struct_mutex
> > dependence so skip it. In the process, also ping the scheduler
> > frequently to try and avoid the NMI watchdog.
> > 
> > Suggested-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> > References: https://bugs.freedesktop.org/show_bug.cgi?id=107094
> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> > Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> > ---
> >   drivers/gpu/drm/i915/selftests/i915_gem_gtt.c | 13 ++++++-------
> >   1 file changed, 6 insertions(+), 7 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
> > index a28ee0cc6a63..fff26bd05f71 100644
> > --- a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
> > +++ b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
> > @@ -142,12 +142,9 @@ static int igt_ppgtt_alloc(void *arg)
> >       if (!USES_PPGTT(dev_priv))
> >               return 0;
> >   
> > -     mutex_lock(&dev_priv->drm.struct_mutex);
> >       ppgtt = __hw_ppgtt_create(dev_priv);
> > -     if (IS_ERR(ppgtt)) {
> > -             err = PTR_ERR(ppgtt);
> > -             goto err_unlock;
> > -     }
> > +     if (IS_ERR(ppgtt))
> > +             return PTR_ERR(ppgtt);
> >   
> >       if (!ppgtt->vm.allocate_va_range)
> >               goto err_ppgtt_cleanup;
> > @@ -166,6 +163,8 @@ static int igt_ppgtt_alloc(void *arg)
> >                       goto err_ppgtt_cleanup;
> >               }
> >   
> > +             cond_resched();
> > +
> 
> This test is also long running? Seeing how it allocates in growing 
> chunks I expected it would finish quick, but it would not?

I'm not sure if the might_sleep/sleep for allocations is credited to us.
The easiest way to be sure is to reschedule explicitly. Anyway, it's the
allocations here that take time, but there's also some time spent
converting pages to WC and filling them with scratch. Again not sure
how much that is credited to us against NMI, but the main one is the
struct_mutex blocking other tasks.
-Chris
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
index a28ee0cc6a63..fff26bd05f71 100644
--- a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
@@ -142,12 +142,9 @@  static int igt_ppgtt_alloc(void *arg)
 	if (!USES_PPGTT(dev_priv))
 		return 0;
 
-	mutex_lock(&dev_priv->drm.struct_mutex);
 	ppgtt = __hw_ppgtt_create(dev_priv);
-	if (IS_ERR(ppgtt)) {
-		err = PTR_ERR(ppgtt);
-		goto err_unlock;
-	}
+	if (IS_ERR(ppgtt))
+		return PTR_ERR(ppgtt);
 
 	if (!ppgtt->vm.allocate_va_range)
 		goto err_ppgtt_cleanup;
@@ -166,6 +163,8 @@  static int igt_ppgtt_alloc(void *arg)
 			goto err_ppgtt_cleanup;
 		}
 
+		cond_resched();
+
 		ppgtt->vm.clear_range(&ppgtt->vm, 0, size);
 	}
 
@@ -183,13 +182,13 @@  static int igt_ppgtt_alloc(void *arg)
 			}
 			goto err_ppgtt_cleanup;
 		}
+
+		cond_resched();
 	}
 
 err_ppgtt_cleanup:
 	ppgtt->vm.cleanup(&ppgtt->vm);
 	kfree(ppgtt);
-err_unlock:
-	mutex_unlock(&dev_priv->drm.struct_mutex);
 	return err;
 }