mutex: down_timeout: check against the base time
authorYasushi SHOJI <yasushi.shoji@gmail.com>
Thu, 28 Dec 2017 01:53:47 +0000 (10:53 +0900)
committerYasushi SHOJI <yasushi.shoji@gmail.com>
Thu, 28 Dec 2017 01:53:47 +0000 (10:53 +0900)
commit7e92a66a681f8da4879a0006ee64e5ea35b6a749
tree1dc2651bbfa1778db3400e6e779d1c77d805ac1f
parentf7c305464667b118b62aff9b846d1a939fbc1547
mutex: down_timeout: check against the base time

When the commit 8b6a404cdd2c40715885e562416c3db039912773 changed
timeval to timespec, it accsidentally picked timeout time `t' instead
of the current `base' time for checking timewait() really timed out.

t is base + msecs as follows:

      base = gettimeofday()
      t = base + msecs
      pthread_cond_timedwait()
      while (!done)
         if (timedout)
    if (mutex_timed_out(t, msecs))
       done = true

Thus, after a good timedout, it burns the cpu for the given msecs
seconds doing tight loop in the while shown above.  This causes 30 to
40 % CPU load on my i5-3360M 2.80GHz while fio server is running.
mutex.c