mbox series

[0/3] trace-cmd: Align guest TSC calculation with the kernel

Message ID 20210923094526.765059-1-tz.stoyanov@gmail.com (mailing list archive)
Headers show
Series trace-cmd: Align guest TSC calculation with the kernel | expand

Message

Tzvetomir Stoyanov (VMware) Sept. 23, 2021, 9:45 a.m. UTC
The formula for calculating guest TSC clock, used in the kernel is:
 guest_tsc = tsc-offset + (host_tsc * tsc-scaling-ratio) >> tsc-scaling-ratio-frac-bits
Current trace-cmd implementation does not take into account fraction
bits, when calculating guest clock offset in case of a clock scaling.
Additional logic is added, to use the same formula in trace-cmd. The changes
are backward compatible with trace-cmd 2.9.

The changes are not tested with a kernel that has guest clock scaling enabled.
The goal of the patch set is to extend the time sync option, saved in the
guest trace.dat file, with all needed data used in the kernel for guest TSC
calculations.

Tzvetomir Stoyanov (VMware) (3):
  trace-cmd: Extend host-guest time sync with fraction bits
  trace-cmd: Read and use fraction bits from TRACECMD_OPTION_TIME_SHIFT
  trace-cmd: Dump fraction bits from TRACECMD_OPTION_TIME_SHIFT

 .../include/private/trace-cmd-private.h       |   4 +-
 lib/trace-cmd/include/trace-tsync-local.h     |   7 +-
 lib/trace-cmd/trace-input.c                   |  79 +++++++-------
 lib/trace-cmd/trace-timesync-kvm.c            |  59 +++++++---
 lib/trace-cmd/trace-timesync-ptp.c            |   4 +-
 lib/trace-cmd/trace-timesync.c                |  49 +++++++--
 tracecmd/trace-dump.c                         | 102 +++++++++++++-----
 7 files changed, 205 insertions(+), 99 deletions(-)