vppinfra: improve timebase resilience 63/25763/2
authorDave Barach <dave@barachs.net>
Tue, 10 Mar 2020 13:01:02 +0000 (09:01 -0400)
committerFlorin Coras <florin.coras@gmail.com>
Tue, 10 Mar 2020 21:49:46 +0000 (21:49 +0000)
commit66441c4c6fa1fc32f9df510c7665886c6eb50189
treea403c2b88a27a1443a60336448ef658035d3a52a
parentb55aec1c8e0c05520c47c3641c20684fc539f8a1
vppinfra: improve timebase resilience

Deal with arbitrary kernel reference time changes: for example,
yanking the kernel reference clock back to a time before vpp started.

Best practice involves aligning the kernel reference clock with
reality prior to starting apps which use 10us granularity timers.

Compute change in the reference and cpu clocks. Recompute the vpp
start time reference and and total cpu clock count, using the current
clock tick rate.

Next, compute a new clock rate sample. If the sample seems sane,
factor it into the exponentially smoothed clock rate and recalculate
total cpu ticks based on the new clock rate.

Type: fix

Signed-off-by: Dave Barach <dave@barachs.net>
Change-Id: Ib6132ffbbe0e6d140725676de5e35be112a31dfe
src/vppinfra/time.c