<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, May 4, 2016 at 10:04 AM, Martin Peres <span dir="ltr"><<a href="mailto:martin.peres@linux.intel.com" target="_blank">martin.peres@linux.intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>On 03/05/16 22:34, Robert Bragg wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Sorry for the delay replying to this, I missed it.<br>
</blockquote>
<br></span>
No worries!<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>
<br>
On Sat, Apr 23, 2016 at 11:34 AM, Martin Peres <<a href="mailto:martin.peres@free.fr" target="_blank">martin.peres@free.fr</a><br></span><span>
<mailto:<a href="mailto:martin.peres@free.fr" target="_blank">martin.peres@free.fr</a>>> wrote:<br>
<br>
On 20/04/16 17:23, Robert Bragg wrote:<br>
<br>
Gen graphics hardware can be set up to periodically write<br>
snapshots of<br>
performance counters into a circular buffer via its Observation<br>
Architecture and this patch exposes that capability to userspace<br>
via the<br>
i915 perf interface.<br>
<br>
Cc: Chris Wilson <<a href="mailto:chris@chris-wilson.co.uk" target="_blank">chris@chris-wilson.co.uk</a><br></span>
<mailto:<a href="mailto:chris@chris-wilson.co.uk" target="_blank">chris@chris-wilson.co.uk</a>>><br>
Signed-off-by: Robert Bragg <<a href="mailto:robert@sixbynine.org" target="_blank">robert@sixbynine.org</a><br>
<mailto:<a href="mailto:robert@sixbynine.org" target="_blank">robert@sixbynine.org</a>>><br>
Signed-off-by: Zhenyu Wang <<a href="mailto:zhenyuw@linux.intel.com" target="_blank">zhenyuw@linux.intel.com</a><br>
<mailto:<a href="mailto:zhenyuw@linux.intel.com" target="_blank">zhenyuw@linux.intel.com</a>>><div><div><br>
---<br>
drivers/gpu/drm/i915/i915_drv.h | 56 +-<br>
drivers/gpu/drm/i915/i915_gem_context.c | 24 +-<br>
drivers/gpu/drm/i915/i915_perf.c | 940<br>
+++++++++++++++++++++++++++++++-<br>
drivers/gpu/drm/i915/i915_reg.h | 338 ++++++++++++<br>
include/uapi/drm/i915_drm.h | 70 ++-<br>
5 files changed, 1408 insertions(+), 20 deletions(-)<br>
<br>
+<br>
+<br>
+ /* It takes a fairly long time for a new MUX<br>
configuration to<br>
+ * be be applied after these register writes. This delay<br>
+ * duration was derived empirically based on the<br>
render_basic<br>
+ * config but hopefully it covers the maximum configuration<br>
+ * latency...<br>
+ */<br>
+ mdelay(100);<br>
<br>
<br>
With such a HW and SW design, how can we ever expose hope to get any<br>
kind of performance when we are trying to monitor different metrics<br>
on each<br>
draw call? This may be acceptable for system monitoring, but it is<br>
problematic<br>
for the GL extensions :s<br>
<br>
<br>
Since it seems like we are going for a perf API, it means that for<br>
every change<br>
of metrics, we need to flush the commands, wait for the GPU to be<br>
done, then<br>
program the new set of metrics via an IOCTL, wait 100 ms, and then<br>
we may<br>
resume rendering ... until the next change. We are talking about a<br>
latency of<br>
6-7 frames at 60 Hz here... this is non-negligeable...<br>
<br>
<br>
I understand that we have a ton of counters and we may hide latency<br>
by not<br>
allowing using more than half of the counters for every draw call or<br>
frame, but<br>
even then, this 100ms delay is killing this approach altogether.<br>
<br>
<br>
<br>
Although I'm also really unhappy about introducing this delay recently,<br>
the impact of the delay is typically amortized somewhat by keeping a<br>
configuration open as long as possible.<br>
<br>
Even without this explicit delay here the OA unit isn't suited to being<br>
reconfigured on a per draw call basis, though it is able to support per<br>
draw call queries with the same config.<br>
<br>
The above assessment assumes wanting to change config between draw calls<br>
which is not something this driver aims to support - as the HW isn't<br>
really designed for that model.<br>
<br>
E.g. in the case of INTEL_performance_query, the backend keeps the i915<br>
perf stream open until all OA based query objects are deleted - so you<br>
have to be pretty explicit if you want to change config.<br>
</div></div></blockquote>
<br>
OK, I get your point. However, I still want to state that applications changing the set would see a disastrous effect as a 100 ms is enough to downclock both the CPU and GPU and that would dramatically alter the<br>
metrics. Should we make it clear somewhere, either in the INTEL_performance_query or as a warning in mesa_performance if changing the set while running? I would think the latter would be preferable as it could also cover the case of the AMD extension which, IIRC, does not talk about the performance cost of changing the metrics. With this caveat made clear, it seems reasonable.<span><br></span></blockquote><div><br></div><div>Yeah a KHR_debug performance warning sounds like a good idea.<br></div><div> <span></span><span></span><br><span></span></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
In case you aren't familiar with how the GL_INTEL_performance_query side<br>
of things works for OA counters; one thing to be aware of is that<br>
there's a separate MI_REPORT_PERF_COUNT command that Mesa writes either<br>
side of a query which writes all the counters for the current OA config<br>
(as configured via this i915 perf interface) to a buffer. In addition to<br>
collecting reports via MI_REPORT_PERF_COUNT Mesa also configures the<br>
unit for periodic sampling to be able to account for potential counter<br>
overflow.<br>
</blockquote>
<br></span>
Oh, the overflow case is mean. Doesn't the spec mandate the application to read at least every second? This is the case for the timestamp queries.<span><br></span></blockquote><div><br></div><div>For a Haswell GT3 system with 40EUs @ 1GHz some aggregate EU counters may overflow their 32bits in approximately 40milliseconds. It should be pretty unusual to see a draw call last that long, but not unimaginable. Might also be a good draw call to focus on profiling too :-)<br><br></div><div>For Gen8+ a bunch of the A counters can be reported with 40bits to mitigate this issue.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
It also might be worth keeping in mind that per draw queries will anyway<br>
trash the pipelining of work, since it's necessary to put stalls between<br>
the draw calls to avoid conflated metrics (not to do with the details of<br>
this driver) so use cases will probably be limited to those that just<br>
want the draw call numbers but don't mind ruining overall<br>
frame/application performance. Periodic sampling or swap-to-swap queries<br>
would be better suited to cases that should minimize their impact.<br>
</blockquote>
<br></span>
Yes, I agree that there will always be a cost, but with the design implemented in nouveau (which barely involves the CPU at all), the pipelining is almost unaffected. As in, monitoring every draw call with a different metric would lower the performance of glxgears (worst case I could think off) but still keep thousands of FPS.<span><br></span></blockquote><br><div>I guess it just has different trade offs.<br><br></div><div>While it sounds like we have a typically higher cost to reconfigure OA (at least if touching the MUX) once the config is fixed (which can be done before measuring anything), then I guess the pipelining for queries might be slightly better with MI_REPORT_PERF_COUNT commands than something requiring interrupting + executing work on the cpu to switch config (even if it's cheaper than an OA re-config). I guess nouveau would have the same need to insert GPU pipeline stalls (just gpu syncing with gpu) to avoid conflating neighbouring draw call metrics, and maybe the bubbles from those that can swallow the latency of the software methods.<br></div><div><br></div><div>glxgears might not really exaggerate draw call pipeline stall issues with only 6 cheap primitives per gear. glxgears hammers context switching more so than drawing anything. I think a pessimal case would be an app that depends on large numbers of draw calls per frame that each do enough real work that stalling for their completion is also measurable.<br><br>Funnily enough enabling the OA unit with glxgears can be kind of problematic for Gen8+ which automatically writes reports on context switch due to the spam of generating all of those context switch reports.<br><span></span> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
The driver is already usable with gputop with this delay and considering<br>
how config changes are typically associated with user interaction I<br>
wouldn't see this as a show stopper - even though it's not ideal. I<br>
think the assertions about it being unusable with GL, were a little<br>
overstated based on making frequent OA config changes which is not<br>
really how the interface is intended to be used.<br>
</blockquote>
<br></span>
Yeah, but a performance warning in mesa, I would be OK with this change. Thanks for taking the time to explain!</blockquote><div><br></div><div>A performance warning sounds like a sensible idea yup.<br><br></div><div>Regards,<br></div><div>- Robert<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
Thanks for starting to take a look through the code.<br>
<br>
Kind Regards,<br>
- Robert<br>
</blockquote>
<br></div></div><span><font color="#888888">
Martin<br>
</font></span></blockquote></div><br></div></div>