Jens Axboe | 02bcaa8 | 2006-11-24 10:42:00 +0100 | [diff] [blame] | 1 | /* |
Jens Axboe | f5cc024 | 2006-11-24 10:47:40 +0100 | [diff] [blame] | 2 | * Clock functions |
Jens Axboe | 02bcaa8 | 2006-11-24 10:42:00 +0100 | [diff] [blame] | 3 | */ |
Jens Axboe | f5cc024 | 2006-11-24 10:47:40 +0100 | [diff] [blame] | 4 | |
Jens Axboe | 02bcaa8 | 2006-11-24 10:42:00 +0100 | [diff] [blame] | 5 | #include <unistd.h> |
Jens Axboe | c223da8 | 2010-03-24 13:23:53 +0100 | [diff] [blame] | 6 | #include <math.h> |
Jens Axboe | 02bcaa8 | 2006-11-24 10:42:00 +0100 | [diff] [blame] | 7 | #include <sys/time.h> |
Bruce Cran | 03e20d6 | 2011-01-02 20:14:54 +0100 | [diff] [blame] | 8 | #include <time.h> |
Jens Axboe | 02bcaa8 | 2006-11-24 10:42:00 +0100 | [diff] [blame] | 9 | |
| 10 | #include "fio.h" |
Jens Axboe | be4ecfd | 2008-12-08 14:10:52 +0100 | [diff] [blame] | 11 | #include "smalloc.h" |
Jens Axboe | 02bcaa8 | 2006-11-24 10:42:00 +0100 | [diff] [blame] | 12 | |
| 13 | #include "hash.h" |
| 14 | |
Jens Axboe | 09a3240 | 2010-08-15 15:01:51 -0400 | [diff] [blame] | 15 | #ifdef ARCH_HAVE_CPU_CLOCK |
Jens Axboe | c223da8 | 2010-03-24 13:23:53 +0100 | [diff] [blame] | 16 | static unsigned long cycles_per_usec; |
Jens Axboe | c223da8 | 2010-03-24 13:23:53 +0100 | [diff] [blame] | 17 | static unsigned long last_cycles; |
Jens Axboe | fa80fea | 2012-12-09 20:29:00 +0100 | [diff] [blame] | 18 | int tsc_reliable = 0; |
Jens Axboe | 09a3240 | 2010-08-15 15:01:51 -0400 | [diff] [blame] | 19 | #endif |
| 20 | static struct timeval last_tv; |
Jens Axboe | 3e48892 | 2008-11-13 12:07:20 +0100 | [diff] [blame] | 21 | static int last_tv_valid; |
Jens Axboe | 02bcaa8 | 2006-11-24 10:42:00 +0100 | [diff] [blame] | 22 | |
Bruce Cran | 16de1bf | 2012-02-20 17:07:32 +0000 | [diff] [blame] | 23 | enum fio_cs fio_clock_source = FIO_PREFERRED_CLOCK_SOURCE; |
Jens Axboe | fa80fea | 2012-12-09 20:29:00 +0100 | [diff] [blame] | 24 | int fio_clock_source_set = 0; |
Jens Axboe | c223da8 | 2010-03-24 13:23:53 +0100 | [diff] [blame] | 25 | |
Jens Axboe | 02bcaa8 | 2006-11-24 10:42:00 +0100 | [diff] [blame] | 26 | #ifdef FIO_DEBUG_TIME |
| 27 | |
| 28 | #define HASH_BITS 8 |
| 29 | #define HASH_SIZE (1 << HASH_BITS) |
| 30 | |
Jens Axboe | 01743ee | 2008-06-02 12:19:19 +0200 | [diff] [blame] | 31 | static struct flist_head hash[HASH_SIZE]; |
Jens Axboe | 02bcaa8 | 2006-11-24 10:42:00 +0100 | [diff] [blame] | 32 | static int gtod_inited; |
| 33 | |
| 34 | struct gtod_log { |
Jens Axboe | 01743ee | 2008-06-02 12:19:19 +0200 | [diff] [blame] | 35 | struct flist_head list; |
Jens Axboe | 02bcaa8 | 2006-11-24 10:42:00 +0100 | [diff] [blame] | 36 | void *caller; |
| 37 | unsigned long calls; |
| 38 | }; |
| 39 | |
| 40 | static struct gtod_log *find_hash(void *caller) |
| 41 | { |
| 42 | unsigned long h = hash_ptr(caller, HASH_BITS); |
Jens Axboe | 01743ee | 2008-06-02 12:19:19 +0200 | [diff] [blame] | 43 | struct flist_head *entry; |
Jens Axboe | 02bcaa8 | 2006-11-24 10:42:00 +0100 | [diff] [blame] | 44 | |
Jens Axboe | 01743ee | 2008-06-02 12:19:19 +0200 | [diff] [blame] | 45 | flist_for_each(entry, &hash[h]) { |
| 46 | struct gtod_log *log = flist_entry(entry, struct gtod_log, |
| 47 | list); |
Jens Axboe | 02bcaa8 | 2006-11-24 10:42:00 +0100 | [diff] [blame] | 48 | |
| 49 | if (log->caller == caller) |
| 50 | return log; |
| 51 | } |
| 52 | |
| 53 | return NULL; |
| 54 | } |
| 55 | |
| 56 | static struct gtod_log *find_log(void *caller) |
| 57 | { |
| 58 | struct gtod_log *log = find_hash(caller); |
| 59 | |
| 60 | if (!log) { |
| 61 | unsigned long h; |
| 62 | |
| 63 | log = malloc(sizeof(*log)); |
Jens Axboe | 01743ee | 2008-06-02 12:19:19 +0200 | [diff] [blame] | 64 | INIT_FLIST_HEAD(&log->list); |
Jens Axboe | 02bcaa8 | 2006-11-24 10:42:00 +0100 | [diff] [blame] | 65 | log->caller = caller; |
| 66 | log->calls = 0; |
| 67 | |
| 68 | h = hash_ptr(caller, HASH_BITS); |
Jens Axboe | 01743ee | 2008-06-02 12:19:19 +0200 | [diff] [blame] | 69 | flist_add_tail(&log->list, &hash[h]); |
Jens Axboe | 02bcaa8 | 2006-11-24 10:42:00 +0100 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | return log; |
| 73 | } |
| 74 | |
| 75 | static void gtod_log_caller(void *caller) |
| 76 | { |
| 77 | if (gtod_inited) { |
| 78 | struct gtod_log *log = find_log(caller); |
| 79 | |
| 80 | log->calls++; |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | static void fio_exit fio_dump_gtod(void) |
| 85 | { |
| 86 | unsigned long total_calls = 0; |
| 87 | int i; |
| 88 | |
| 89 | for (i = 0; i < HASH_SIZE; i++) { |
Jens Axboe | 01743ee | 2008-06-02 12:19:19 +0200 | [diff] [blame] | 90 | struct flist_head *entry; |
Jens Axboe | 02bcaa8 | 2006-11-24 10:42:00 +0100 | [diff] [blame] | 91 | struct gtod_log *log; |
| 92 | |
Jens Axboe | 01743ee | 2008-06-02 12:19:19 +0200 | [diff] [blame] | 93 | flist_for_each(entry, &hash[i]) { |
| 94 | log = flist_entry(entry, struct gtod_log, list); |
Jens Axboe | 02bcaa8 | 2006-11-24 10:42:00 +0100 | [diff] [blame] | 95 | |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 96 | printf("function %p, calls %lu\n", log->caller, |
| 97 | log->calls); |
Jens Axboe | 02bcaa8 | 2006-11-24 10:42:00 +0100 | [diff] [blame] | 98 | total_calls += log->calls; |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | printf("Total %lu gettimeofday\n", total_calls); |
| 103 | } |
| 104 | |
| 105 | static void fio_init gtod_init(void) |
| 106 | { |
| 107 | int i; |
| 108 | |
| 109 | for (i = 0; i < HASH_SIZE; i++) |
Jens Axboe | 01743ee | 2008-06-02 12:19:19 +0200 | [diff] [blame] | 110 | INIT_FLIST_HEAD(&hash[i]); |
Jens Axboe | 02bcaa8 | 2006-11-24 10:42:00 +0100 | [diff] [blame] | 111 | |
| 112 | gtod_inited = 1; |
| 113 | } |
| 114 | |
| 115 | #endif /* FIO_DEBUG_TIME */ |
| 116 | |
Jens Axboe | 1e97cce | 2006-12-05 11:44:16 +0100 | [diff] [blame] | 117 | #ifdef FIO_DEBUG_TIME |
Jens Axboe | 02bcaa8 | 2006-11-24 10:42:00 +0100 | [diff] [blame] | 118 | void fio_gettime(struct timeval *tp, void *caller) |
Jens Axboe | 1e97cce | 2006-12-05 11:44:16 +0100 | [diff] [blame] | 119 | #else |
| 120 | void fio_gettime(struct timeval *tp, void fio_unused *caller) |
| 121 | #endif |
Jens Axboe | 02bcaa8 | 2006-11-24 10:42:00 +0100 | [diff] [blame] | 122 | { |
| 123 | #ifdef FIO_DEBUG_TIME |
| 124 | if (!caller) |
| 125 | caller = __builtin_return_address(0); |
| 126 | |
| 127 | gtod_log_caller(caller); |
Jens Axboe | 02bcaa8 | 2006-11-24 10:42:00 +0100 | [diff] [blame] | 128 | #endif |
Jens Axboe | be4ecfd | 2008-12-08 14:10:52 +0100 | [diff] [blame] | 129 | if (fio_tv) { |
| 130 | memcpy(tp, fio_tv, sizeof(*tp)); |
| 131 | return; |
Jens Axboe | c223da8 | 2010-03-24 13:23:53 +0100 | [diff] [blame] | 132 | } |
| 133 | |
| 134 | switch (fio_clock_source) { |
| 135 | case CS_GTOD: |
Jens Axboe | 02bcaa8 | 2006-11-24 10:42:00 +0100 | [diff] [blame] | 136 | gettimeofday(tp, NULL); |
Jens Axboe | c223da8 | 2010-03-24 13:23:53 +0100 | [diff] [blame] | 137 | break; |
| 138 | case CS_CGETTIME: { |
Jens Axboe | 02bcaa8 | 2006-11-24 10:42:00 +0100 | [diff] [blame] | 139 | struct timespec ts; |
| 140 | |
Jens Axboe | 5bd9c78 | 2012-02-03 12:48:16 +0100 | [diff] [blame] | 141 | #ifdef FIO_HAVE_CLOCK_MONOTONIC |
| 142 | if (clock_gettime(CLOCK_MONOTONIC, &ts) < 0) { |
| 143 | #else |
Jens Axboe | d481e00 | 2009-12-04 09:56:32 +0100 | [diff] [blame] | 144 | if (clock_gettime(CLOCK_REALTIME, &ts) < 0) { |
Jens Axboe | 5bd9c78 | 2012-02-03 12:48:16 +0100 | [diff] [blame] | 145 | #endif |
Jens Axboe | c223da8 | 2010-03-24 13:23:53 +0100 | [diff] [blame] | 146 | log_err("fio: clock_gettime fails\n"); |
| 147 | assert(0); |
Jens Axboe | 02bcaa8 | 2006-11-24 10:42:00 +0100 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | tp->tv_sec = ts.tv_sec; |
| 151 | tp->tv_usec = ts.tv_nsec / 1000; |
Jens Axboe | c223da8 | 2010-03-24 13:23:53 +0100 | [diff] [blame] | 152 | break; |
| 153 | } |
| 154 | #ifdef ARCH_HAVE_CPU_CLOCK |
| 155 | case CS_CPUCLOCK: { |
| 156 | unsigned long long usecs, t; |
| 157 | |
| 158 | t = get_cpu_clock(); |
| 159 | if (t < last_cycles) { |
| 160 | dprint(FD_TIME, "CPU clock going back in time\n"); |
| 161 | t = last_cycles; |
| 162 | } |
| 163 | |
| 164 | usecs = t / cycles_per_usec; |
| 165 | tp->tv_sec = usecs / 1000000; |
| 166 | tp->tv_usec = usecs % 1000000; |
| 167 | last_cycles = t; |
| 168 | break; |
| 169 | } |
| 170 | #endif |
| 171 | default: |
| 172 | log_err("fio: invalid clock source %d\n", fio_clock_source); |
| 173 | break; |
Jens Axboe | 02bcaa8 | 2006-11-24 10:42:00 +0100 | [diff] [blame] | 174 | } |
Jens Axboe | 3e48892 | 2008-11-13 12:07:20 +0100 | [diff] [blame] | 175 | |
| 176 | /* |
| 177 | * If Linux is using the tsc clock on non-synced processors, |
| 178 | * sometimes time can appear to drift backwards. Fix that up. |
| 179 | */ |
| 180 | if (last_tv_valid) { |
| 181 | if (tp->tv_sec < last_tv.tv_sec) |
| 182 | tp->tv_sec = last_tv.tv_sec; |
| 183 | else if (last_tv.tv_sec == tp->tv_sec && |
| 184 | tp->tv_usec < last_tv.tv_usec) |
| 185 | tp->tv_usec = last_tv.tv_usec; |
| 186 | } |
| 187 | last_tv_valid = 1; |
| 188 | memcpy(&last_tv, tp, sizeof(*tp)); |
Jens Axboe | 02bcaa8 | 2006-11-24 10:42:00 +0100 | [diff] [blame] | 189 | } |
Jens Axboe | be4ecfd | 2008-12-08 14:10:52 +0100 | [diff] [blame] | 190 | |
Jens Axboe | 09a3240 | 2010-08-15 15:01:51 -0400 | [diff] [blame] | 191 | #ifdef ARCH_HAVE_CPU_CLOCK |
Jens Axboe | c223da8 | 2010-03-24 13:23:53 +0100 | [diff] [blame] | 192 | static unsigned long get_cycles_per_usec(void) |
| 193 | { |
| 194 | struct timeval s, e; |
| 195 | unsigned long long c_s, c_e; |
| 196 | |
| 197 | gettimeofday(&s, NULL); |
| 198 | c_s = get_cpu_clock(); |
| 199 | do { |
| 200 | unsigned long long elapsed; |
| 201 | |
| 202 | gettimeofday(&e, NULL); |
| 203 | elapsed = utime_since(&s, &e); |
Jens Axboe | 486332e | 2012-12-10 08:07:14 +0100 | [diff] [blame^] | 204 | if (elapsed >= 1280) { |
Jens Axboe | c223da8 | 2010-03-24 13:23:53 +0100 | [diff] [blame] | 205 | c_e = get_cpu_clock(); |
| 206 | break; |
| 207 | } |
| 208 | } while (1); |
| 209 | |
Jens Axboe | 486332e | 2012-12-10 08:07:14 +0100 | [diff] [blame^] | 210 | return (c_e - c_s) >> 7; |
Jens Axboe | c223da8 | 2010-03-24 13:23:53 +0100 | [diff] [blame] | 211 | } |
| 212 | |
Jens Axboe | fa80fea | 2012-12-09 20:29:00 +0100 | [diff] [blame] | 213 | #define NR_TIME_ITERS 50 |
| 214 | |
Jens Axboe | 09a3240 | 2010-08-15 15:01:51 -0400 | [diff] [blame] | 215 | static void calibrate_cpu_clock(void) |
Jens Axboe | c223da8 | 2010-03-24 13:23:53 +0100 | [diff] [blame] | 216 | { |
| 217 | double delta, mean, S; |
Jens Axboe | fa80fea | 2012-12-09 20:29:00 +0100 | [diff] [blame] | 218 | unsigned long avg, cycles[NR_TIME_ITERS]; |
Jens Axboe | c223da8 | 2010-03-24 13:23:53 +0100 | [diff] [blame] | 219 | int i, samples; |
| 220 | |
Jens Axboe | c223da8 | 2010-03-24 13:23:53 +0100 | [diff] [blame] | 221 | cycles[0] = get_cycles_per_usec(); |
| 222 | S = delta = mean = 0.0; |
Jens Axboe | fa80fea | 2012-12-09 20:29:00 +0100 | [diff] [blame] | 223 | for (i = 0; i < NR_TIME_ITERS; i++) { |
Jens Axboe | c223da8 | 2010-03-24 13:23:53 +0100 | [diff] [blame] | 224 | cycles[i] = get_cycles_per_usec(); |
| 225 | delta = cycles[i] - mean; |
| 226 | if (delta) { |
| 227 | mean += delta / (i + 1.0); |
| 228 | S += delta * (cycles[i] - mean); |
| 229 | } |
| 230 | } |
| 231 | |
Jens Axboe | fa80fea | 2012-12-09 20:29:00 +0100 | [diff] [blame] | 232 | S = sqrt(S / (NR_TIME_ITERS - 1.0)); |
Jens Axboe | c223da8 | 2010-03-24 13:23:53 +0100 | [diff] [blame] | 233 | |
| 234 | samples = avg = 0; |
Jens Axboe | fa80fea | 2012-12-09 20:29:00 +0100 | [diff] [blame] | 235 | for (i = 0; i < NR_TIME_ITERS; i++) { |
Jens Axboe | c223da8 | 2010-03-24 13:23:53 +0100 | [diff] [blame] | 236 | double this = cycles[i]; |
| 237 | |
Bruce Cran | 03e20d6 | 2011-01-02 20:14:54 +0100 | [diff] [blame] | 238 | if ((fmax(this, mean) - fmin(this, mean)) > S) |
Jens Axboe | c223da8 | 2010-03-24 13:23:53 +0100 | [diff] [blame] | 239 | continue; |
| 240 | samples++; |
| 241 | avg += this; |
| 242 | } |
| 243 | |
Jens Axboe | fa80fea | 2012-12-09 20:29:00 +0100 | [diff] [blame] | 244 | S /= (double) NR_TIME_ITERS; |
| 245 | mean /= (double) NR_TIME_ITERS; |
Jens Axboe | c223da8 | 2010-03-24 13:23:53 +0100 | [diff] [blame] | 246 | |
Jens Axboe | fa80fea | 2012-12-09 20:29:00 +0100 | [diff] [blame] | 247 | for (i = 0; i < NR_TIME_ITERS; i++) |
Jens Axboe | c223da8 | 2010-03-24 13:23:53 +0100 | [diff] [blame] | 248 | dprint(FD_TIME, "cycles[%d]=%lu\n", i, cycles[i] / 10); |
| 249 | |
| 250 | avg /= (samples * 10); |
| 251 | dprint(FD_TIME, "avg: %lu\n", avg); |
| 252 | dprint(FD_TIME, "mean=%f, S=%f\n", mean, S); |
| 253 | |
| 254 | cycles_per_usec = avg; |
Jens Axboe | 09a3240 | 2010-08-15 15:01:51 -0400 | [diff] [blame] | 255 | } |
| 256 | #else |
| 257 | static void calibrate_cpu_clock(void) |
| 258 | { |
| 259 | } |
| 260 | #endif |
| 261 | |
| 262 | void fio_clock_init(void) |
| 263 | { |
| 264 | last_tv_valid = 0; |
| 265 | calibrate_cpu_clock(); |
Jens Axboe | fa80fea | 2012-12-09 20:29:00 +0100 | [diff] [blame] | 266 | |
| 267 | /* |
| 268 | * If the arch sets tsc_reliable != 0, then it must be good enough |
| 269 | * to use as THE clock source. For x86 CPUs, this means the TSC |
| 270 | * runs at a constant rate and is synced across CPU cores. |
| 271 | */ |
| 272 | if (tsc_reliable) { |
| 273 | if (!fio_clock_source_set) |
| 274 | fio_clock_source = CS_CPUCLOCK; |
| 275 | } else if (fio_clock_source == CS_CPUCLOCK) |
| 276 | log_info("fio: clocksource=cpu may not be reliable\n"); |
Jens Axboe | c223da8 | 2010-03-24 13:23:53 +0100 | [diff] [blame] | 277 | } |
| 278 | |
Jens Axboe | 39ab7da | 2012-11-06 22:10:43 +0100 | [diff] [blame] | 279 | unsigned long long utime_since(struct timeval *s, struct timeval *e) |
Jens Axboe | be4ecfd | 2008-12-08 14:10:52 +0100 | [diff] [blame] | 280 | { |
Jens Axboe | 39ab7da | 2012-11-06 22:10:43 +0100 | [diff] [blame] | 281 | long sec, usec; |
| 282 | unsigned long long ret; |
Jens Axboe | be4ecfd | 2008-12-08 14:10:52 +0100 | [diff] [blame] | 283 | |
Jens Axboe | 39ab7da | 2012-11-06 22:10:43 +0100 | [diff] [blame] | 284 | sec = e->tv_sec - s->tv_sec; |
| 285 | usec = e->tv_usec - s->tv_usec; |
| 286 | if (sec > 0 && usec < 0) { |
| 287 | sec--; |
| 288 | usec += 1000000; |
| 289 | } |
Jens Axboe | 783a3eb | 2012-02-09 10:27:10 +0100 | [diff] [blame] | 290 | |
| 291 | /* |
Jens Axboe | 39ab7da | 2012-11-06 22:10:43 +0100 | [diff] [blame] | 292 | * time warp bug on some kernels? |
Jens Axboe | 783a3eb | 2012-02-09 10:27:10 +0100 | [diff] [blame] | 293 | */ |
Jens Axboe | 39ab7da | 2012-11-06 22:10:43 +0100 | [diff] [blame] | 294 | if (sec < 0 || (sec == 0 && usec < 0)) |
| 295 | return 0; |
Jens Axboe | 783a3eb | 2012-02-09 10:27:10 +0100 | [diff] [blame] | 296 | |
Jens Axboe | 39ab7da | 2012-11-06 22:10:43 +0100 | [diff] [blame] | 297 | ret = sec * 1000000ULL + usec; |
| 298 | |
| 299 | return ret; |
Jens Axboe | 783a3eb | 2012-02-09 10:27:10 +0100 | [diff] [blame] | 300 | } |
| 301 | |
Jens Axboe | 39ab7da | 2012-11-06 22:10:43 +0100 | [diff] [blame] | 302 | unsigned long long utime_since_now(struct timeval *s) |
Jens Axboe | 783a3eb | 2012-02-09 10:27:10 +0100 | [diff] [blame] | 303 | { |
Jens Axboe | 39ab7da | 2012-11-06 22:10:43 +0100 | [diff] [blame] | 304 | struct timeval t; |
Jens Axboe | 783a3eb | 2012-02-09 10:27:10 +0100 | [diff] [blame] | 305 | |
Jens Axboe | 39ab7da | 2012-11-06 22:10:43 +0100 | [diff] [blame] | 306 | fio_gettime(&t, NULL); |
| 307 | return utime_since(s, &t); |
| 308 | } |
Jens Axboe | 783a3eb | 2012-02-09 10:27:10 +0100 | [diff] [blame] | 309 | |
Jens Axboe | 39ab7da | 2012-11-06 22:10:43 +0100 | [diff] [blame] | 310 | unsigned long mtime_since(struct timeval *s, struct timeval *e) |
| 311 | { |
| 312 | long sec, usec, ret; |
| 313 | |
| 314 | sec = e->tv_sec - s->tv_sec; |
| 315 | usec = e->tv_usec - s->tv_usec; |
| 316 | if (sec > 0 && usec < 0) { |
| 317 | sec--; |
| 318 | usec += 1000000; |
Jens Axboe | 783a3eb | 2012-02-09 10:27:10 +0100 | [diff] [blame] | 319 | } |
| 320 | |
Jens Axboe | 39ab7da | 2012-11-06 22:10:43 +0100 | [diff] [blame] | 321 | if (sec < 0 || (sec == 0 && usec < 0)) |
| 322 | return 0; |
Jens Axboe | 783a3eb | 2012-02-09 10:27:10 +0100 | [diff] [blame] | 323 | |
Jens Axboe | 39ab7da | 2012-11-06 22:10:43 +0100 | [diff] [blame] | 324 | sec *= 1000UL; |
| 325 | usec /= 1000UL; |
| 326 | ret = sec + usec; |
| 327 | |
Jens Axboe | 783a3eb | 2012-02-09 10:27:10 +0100 | [diff] [blame] | 328 | return ret; |
| 329 | } |
Jens Axboe | 39ab7da | 2012-11-06 22:10:43 +0100 | [diff] [blame] | 330 | |
| 331 | unsigned long mtime_since_now(struct timeval *s) |
| 332 | { |
| 333 | struct timeval t; |
| 334 | void *p = __builtin_return_address(0); |
| 335 | |
| 336 | fio_gettime(&t, p); |
| 337 | return mtime_since(s, &t); |
| 338 | } |
| 339 | |
| 340 | unsigned long time_since_now(struct timeval *s) |
| 341 | { |
| 342 | return mtime_since_now(s) / 1000; |
| 343 | } |