utime_since was using a long for its return which overflows when the difference
between times is more than about 35 minutes.
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
*/
static void *thread_main(void *data)
{
*/
static void *thread_main(void *data)
{
- unsigned long long runtime[2];
+ unsigned long long runtime[2], elapsed;
struct thread_data *td = data;
struct thread_data *td = data;
int clear_state;
if (!td->o.use_thread)
int clear_state;
if (!td->o.use_thread)
-extern unsigned long utime_since(struct timeval *, struct timeval *);
-extern unsigned long utime_since_now(struct timeval *);
+extern unsigned long long utime_since(struct timeval *, struct timeval *);
+extern unsigned long long utime_since_now(struct timeval *);
extern unsigned long mtime_since(struct timeval *, struct timeval *);
extern unsigned long mtime_since_now(struct timeval *);
extern unsigned long time_since_now(struct timeval *);
extern unsigned long mtime_since(struct timeval *, struct timeval *);
extern unsigned long mtime_since_now(struct timeval *);
extern unsigned long time_since_now(struct timeval *);
static struct timeval genesis;
static unsigned long ns_granularity;
static struct timeval genesis;
static unsigned long ns_granularity;
-unsigned long utime_since(struct timeval *s, struct timeval *e)
+unsigned long long utime_since(struct timeval *s, struct timeval *e)
+ long sec, usec;
+ unsigned long long ret;
+
sec = e->tv_sec - s->tv_sec;
usec = e->tv_usec - s->tv_usec;
if (sec > 0 && usec < 0) {
sec = e->tv_sec - s->tv_sec;
usec = e->tv_usec - s->tv_usec;
if (sec > 0 && usec < 0) {
- sec *= 1000000UL;
- ret = sec + usec;
-
/*
* time warp bug on some kernels?
*/
/*
* time warp bug on some kernels?
*/
- if (ret < 0)
- ret = 0;
-
+ if (sec < 0 || (sec == 0 && usec < 0))
+ return 0;
+
+ ret = sec * 1000000ULL + usec;
+
-unsigned long utime_since_now(struct timeval *s)
+unsigned long long utime_since_now(struct timeval *s)