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

Support CLOCK_BOOTTIME #218

Open
prattmic opened this issue Apr 29, 2019 · 5 comments
Open

Support CLOCK_BOOTTIME #218

prattmic opened this issue Apr 29, 2019 · 5 comments
Labels
area: compatibility Issue related to (Linux) kernel compatibility good first issue Good for newcomers priority: p3 Low priority type: enhancement New feature or request

Comments

@prattmic
Copy link
Member

prattmic commented Apr 29, 2019

We could likely make CLOCK_BOOTTIME equivalent to CLOCK_MONOTONIC, as CLOCK_MONOTONIC already includes time spent not running during save / restore, which is the closest thing we have to "suspend".

// Compute the offset of the monotonic clock from the base Clocks.
//
// In a fresh (not restored) sentry, monotonic time starts at zero.
//
// In a restored sentry, monotonic time jumps forward by approximately
// the same amount as real time. There are no guarantees here, we are
// just making a best-effort attempt to to make it appear that the app
// was simply not scheduled for a long period, rather than that the
// real time clock was changed.
//
// If real time went backwards, it remains the same.

@prattmic prattmic added type: enhancement New feature or request good first issue Good for newcomers area: compatibility Issue related to (Linux) kernel compatibility priority: p3 Low priority labels Apr 29, 2019
@prattmic
Copy link
Member Author

prattmic commented May 6, 2019

systemd wants CLOCK_BOOTTIME, though it has a fallback: https://github.com/systemd/systemd/blob/04d7ca022843913fba5170c40be07acf2ab5902b/src/basic/time-util.c#L82

It's not immediately clear to me what functionality it loses.

@Pixep
Copy link
Contributor

Pixep commented Jun 18, 2019

Is the current behavior of CLOCK_MONOTONIC during save/restore even considered the proper one? This actually looks like CLOCK_BOOTTIME to me.

@prattmic
Copy link
Member Author

The Linux kernel doesn't have the concept of save / restore, so there is no defined "correct" behavior across S/R. I can see arguments for both sides. As is, the clock jump makes operations with a timeout likely to fire immediately upon restore. On the other hand, it may cause some anomalous timing statistics for things that happen to be measured across S/R.

@Pixep
Copy link
Contributor

Pixep commented Jun 18, 2019

You're right, but aren't the situations where "it may cause some anomalous timing statistics" supposed to be using CLOCK_BOOTTIME or a real-time clock instead? I'm considering supporting you on that issue, hence the questions :). But I suppose we can assume it to be strictly equivalent to the current CLOCK_MONOTONIC for now as you said, and that is a different topic.

@Pixep
Copy link
Contributor

Pixep commented Jun 22, 2019

I believe CLOCK_BOOTTIME is intended to only be an alias to the existing CLOCK_MONOTONIC (i.e. no dedicated kernel timer). This would effectively make this a minimal change. Is there any plan to make the two clocks independents instead?

Pixep added a commit to Pixep/gVisor that referenced this issue Jun 22, 2019
Makes CLOCK_BOOTTIME available with
* clock_gettime
* timerfd_create
* clock_gettime vDSO

CLOCK_BOOTTIME is implemented as an alias to CLOCK_MONOTONIC.
CLOCK_MONOTONIC already keeps track of time across save
and restore. This is the closest possible behavior to Linux
CLOCK_BOOTIME, as there is no concept of suspend/resume.

Updates google#218
Pixep added a commit to Pixep/gVisor that referenced this issue Jun 25, 2019
Makes CLOCK_BOOTTIME available with
* clock_gettime
* timerfd_create
* clock_gettime vDSO

CLOCK_BOOTTIME is implemented as an alias to CLOCK_MONOTONIC.
CLOCK_MONOTONIC already keeps track of time across save
and restore. This is the closest possible behavior to Linux
CLOCK_BOOTIME, as there is no concept of suspend/resume.

Updates google#218
gvisor-bot pushed a commit that referenced this issue Jul 18, 2019
Makes CLOCK_BOOTTIME available with
* clock_gettime
* timerfd_create
* clock_gettime vDSO

CLOCK_BOOTTIME is implemented as an alias to CLOCK_MONOTONIC.
CLOCK_MONOTONIC already keeps track of time across save
and restore. This is the closest possible behavior to Linux
CLOCK_BOOTIME, as there is no concept of suspend/resume.

Updates #218

FUTURE_COPYBARA_INTEGRATE_REVIEW=#450 from Pixep:feature/add-clock-boottime-as-monotonic 2d11fa0
PiperOrigin-RevId: 258819371
gvisor-bot pushed a commit that referenced this issue Jul 18, 2019
Makes CLOCK_BOOTTIME available with
* clock_gettime
* timerfd_create
* clock_gettime vDSO

CLOCK_BOOTTIME is implemented as an alias to CLOCK_MONOTONIC.
CLOCK_MONOTONIC already keeps track of time across save
and restore. This is the closest possible behavior to Linux
CLOCK_BOOTIME, as there is no concept of suspend/resume.

Updates #218

FUTURE_COPYBARA_INTEGRATE_REVIEW=#450 from Pixep:feature/add-clock-boottime-as-monotonic 2d11fa0
PiperOrigin-RevId: 258819371
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: compatibility Issue related to (Linux) kernel compatibility good first issue Good for newcomers priority: p3 Low priority type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants