All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/i915: Remove toplevel struct_mutex locking from debugfs/i915_drop_caches
@ 2017-05-24 16:26 Chris Wilson
  2017-05-24 16:44 ` ✓ Fi.CI.BAT: success for " Patchwork
  2017-05-25 14:58 ` [PATCH] " Joonas Lahtinen
  0 siblings, 2 replies; 5+ messages in thread
From: Chris Wilson @ 2017-05-24 16:26 UTC (permalink / raw)
  To: intel-gfx

I have a plan to write a quick test to exercise concurrent usage of
i915_gem_shrink(), the simplest way looks to be to have multiple threads
using debugfs/i915_drop_caches. However, we currently take one lock over
the entire function, serialising the calls into i915_gem_shrink() so
reduce the lock coverage.

Testcase: igt/gem_shrink/reclaim
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
---
 drivers/gpu/drm/i915/i915_debugfs.c | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 25b97788b906..bd16db60164c 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -4116,26 +4116,28 @@ i915_drop_caches_set(void *data, u64 val)
 {
 	struct drm_i915_private *dev_priv = data;
 	struct drm_device *dev = &dev_priv->drm;
-	int ret;
+	int ret = 0;
 
 	DRM_DEBUG("Dropping caches: 0x%08llx\n", val);
 
 	/* No need to check and wait for gpu resets, only libdrm auto-restarts
 	 * on ioctls on -EAGAIN. */
-	ret = mutex_lock_interruptible(&dev->struct_mutex);
-	if (ret)
-		return ret;
-
-	if (val & DROP_ACTIVE) {
-		ret = i915_gem_wait_for_idle(dev_priv,
-					     I915_WAIT_INTERRUPTIBLE |
-					     I915_WAIT_LOCKED);
+	if (val & (DROP_ACTIVE | DROP_RETIRE)) {
+		ret = mutex_lock_interruptible(&dev->struct_mutex);
 		if (ret)
-			goto unlock;
-	}
+			return ret;
 
-	if (val & DROP_RETIRE)
-		i915_gem_retire_requests(dev_priv);
+		if (val & DROP_ACTIVE) {
+			ret = i915_gem_wait_for_idle(dev_priv,
+						     I915_WAIT_INTERRUPTIBLE |
+						     I915_WAIT_LOCKED);
+		}
+
+		if (val & DROP_RETIRE)
+			i915_gem_retire_requests(dev_priv);
+
+		mutex_unlock(&dev->struct_mutex);
+	}
 
 	lockdep_set_current_reclaim_state(GFP_KERNEL);
 	if (val & DROP_BOUND)
@@ -4148,9 +4150,6 @@ i915_drop_caches_set(void *data, u64 val)
 		i915_gem_shrink_all(dev_priv);
 	lockdep_clear_current_reclaim_state();
 
-unlock:
-	mutex_unlock(&dev->struct_mutex);
-
 	if (val & DROP_FREED) {
 		synchronize_rcu();
 		i915_gem_drain_freed_objects(dev_priv);
-- 
2.11.0

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

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

* ✓ Fi.CI.BAT: success for drm/i915: Remove toplevel struct_mutex locking from debugfs/i915_drop_caches
  2017-05-24 16:26 [PATCH] drm/i915: Remove toplevel struct_mutex locking from debugfs/i915_drop_caches Chris Wilson
@ 2017-05-24 16:44 ` Patchwork
  2017-05-25 14:58 ` [PATCH] " Joonas Lahtinen
  1 sibling, 0 replies; 5+ messages in thread
From: Patchwork @ 2017-05-24 16:44 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: drm/i915: Remove toplevel struct_mutex locking from debugfs/i915_drop_caches
URL   : https://patchwork.freedesktop.org/series/24885/
State : success

== Summary ==

Series 24885v1 drm/i915: Remove toplevel struct_mutex locking from debugfs/i915_drop_caches
https://patchwork.freedesktop.org/api/1.0/series/24885/revisions/1/mbox/

fi-bdw-5557u     total:278  pass:267  dwarn:0   dfail:0   fail:0   skip:11  time:446s
fi-bdw-gvtdvm    total:278  pass:256  dwarn:8   dfail:0   fail:0   skip:14  time:429s
fi-bsw-n3050     total:278  pass:242  dwarn:0   dfail:0   fail:0   skip:36  time:584s
fi-bxt-j4205     total:278  pass:259  dwarn:0   dfail:0   fail:0   skip:19  time:506s
fi-byt-j1900     total:278  pass:254  dwarn:0   dfail:0   fail:0   skip:24  time:483s
fi-byt-n2820     total:278  pass:250  dwarn:0   dfail:0   fail:0   skip:28  time:479s
fi-hsw-4770      total:278  pass:262  dwarn:0   dfail:0   fail:0   skip:16  time:411s
fi-hsw-4770r     total:278  pass:262  dwarn:0   dfail:0   fail:0   skip:16  time:414s
fi-ilk-650       total:278  pass:228  dwarn:0   dfail:0   fail:0   skip:50  time:416s
fi-ivb-3520m     total:278  pass:260  dwarn:0   dfail:0   fail:0   skip:18  time:488s
fi-ivb-3770      total:278  pass:260  dwarn:0   dfail:0   fail:0   skip:18  time:463s
fi-kbl-7500u     total:278  pass:255  dwarn:5   dfail:0   fail:0   skip:18  time:463s
fi-kbl-7560u     total:278  pass:263  dwarn:5   dfail:0   fail:0   skip:10  time:568s
fi-skl-6260u     total:278  pass:268  dwarn:0   dfail:0   fail:0   skip:10  time:457s
fi-skl-6700hq    total:278  pass:239  dwarn:0   dfail:1   fail:17  skip:21  time:430s
fi-skl-6700k     total:278  pass:256  dwarn:4   dfail:0   fail:0   skip:18  time:465s
fi-skl-6770hq    total:278  pass:268  dwarn:0   dfail:0   fail:0   skip:10  time:504s
fi-skl-gvtdvm    total:278  pass:265  dwarn:0   dfail:0   fail:0   skip:13  time:436s
fi-snb-2520m     total:278  pass:250  dwarn:0   dfail:0   fail:0   skip:28  time:529s
fi-snb-2600      total:278  pass:249  dwarn:0   dfail:0   fail:0   skip:29  time:404s

7808a0f3330f5bdf11b5b6880af8407ad6200989 drm-tip: 2017y-05m-24d-11h-04m-21s UTC integration manifest
bdaeecc drm/i915: Remove toplevel struct_mutex locking from debugfs/i915_drop_caches

== Logs ==

For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_4803/
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH] drm/i915: Remove toplevel struct_mutex locking from debugfs/i915_drop_caches
  2017-05-24 16:26 [PATCH] drm/i915: Remove toplevel struct_mutex locking from debugfs/i915_drop_caches Chris Wilson
  2017-05-24 16:44 ` ✓ Fi.CI.BAT: success for " Patchwork
@ 2017-05-25 14:58 ` Joonas Lahtinen
  2017-05-25 15:03   ` Chris Wilson
  1 sibling, 1 reply; 5+ messages in thread
From: Joonas Lahtinen @ 2017-05-25 14:58 UTC (permalink / raw)
  To: Chris Wilson, intel-gfx

On ke, 2017-05-24 at 17:26 +0100, Chris Wilson wrote:
> I have a plan to write a quick test to exercise concurrent usage of
> i915_gem_shrink(), the simplest way looks to be to have multiple threads
> using debugfs/i915_drop_caches. However, we currently take one lock over
> the entire function, serialising the calls into i915_gem_shrink() so
> reduce the lock coverage.
> 
> Testcase: igt/gem_shrink/reclaim
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>

<SNIP>

> +		if (val & DROP_RETIRE)
> +			i915_gem_retire_requests(dev_priv);
> +
> +		mutex_unlock(&dev->struct_mutex);
> +	}
>  
>  	lockdep_set_current_reclaim_state(GFP_KERNEL);

Lock used to work as a serializer, isn't this going to get contended
now?

Regards, Joonas
-- 
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH] drm/i915: Remove toplevel struct_mutex locking from debugfs/i915_drop_caches
  2017-05-25 14:58 ` [PATCH] " Joonas Lahtinen
@ 2017-05-25 15:03   ` Chris Wilson
  2017-05-30  8:42     ` Joonas Lahtinen
  0 siblings, 1 reply; 5+ messages in thread
From: Chris Wilson @ 2017-05-25 15:03 UTC (permalink / raw)
  To: Joonas Lahtinen; +Cc: intel-gfx

On Thu, May 25, 2017 at 05:58:33PM +0300, Joonas Lahtinen wrote:
> On ke, 2017-05-24 at 17:26 +0100, Chris Wilson wrote:
> > I have a plan to write a quick test to exercise concurrent usage of
> > i915_gem_shrink(), the simplest way looks to be to have multiple threads
> > using debugfs/i915_drop_caches. However, we currently take one lock over
> > the entire function, serialising the calls into i915_gem_shrink() so
> > reduce the lock coverage.
> > 
> > Testcase: igt/gem_shrink/reclaim
> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> > Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> 
> <SNIP>
> 
> > +		if (val & DROP_RETIRE)
> > +			i915_gem_retire_requests(dev_priv);
> > +
> > +		mutex_unlock(&dev->struct_mutex);
> > +	}
> >  
> >  	lockdep_set_current_reclaim_state(GFP_KERNEL);
> 
> Lock used to work as a serializer, isn't this going to get contended
> now?

lockdep_set_current ?

The intention is to allow the contention to reach i915_gem_shrink where
we have the more complex locking.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH] drm/i915: Remove toplevel struct_mutex locking from debugfs/i915_drop_caches
  2017-05-25 15:03   ` Chris Wilson
@ 2017-05-30  8:42     ` Joonas Lahtinen
  0 siblings, 0 replies; 5+ messages in thread
From: Joonas Lahtinen @ 2017-05-30  8:42 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

On to, 2017-05-25 at 16:03 +0100, Chris Wilson wrote:
> On Thu, May 25, 2017 at 05:58:33PM +0300, Joonas Lahtinen wrote:

<SNIP>

> > 
> > Lock used to work as a serializer, isn't this going to get contended
> > now?
> 
> lockdep_set_current ?
> 
> The intention is to allow the contention to reach i915_gem_shrink where
> we have the more complex locking.

Nevermind,

Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>

Regards, Joonas
-- 
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

end of thread, other threads:[~2017-05-30  8:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-24 16:26 [PATCH] drm/i915: Remove toplevel struct_mutex locking from debugfs/i915_drop_caches Chris Wilson
2017-05-24 16:44 ` ✓ Fi.CI.BAT: success for " Patchwork
2017-05-25 14:58 ` [PATCH] " Joonas Lahtinen
2017-05-25 15:03   ` Chris Wilson
2017-05-30  8:42     ` Joonas Lahtinen

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.