* [PATCH] drm/i915: Lock out execlist tasklet while peeking inside for busy-stats
@ 2018-01-15 9:20 Chris Wilson
2018-01-15 9:56 ` Tvrtko Ursulin
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Chris Wilson @ 2018-01-15 9:20 UTC (permalink / raw)
To: intel-gfx
In order to prevent a race condition where we may end up overaccounting
the active state and leaving the busy-stats believing the GPU is 100%
busy, lock out the tasklet while we reconstruct the busy state. There is
no direct spinlock guard for the execlists->port[], so we need to
utilise tasklet_disable() as a synchronous barrier to prevent the only
writer to execlists->port[] from running at the same time as the enable.
Fixes: 4900727d35bb ("drm/i915/pmu: Reconstruct active state on starting busy-stats")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
drivers/gpu/drm/i915/intel_engine_cs.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/i915/intel_engine_cs.c b/drivers/gpu/drm/i915/intel_engine_cs.c
index d790bdc227ff..b221610f2365 100644
--- a/drivers/gpu/drm/i915/intel_engine_cs.c
+++ b/drivers/gpu/drm/i915/intel_engine_cs.c
@@ -1943,16 +1943,22 @@ intel_engine_lookup_user(struct drm_i915_private *i915, u8 class, u8 instance)
*/
int intel_enable_engine_stats(struct intel_engine_cs *engine)
{
+ struct intel_engine_execlists *execlists = &engine->execlists;
unsigned long flags;
+ int err = 0;
if (!intel_engine_supports_stats(engine))
return -ENODEV;
+ tasklet_disable(&execlists->tasklet);
spin_lock_irqsave(&engine->stats.lock, flags);
- if (engine->stats.enabled == ~0)
- goto busy;
+
+ if (unlikely(engine->stats.enabled == ~0)) {
+ err = -EBUSY;
+ goto unlock;
+ }
+
if (engine->stats.enabled++ == 0) {
- struct intel_engine_execlists *execlists = &engine->execlists;
const struct execlist_port *port = execlists->port;
unsigned int num_ports = execlists_num_ports(execlists);
@@ -1967,14 +1973,12 @@ int intel_enable_engine_stats(struct intel_engine_cs *engine)
if (engine->stats.active)
engine->stats.start = engine->stats.enabled_at;
}
- spin_unlock_irqrestore(&engine->stats.lock, flags);
- return 0;
-
-busy:
+unlock:
spin_unlock_irqrestore(&engine->stats.lock, flags);
+ tasklet_enable(&execlists->tasklet);
- return -EBUSY;
+ return err;
}
static ktime_t __intel_engine_get_busy_time(struct intel_engine_cs *engine)
--
2.15.1
_______________________________________________
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
* Re: [PATCH] drm/i915: Lock out execlist tasklet while peeking inside for busy-stats
2018-01-15 9:20 [PATCH] drm/i915: Lock out execlist tasklet while peeking inside for busy-stats Chris Wilson
@ 2018-01-15 9:56 ` Tvrtko Ursulin
2018-01-15 10:39 ` ✓ Fi.CI.BAT: success for " Patchwork
2018-01-15 12:11 ` ✓ Fi.CI.IGT: " Patchwork
2 siblings, 0 replies; 5+ messages in thread
From: Tvrtko Ursulin @ 2018-01-15 9:56 UTC (permalink / raw)
To: Chris Wilson, intel-gfx
On 15/01/2018 09:20, Chris Wilson wrote:
> In order to prevent a race condition where we may end up overaccounting
> the active state and leaving the busy-stats believing the GPU is 100%
> busy, lock out the tasklet while we reconstruct the busy state. There is
> no direct spinlock guard for the execlists->port[], so we need to
> utilise tasklet_disable() as a synchronous barrier to prevent the only
> writer to execlists->port[] from running at the same time as the enable.
>
> Fixes: 4900727d35bb ("drm/i915/pmu: Reconstruct active state on starting busy-stats")
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> ---
> drivers/gpu/drm/i915/intel_engine_cs.c | 20 ++++++++++++--------
> 1 file changed, 12 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_engine_cs.c b/drivers/gpu/drm/i915/intel_engine_cs.c
> index d790bdc227ff..b221610f2365 100644
> --- a/drivers/gpu/drm/i915/intel_engine_cs.c
> +++ b/drivers/gpu/drm/i915/intel_engine_cs.c
> @@ -1943,16 +1943,22 @@ intel_engine_lookup_user(struct drm_i915_private *i915, u8 class, u8 instance)
> */
> int intel_enable_engine_stats(struct intel_engine_cs *engine)
> {
> + struct intel_engine_execlists *execlists = &engine->execlists;
> unsigned long flags;
> + int err = 0;
>
> if (!intel_engine_supports_stats(engine))
> return -ENODEV;
>
> + tasklet_disable(&execlists->tasklet);
> spin_lock_irqsave(&engine->stats.lock, flags);
> - if (engine->stats.enabled == ~0)
> - goto busy;
> +
> + if (unlikely(engine->stats.enabled == ~0)) {
> + err = -EBUSY;
> + goto unlock;
> + }
> +
> if (engine->stats.enabled++ == 0) {
> - struct intel_engine_execlists *execlists = &engine->execlists;
> const struct execlist_port *port = execlists->port;
> unsigned int num_ports = execlists_num_ports(execlists);
>
> @@ -1967,14 +1973,12 @@ int intel_enable_engine_stats(struct intel_engine_cs *engine)
> if (engine->stats.active)
> engine->stats.start = engine->stats.enabled_at;
> }
> - spin_unlock_irqrestore(&engine->stats.lock, flags);
>
> - return 0;
> -
> -busy:
> +unlock:
> spin_unlock_irqrestore(&engine->stats.lock, flags);
> + tasklet_enable(&execlists->tasklet);
>
> - return -EBUSY;
> + return err;
> }
>
> static ktime_t __intel_engine_get_busy_time(struct intel_engine_cs *engine)
>
Hopefully the end of the immediate trouble, with only beautification
remaining.
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Regards,
Tvrtko
_______________________________________________
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
* ✓ Fi.CI.BAT: success for drm/i915: Lock out execlist tasklet while peeking inside for busy-stats
2018-01-15 9:20 [PATCH] drm/i915: Lock out execlist tasklet while peeking inside for busy-stats Chris Wilson
2018-01-15 9:56 ` Tvrtko Ursulin
@ 2018-01-15 10:39 ` Patchwork
2018-01-15 12:11 ` ✓ Fi.CI.IGT: " Patchwork
2 siblings, 0 replies; 5+ messages in thread
From: Patchwork @ 2018-01-15 10:39 UTC (permalink / raw)
To: Chris Wilson; +Cc: intel-gfx
== Series Details ==
Series: drm/i915: Lock out execlist tasklet while peeking inside for busy-stats
URL : https://patchwork.freedesktop.org/series/36473/
State : success
== Summary ==
Series 36473v1 drm/i915: Lock out execlist tasklet while peeking inside for busy-stats
https://patchwork.freedesktop.org/api/1.0/series/36473/revisions/1/mbox/
Test debugfs_test:
Subgroup read_all_entries:
incomplete -> PASS (fi-snb-2520m) fdo#103713 +1
Test gem_mmap_gtt:
Subgroup basic-small-bo-tiledx:
fail -> PASS (fi-gdg-551) fdo#102575
Test kms_pipe_crc_basic:
Subgroup suspend-read-crc-pipe-c:
pass -> DMESG-WARN (fi-kbl-r) fdo#104172
fdo#103713 https://bugs.freedesktop.org/show_bug.cgi?id=103713
fdo#102575 https://bugs.freedesktop.org/show_bug.cgi?id=102575
fdo#104172 https://bugs.freedesktop.org/show_bug.cgi?id=104172
fi-bdw-5557u total:288 pass:267 dwarn:0 dfail:0 fail:0 skip:21 time:419s
fi-bdw-gvtdvm total:288 pass:264 dwarn:0 dfail:0 fail:0 skip:24 time:423s
fi-blb-e6850 total:288 pass:223 dwarn:1 dfail:0 fail:0 skip:64 time:371s
fi-bsw-n3050 total:288 pass:242 dwarn:0 dfail:0 fail:0 skip:46 time:488s
fi-bwr-2160 total:288 pass:183 dwarn:0 dfail:0 fail:0 skip:105 time:280s
fi-bxt-j4205 total:288 pass:259 dwarn:0 dfail:0 fail:0 skip:29 time:488s
fi-byt-j1900 total:288 pass:253 dwarn:0 dfail:0 fail:0 skip:35 time:469s
fi-byt-n2820 total:288 pass:249 dwarn:0 dfail:0 fail:0 skip:39 time:468s
fi-cnl-y2 total:288 pass:261 dwarn:0 dfail:0 fail:0 skip:27 time:529s
fi-elk-e7500 total:224 pass:168 dwarn:10 dfail:0 fail:0 skip:45
fi-gdg-551 total:288 pass:180 dwarn:0 dfail:0 fail:0 skip:108 time:274s
fi-glk-1 total:288 pass:260 dwarn:0 dfail:0 fail:0 skip:28 time:511s
fi-hsw-4770r total:288 pass:261 dwarn:0 dfail:0 fail:0 skip:27 time:399s
fi-ilk-650 total:288 pass:228 dwarn:0 dfail:0 fail:0 skip:60 time:415s
fi-ivb-3520m total:288 pass:259 dwarn:0 dfail:0 fail:0 skip:29 time:456s
fi-ivb-3770 total:288 pass:255 dwarn:0 dfail:0 fail:0 skip:33 time:423s
fi-kbl-7500u total:288 pass:263 dwarn:1 dfail:0 fail:0 skip:24 time:469s
fi-kbl-7560u total:288 pass:269 dwarn:0 dfail:0 fail:0 skip:19 time:504s
fi-kbl-7567u total:288 pass:268 dwarn:0 dfail:0 fail:0 skip:20 time:457s
fi-kbl-r total:288 pass:260 dwarn:1 dfail:0 fail:0 skip:27 time:504s
fi-pnv-d510 total:288 pass:222 dwarn:1 dfail:0 fail:0 skip:65 time:579s
fi-skl-6260u total:288 pass:268 dwarn:0 dfail:0 fail:0 skip:20 time:429s
fi-skl-6600u total:288 pass:261 dwarn:0 dfail:0 fail:0 skip:27 time:516s
fi-skl-6700hq total:288 pass:262 dwarn:0 dfail:0 fail:0 skip:26 time:529s
fi-skl-6700k2 total:288 pass:264 dwarn:0 dfail:0 fail:0 skip:24 time:495s
fi-skl-6770hq total:288 pass:268 dwarn:0 dfail:0 fail:0 skip:20 time:492s
fi-snb-2520m total:245 pass:211 dwarn:0 dfail:0 fail:0 skip:33
fi-snb-2600 total:288 pass:248 dwarn:0 dfail:0 fail:0 skip:40 time:398s
Blacklisted hosts:
fi-cfl-s2 total:288 pass:262 dwarn:0 dfail:0 fail:0 skip:26 time:568s
fi-glk-dsi total:288 pass:258 dwarn:0 dfail:0 fail:0 skip:30 time:466s
254125b984264731491e1eafbe58bc50e84a032d drm-tip: 2018y-01m-15d-09h-31m-31s UTC integration manifest
85e0cababafe drm/i915: Lock out execlist tasklet while peeking inside for busy-stats
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_7667/issues.html
_______________________________________________
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
* ✓ Fi.CI.IGT: success for drm/i915: Lock out execlist tasklet while peeking inside for busy-stats
2018-01-15 9:20 [PATCH] drm/i915: Lock out execlist tasklet while peeking inside for busy-stats Chris Wilson
2018-01-15 9:56 ` Tvrtko Ursulin
2018-01-15 10:39 ` ✓ Fi.CI.BAT: success for " Patchwork
@ 2018-01-15 12:11 ` Patchwork
2018-01-15 12:25 ` Chris Wilson
2 siblings, 1 reply; 5+ messages in thread
From: Patchwork @ 2018-01-15 12:11 UTC (permalink / raw)
To: Chris Wilson; +Cc: intel-gfx
== Series Details ==
Series: drm/i915: Lock out execlist tasklet while peeking inside for busy-stats
URL : https://patchwork.freedesktop.org/series/36473/
State : success
== Summary ==
Test kms_flip:
Subgroup plain-flip-fb-recreate:
fail -> PASS (shard-hsw) fdo#100368
Subgroup vblank-vs-dpms-suspend:
fail -> PASS (shard-snb)
Test kms_setmode:
Subgroup basic:
fail -> PASS (shard-hsw) fdo#99912
Test kms_pipe_crc_basic:
Subgroup suspend-read-crc-pipe-a:
incomplete -> PASS (shard-snb) fdo#103375
Test gem_tiled_swapping:
Subgroup non-threaded:
pass -> INCOMPLETE (shard-hsw) fdo#104218
Test kms_frontbuffer_tracking:
Subgroup fbc-1p-offscren-pri-shrfb-draw-render:
fail -> PASS (shard-snb) fdo#101623 +1
Test perf:
Subgroup oa-formats:
pass -> FAIL (shard-hsw) fdo#104151
fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912
fdo#103375 https://bugs.freedesktop.org/show_bug.cgi?id=103375
fdo#104218 https://bugs.freedesktop.org/show_bug.cgi?id=104218
fdo#101623 https://bugs.freedesktop.org/show_bug.cgi?id=101623
fdo#104151 https://bugs.freedesktop.org/show_bug.cgi?id=104151
shard-hsw total:2644 pass:1502 dwarn:1 dfail:0 fail:9 skip:1131 time:8886s
shard-snb total:2713 pass:1311 dwarn:1 dfail:0 fail:10 skip:1391 time:7908s
Blacklisted hosts:
shard-apl total:2691 pass:1667 dwarn:1 dfail:0 fail:21 skip:1001 time:13180s
shard-kbl total:2713 pass:1808 dwarn:1 dfail:0 fail:23 skip:881 time:10658s
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_7667/shards.html
_______________________________________________
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: ✓ Fi.CI.IGT: success for drm/i915: Lock out execlist tasklet while peeking inside for busy-stats
2018-01-15 12:11 ` ✓ Fi.CI.IGT: " Patchwork
@ 2018-01-15 12:25 ` Chris Wilson
0 siblings, 0 replies; 5+ messages in thread
From: Chris Wilson @ 2018-01-15 12:25 UTC (permalink / raw)
To: Patchwork; +Cc: intel-gfx
Quoting Patchwork (2018-01-15 12:11:48)
> == Series Details ==
>
> Series: drm/i915: Lock out execlist tasklet while peeking inside for busy-stats
> URL : https://patchwork.freedesktop.org/series/36473/
> State : success
>
> == Logs ==
>
> For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_7667/shards.html
Looks good, pushed. Thanks for the review, hopefully the baseline
remains green now and you can tidy up with confidence.
-Chris
_______________________________________________
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:[~2018-01-15 12:25 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-15 9:20 [PATCH] drm/i915: Lock out execlist tasklet while peeking inside for busy-stats Chris Wilson
2018-01-15 9:56 ` Tvrtko Ursulin
2018-01-15 10:39 ` ✓ Fi.CI.BAT: success for " Patchwork
2018-01-15 12:11 ` ✓ Fi.CI.IGT: " Patchwork
2018-01-15 12:25 ` Chris Wilson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox