fn freq_scale_shift(scaled_hz: u64, base_hz: u64) -> (u32, i8)
Expand description

Calculate a (multiplier, shift) pair for scaled math of clocks. The values are passed on to pvclock_scale_delta in the guest kernel and satisfy the following (approximate) equality: n * scaled_hz / base_hz ~= ((n << shift) * multiplier) >> 32 The logic here is roughly based on kvm_get_time_scale (but simplified as we can use u128).

§Arguments

  • scaled_hz - Frequency to convert to. When dealing with clocksources, this is NSEC_PER_SEC.
  • base_hz - Frequency to convert from. When dealing with clocksources, this is the counter frequency.