Patchwork [RFC/RFT] use monotonic clock for relative time where available

mail settings
Submitter Johannes Berg
Date Nov. 13, 2013, 7:03 p.m.
Message ID <>
Download mbox | patch
Permalink /patch/291016/
State Superseded
Headers show


Johannes Berg - Nov. 13, 2013, 7:03 p.m.
On Wed, 2013-11-13 at 17:50 +0100, Johannes Berg wrote:
> From: Johannes Berg <>
> Relative time shouldn't be calculated based on gettimeofday
> because that clock can jump (e.g. when the time is adjusted
> by the system administrator.)
> On systems where that is available, use CLOCK_BOOTTIME (on
> fairly recent Linux systems, this clock takes into account
> the time spend suspended) or CLOCK_MONOTONIC (on Linux and
> some POSIX systems, this clock is just freely running with
> no adjustments.)
> Unfortunately this patch is invasive since a lot of places
> need to be adjusted to use os_get_reltime() rather than
> os_get_time() that is used now. However, not all instances
> should use the other clock, e.g. absolute time needed in
> any certificate checking and similar needs to be wall time.
> TODO: carefully check all replacements to see if any should
>       actually be using os_get_time() instead!

FWIW, with this patch, tests are passing (still running) when I add this
patch to my vm runner script:

With this clock modification and an unmodified wpa_s, it totally fails.



--- a/tests/hwsim/vm/
+++ b/tests/hwsim/vm/
@@ -56,6 +56,13 @@  ip link set lo up
 mkdir /tmp/logs
 mount -t 9p -o trans=virtio,rw logshare /tmp/logs
+    while sleep 1 ; do
+        date --set "@$(($(date +%s) + 19))"
+        date >/dev/ttyS0
+    done
+) &
 # check if we're rebooting due to a kernel panic ...
 if grep -q 'Kernel panic' /tmp/logs/console ; then
        echo "KERNEL CRASHED!" >/dev/ttyS0