eal/linux: make alarm not affected by system time jump
authorWen-Chi Yang <wolkayang@gmail.com>
Fri, 5 Jun 2015 02:46:36 +0000 (10:46 +0800)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Wed, 21 Oct 2015 15:01:24 +0000 (17:01 +0200)
commitd08d304508a8a8caf255baf622ab65db1fec952c
treec0aa538203a670db45e8cda927a6ce058f9dd0cb
parent1e7bd2380f661d7b4024708371f8340a6e55fd8d
eal/linux: make alarm not affected by system time jump

Due to eal_alarm_callback() and rte_eal_alarm_set() use gettimeofday()
to get the current time, and gettimeofday() is affected by jumps.

For example, set up a rte_alarm which will be triggerd next second (
current time + 1 second) by rte_eal_alarm_set(). And the callback
function of this rte_alarm sets up another rte_alarm which will be
triggered next second (current time + 2 second).
Once we change the system time when the callback function is triggered,
it is possible that rte alarm functionalities work out of expectation.

Replace gettimeofday() with clock_gettime(CLOCK_MONOTONIC_RAW, &now)
could avoid this phenomenon.

Signed-off-by: Wen-Chi Yang <wolkayang@gmail.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
lib/librte_eal/linuxapp/eal/eal_alarm.c