Skip to content
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

Use high-precision vblank timings, if available #33

Merged
merged 4 commits into from
Sep 24, 2019

Conversation

hfink-daqri
Copy link
Contributor

This (work-in-progress) PR implements the use of more accurate vblank timestamps, as suggested in #30 :

It requires a small kernel patch (submitted to the mailing list here), that extends the drm_vblank_event with two fields: time holding a monotonic clock timestamp, and high_prec, a boolean indicating whether or not the timestamp came from a DRM driver that is able to generate HW-corrected high-precision vblank timestamps, or not.

GPUVis is fully backwards-compatible to how it worked before. High-precision vblank timestamps are only used in GPUVis if the following is true:

  • the overall trace was created with monotonic clock (see below)
  • the user turned ON the option to use high-prec timestamps (OPT_VBlankHighPrecTimestamps, default is OFF) (bound to Ctrl-Shift-K, or right-click to toggle in option pop-up)
  • time field is set in the drm_vblank_event data, and high_prec is true

Opening an enriched trace, you can now toggle back and forth using Ctrl-Shift-K and see how the purple lines jump back and forth (on my laptop, diff is ~ 200ms).

As described above, you need to configure ftrace to use monotonic clock as the source for timestamps:
echo mono > /sys/kernel/tracing/trace_clock

Without that, we can't easily align the timestamps of the vblank event along the ftrace/GPUVis timeline.

Heinrich added 4 commits August 9, 2019 17:53
When reading drm_vblank_event events, parse the following optional
fields:

- 'time': a possibly more accurate timestamp better representing the
actual HW vblank timestamp

- 'high_prec': true if 'time' is a high-precision HW timestamp from a
drm driver with this particular capability

Fields are only parsed if the ftrace clock was set to `mono`, otherwise
the timestamps can't be aligned in a meaningful way.

With ftrace, the tracing clock can be set to `mono like this:

`echo mono > /sys/kernel/tracing/trace_clock`

Also add helper functions to retrieve the high-precision timestamp.
@mikesart
Copy link
Owner

Hi Heinrich. This looks good to me. Let me know when you want to have it pulled and I'll get it in. Thanks much.

@hfink-daqri hfink-daqri changed the title WIP: Use high-precision vblank timings, if available Use high-precision vblank timings, if available Sep 23, 2019
@hfink-daqri
Copy link
Contributor Author

The kernel patch has been accepted and is currently in drm-misc-next. It's supposed to land for 5.5. I think this MR is ready to be merged.

@mikesart mikesart merged commit 14c4600 into mikesart:master Sep 24, 2019
@mikesart
Copy link
Owner

It's in. Thanks Heinrich!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants