Skip to content

RFC Introduce a way to adjust CLOCK_BOOTTIME from userspace for VM guests

Hikaru Nishida kvm lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest2 patches 7 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2timekeeping: Add timekeeping_adjust_boottimeinclude/linux/timekeeping.h kernel/time/timekeeping.c+28 -01 reply
2/2drivers/virt: introduce CLOCK_BOOTTIME adjustment sysfs interface driverdrivers/virt/Kconfig drivers/virt/Makefile drivers/virt/boottime_adj.c+67 -03 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH 0/2] Introduce a way to adjust CLOCK_BOOTTIME from userspace for VM guests

From: Hikaru Nishida <[email protected]>

Hi folks,

We'd like to add a sysfs interface that enable us to advance CLOCK_BOOTTIME from userspace. The use case of this change is that adjusting guest's CLOCK_BOOTTIME as host suspends to ensure that the guest can notice the device has been suspended.
We have an application that rely on the difference between CLOCK_BOOTTIME and CLOCK_MONOTONIC to detect whether the device went suspend or not. However, the logic did not work well on VM environment since most VMs are pausing the VM guests instead of actually suspending them on the host's suspension.
With following patches, we can adjust CLOCK_BOOTTIME without actually suspending guest and make the app working as intended.
I think this feature is also useful for other VM solutions since there was no way to do this from userspace.

As far as I checked, it is working as expected but is there any concern about this change? If so, please let me know.

Thanks,
Hikaru Nishida

Hikaru Nishida (2):
timekeeping: Add timekeeping_adjust_boottime drivers/virt: introduce CLOCK_BOOTTIME adjustment sysfs interface
driver

 drivers/virt/Kconfig        |  9 ++++++
 drivers/virt/Makefile       |  1 +
 drivers/virt/boottime_adj.c | 57 +++++++++++++++++++++++++++++++++++++
 include/linux/timekeeping.h |  2 ++
 kernel/time/timekeeping.c   | 26 +++++++++++++++++
 5 files changed, 95 insertions(+)
 create mode 100644 drivers/virt/boottime_adj.c
Signature · 1 line
2.30.0.478.g8a0d178c01-goog