-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
drm:drm_vblank_event doesn't represent actual HW vblank #30
Comments
Correction: This holds for all drivers, not just i915. The difference between when we handle the vblank interrupt and the actual vblank timestamp is entirely driver dependent (but in no case actually matches). Please also note that the time you can last successfully submit a page flip is also driver dependent. The only cross-driver guarantee is that after you get the vblank event, a subsequent flip will schedule on the next frame. Even if the vblank hasn't actually happened yet. But it is entirely undefined how much ahead of that event you need to submit a page flip to hit the current vblank. |
Can I trouble you for a link to a log of the #intel-gfx discussion. Don't want to make you have to repeat yourself here. I believe that we currently don't have any information source that offers higher precision than
Could an event like the above be generate by the i915 driver? If not, do we have any alternative strategies for mitigating the delay? (we could try to find some standard deviation and show vblank as a range for example) |
Alternatively, we could:
Terminology note. By IRQ handler I mean the routine that executes outside once interrupts are re-enabled. I can't recall the proper name at the moment. |
For a compositor to be able to achieve maximum quality of service (eg. lowest possible latency while not missing frames), it'd be nice for drivers to provide a reasonable estimate on what that value might be on the current hardware that's driving the head, though. At the bare minimum feedback on what vblank a flip actually landed on would let us tune the compositor frame timer guard window timing at runtime, so hopefully the driver is able to provide that, but a hint to get us started would be ideal. |
I didn't keep a log of that discussion, sorry. As far as I remember, there wasn't any additional information discussed than already described here.
I can't really comment on the trace points and i915 architecture, but would it be possible for a user-space process to insert events into the
If I'm not mistaken, this information you can already track through the Could it also be that kernel static trace points are simply not well suited for collecting this data? Maybe it would be worth thinking to add an alternative data collection technique (i.e. instead of ftrace) on Linux to GPUVis (such as Window ETL support was apparently recently) in the long run? |
@lostgoat Trying to answer your questions:
@Plagman agreed, but given scheduling heuristics and all that stuff it's tricky. Best rule of thumb for the deadline right now is "a bit before you get the drm_event/hit that tracepoint". The really annoying thing is that for some hw you can squeeze in a frame update even after the vblank has passed already (those suppporting vrr usually), and we're still shuffling around implementation details to make sure we have consistent timestamps and all that for these cases. They way things are progressing we'll do the following:
It might be good to put that into some formal vblank/page_flip timestamp uapi documentation. |
That sounds perfect. We can use the adjusted timestamp if the field is available, otherwise we'll use the ftrace timestamp. |
sounds good, I didn't know that we can extend the tracepoint that easily. I would be more than happy to test this on our side and share the results. @danvet what do you think is the best way to move forward, and how can I help? |
tbh I just think we can extend tracepoints like that, I'm not sure. next step would be to type the kernel patch and maybe adjust gpuvis and see whether it all works. should be a tiny patch, at least on the kernel side. |
I think @hfink-daqri is already building his own kernel to enable the Intel tracepoints, so if anyone has a rough patch I'm sure either he or I could get it working and give it a try on the user side. Thanks everyone. |
I have some comprehension questions.
According to drm docs the vertical front porch is extended in this case until a time out (VRR minimum) or a page flip / atomic commit comes in. The next vblank just begins later. Or did in this case the drm_vblank_event already trigger and you meant that? I created the following diagram to visualize what's happening around a vblank:
Please tell me if that's not correct. Some explanations why intervals are defined and points of interest P-1 to P-4 are placed like above:
In the end userland receives in the |
@subdiff a few thoughts:
tldr; all bets are off :-) Also sorry for the late reply, somehow missed the notification. |
Update: There's a few more drivers with high-precision timestamp support: stm, and msm (but only for mdp5, not for mdp4). |
@danvet I measured the diff between ~CPU time for irq_handler and timestamp provided by re. possible patches, I'd be happy to assist in testing eventual patches, even if it's just work-in-progress prototypes. |
Ok, I've checked my math and on my 1980x1200 screen the vblank (so P3-P4) is a bit less than 500 usec. I thought it was longer, but I guess that was just back in the old days of actual CRT screens. So P2-P4 of 200-400 usec is somewhat plausible I think. |
I was playing around to extend the trace-point as discussed above. The kernel part seems straight-forward, I got that part working, but I am struggling to align the passed timestamp (which is monotonic clock based) to the timestamps used in gpuvis. Is there maybe a similar case in gpuvis where a monotonic-clock timestamp is aligned to the trace-event timeline that I could follow? Or maybe documentation on how trace-event timestamps are being parsed? |
answering my question above: ftrace needs to be configured to use monotonic clock for time-stamping. It'll be slower than the default "local" CPU clock, but reasonable to do for our use-case, I guess: |
I got high-precision vblank timestamps working so far, see linked PR above. It works nicely and you can toggle back and forth between using high-precision and IRQ-based vblank timings in GPUVis. @danvet I sent a draft of the kernel patch to the mailing list. It's the first time I am sending a kernel patch, so it's likely there's something wrong/missing in that patch and/or me messing up my Feedback on either kernel/GPUVis side is very welcome. I am off for 10 days now, so I might be late responding to your comments and won't be able to submit new revision before being back. |
Store the timestamp of the current vblank in the new field 'time' of the vblank trace event. If the timestamp is calculated by a driver that supports high-precision vblank timing, set the field 'high-prec' to 'true'. User space can now access actual hardware vblank times via the tracing infrastructure. Tracing applications (such as GPUVis, see [0] for related discussion), can use the newly added information to conduct a more accurate analysis of display timing. [0] mikesart/gpuvis#30 Signed-off-by: Heinrich <heinrich.fink@daqri.com>
kernel patch has been applied to drm-misc-next and GPUVis MR was merged. Closing this issue. Thanks everyone for this interesting discussion and your input! |
Store the timestamp of the current vblank in the new field 'time' of the vblank trace event. If the timestamp is calculated by a driver that supports high-precision vblank timing, set the field 'high-prec' to 'true'. User space can now access actual hardware vblank times via the tracing infrastructure. Tracing applications (such as GPUVis, see [0] for related discussion), can use the newly added information to conduct a more accurate analysis of display timing. v2 Fix author name (missing last name) [0] mikesart/gpuvis#30 Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Heinrich Fink <heinrich.fink@daqri.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: https://patchwork.freedesktop.org/patch/msgid/20190902142412.27846-2-heinrich.fink@daqri.com
Store the timestamp of the current vblank in the new field 'time' of the vblank trace event. If the timestamp is calculated by a driver that supports high-precision vblank timing, set the field 'high-prec' to 'true'. User space can now access actual hardware vblank times via the tracing infrastructure. Tracing applications (such as GPUVis, see [0] for related discussion), can use the newly added information to conduct a more accurate analysis of display timing. v2 Fix author name (missing last name) [0] mikesart/gpuvis#30 Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Heinrich Fink <heinrich.fink@daqri.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: https://patchwork.freedesktop.org/patch/msgid/20190902142412.27846-2-heinrich.fink@daqri.com
Store the timestamp of the current vblank in the new field 'time' of the vblank trace event. If the timestamp is calculated by a driver that supports high-precision vblank timing, set the field 'high-prec' to 'true'. User space can now access actual hardware vblank times via the tracing infrastructure. Tracing applications (such as GPUVis, see [0] for related discussion), can use the newly added information to conduct a more accurate analysis of display timing. v2 Fix author name (missing last name) [0] mikesart/gpuvis#30 Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Heinrich Fink <heinrich.fink@daqri.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: https://patchwork.freedesktop.org/patch/msgid/20190902142412.27846-2-heinrich.fink@daqri.com
Store the timestamp of the current vblank in the new field 'time' of the vblank trace event. If the timestamp is calculated by a driver that supports high-precision vblank timing, set the field 'high-prec' to 'true'. User space can now access actual hardware vblank times via the tracing infrastructure. Tracing applications (such as GPUVis, see [0] for related discussion), can use the newly added information to conduct a more accurate analysis of display timing. v2 Fix author name (missing last name) [0] mikesart/gpuvis#30 Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Heinrich Fink <heinrich.fink@daqri.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: https://patchwork.freedesktop.org/patch/msgid/20190902142412.27846-2-heinrich.fink@daqri.com
Store the timestamp of the current vblank in the new field 'time' of the vblank trace event. If the timestamp is calculated by a driver that supports high-precision vblank timing, set the field 'high-prec' to 'true'. User space can now access actual hardware vblank times via the tracing infrastructure. Tracing applications (such as GPUVis, see [0] for related discussion), can use the newly added information to conduct a more accurate analysis of display timing. v2 Fix author name (missing last name) [0] mikesart/gpuvis#30 Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Heinrich Fink <heinrich.fink@daqri.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: https://patchwork.freedesktop.org/patch/msgid/20190902142412.27846-2-heinrich.fink@daqri.com
Store the timestamp of the current vblank in the new field 'time' of the vblank trace event. If the timestamp is calculated by a driver that supports high-precision vblank timing, set the field 'high-prec' to 'true'. User space can now access actual hardware vblank times via the tracing infrastructure. Tracing applications (such as GPUVis, see [0] for related discussion), can use the newly added information to conduct a more accurate analysis of display timing. v2 Fix author name (missing last name) [0] mikesart/gpuvis#30 Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Heinrich Fink <heinrich.fink@daqri.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: https://patchwork.freedesktop.org/patch/msgid/20190902142412.27846-2-heinrich.fink@daqri.com
Store the timestamp of the current vblank in the new field 'time' of the vblank trace event. If the timestamp is calculated by a driver that supports high-precision vblank timing, set the field 'high-prec' to 'true'. User space can now access actual hardware vblank times via the tracing infrastructure. Tracing applications (such as GPUVis, see [0] for related discussion), can use the newly added information to conduct a more accurate analysis of display timing. v2 Fix author name (missing last name) [0] mikesart/gpuvis#30 Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Heinrich Fink <heinrich.fink@daqri.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: https://patchwork.freedesktop.org/patch/msgid/20190902142412.27846-2-heinrich.fink@daqri.com
Store the timestamp of the current vblank in the new field 'time' of the vblank trace event. If the timestamp is calculated by a driver that supports high-precision vblank timing, set the field 'high-prec' to 'true'. User space can now access actual hardware vblank times via the tracing infrastructure. Tracing applications (such as GPUVis, see [0] for related discussion), can use the newly added information to conduct a more accurate analysis of display timing. v2 Fix author name (missing last name) [0] mikesart/gpuvis#30 Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Heinrich Fink <heinrich.fink@daqri.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: https://patchwork.freedesktop.org/patch/msgid/20190902142412.27846-2-heinrich.fink@daqri.com
Store the timestamp of the current vblank in the new field 'time' of the vblank trace event. If the timestamp is calculated by a driver that supports high-precision vblank timing, set the field 'high-prec' to 'true'. User space can now access actual hardware vblank times via the tracing infrastructure. Tracing applications (such as GPUVis, see [0] for related discussion), can use the newly added information to conduct a more accurate analysis of display timing. v2 Fix author name (missing last name) [0] mikesart/gpuvis#30 Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Heinrich Fink <heinrich.fink@daqri.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: https://patchwork.freedesktop.org/patch/msgid/20190902142412.27846-2-heinrich.fink@daqri.com
Store the timestamp of the current vblank in the new field 'time' of the vblank trace event. If the timestamp is calculated by a driver that supports high-precision vblank timing, set the field 'high-prec' to 'true'. User space can now access actual hardware vblank times via the tracing infrastructure. Tracing applications (such as GPUVis, see [0] for related discussion), can use the newly added information to conduct a more accurate analysis of display timing. v2 Fix author name (missing last name) [0] mikesart/gpuvis#30 Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Heinrich Fink <heinrich.fink@daqri.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: https://patchwork.freedesktop.org/patch/msgid/20190902142412.27846-2-heinrich.fink@daqri.com
Store the timestamp of the current vblank in the new field 'time' of the vblank trace event. If the timestamp is calculated by a driver that supports high-precision vblank timing, set the field 'high-prec' to 'true'. User space can now access actual hardware vblank times via the tracing infrastructure. Tracing applications (such as GPUVis, see [0] for related discussion), can use the newly added information to conduct a more accurate analysis of display timing. v2 Fix author name (missing last name) [0] mikesart/gpuvis#30 Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Heinrich Fink <heinrich.fink@daqri.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: https://patchwork.freedesktop.org/patch/msgid/20190902142412.27846-2-heinrich.fink@daqri.com
Store the timestamp of the current vblank in the new field 'time' of the vblank trace event. If the timestamp is calculated by a driver that supports high-precision vblank timing, set the field 'high-prec' to 'true'. User space can now access actual hardware vblank times via the tracing infrastructure. Tracing applications (such as GPUVis, see [0] for related discussion), can use the newly added information to conduct a more accurate analysis of display timing. v2 Fix author name (missing last name) [0] mikesart/gpuvis#30 Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Heinrich Fink <heinrich.fink@daqri.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: https://patchwork.freedesktop.org/patch/msgid/20190902142412.27846-2-heinrich.fink@daqri.com
By default, GPUVis uses
drm:drm_vblank_event trace
points to identify vblank timings. While working on an Intel i915 trace, I learned that for this driver, thedrm_vblank_event
trace point does not represent the actual HW vblank timestamp, but only the CPU time the trace-point was hit during some irq handler (briefly discussed at #intel-gfx). In my tests, this timestamp was 200 - 400 us before the actual vblank. Supposedly, for a system under heavy load, this divergence becomes larger.This can be a problem when analyzing tight timings with a GPUVis trace. For instance, we are scheduling a CPU wake-up time relative to the last vblank time we get through the user-space KMS API (which is HW corrected and accurate). During that wake-up, we commit display plane state as late as possible for it to make it for the next vblank. In GPUVis, this wake-up appears to be inaccurately scheduled, since the visualized vblank lines are based on inaccurate timings themselves. That lead to a few false conclusions on my side.
Unfortunately I don't have a good fix for this, and neither do I know if this problem also applies to AMD drivers. I just wanted to write this up here in case anyone else runs into this issue, and maybe to discuss alternative solutions.
The text was updated successfully, but these errors were encountered: