Skip to content

bperf: Avoid "time going back" in per thread reader #380

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

liu-song-6
Copy link
Contributor

Summary:
We use rdtsc to estimate enabled and running time. However,
kernel occasionally adjusts the algorithm of tsc based timer.
Therefore, extra care is need to avoid "time going back" issue.
Please refer to the comment before kernel function
ktime_get_mono_fast_ns() for more information.

Here, we make time_after_offset_update 0.1% smaller. So that
the time never goes back. This is not an issue for time_enabled
and time_running, as they are only used adjust PMC reading.
However, cpuTime may show some spikes when we adjust the time
forward.

Differential Revision: D75930645

Summary:
We use rdtsc to estimate enabled and running time. However,
kernel occasionally adjusts the algorithm of tsc based timer.
Therefore, extra care is need to avoid "time going back" issue.
Please refer to the comment before kernel function
ktime_get_mono_fast_ns() for more information.

Here, we make time_after_offset_update 0.1% smaller. So that
the time never goes back. This is not an issue for time_enabled
and time_running, as they are only used adjust PMC reading.
However, cpuTime may show some spikes when we adjust the time
forward.

Differential Revision: D75930645
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 4, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75930645

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants