utime_since was using a long for its return which overflows when the difference
between times is more than about 35 minutes.
diff --git a/fio.c b/fio.c
index e71537f..e9b27d9 100644
--- a/fio.c
+++ b/fio.c
@@ -787,9 +787,8 @@ static int clear_io_state(struct thread_
*/
static void *thread_main(void *data)
{
- unsigned long long runtime[2];
+ unsigned long long runtime[2], elapsed;
struct thread_data *td = data;
- unsigned long elapsed;
int clear_state;
if (!td->o.use_thread)
diff --git a/fio.h b/fio.h
index 5ca2ad3..2e43473 100644
--- a/fio.h
+++ b/fio.h
@@ -777,8 +777,8 @@ extern void add_agg_sample(unsigned long
/*
* Time functions
*/
-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 *);
diff --git a/gettime.c b/gettime.c
diff --git a/time.c b/time.c
index 4fbc98b..102ba7a 100644
--- a/time.c
+++ b/time.c
@@ -6,30 +6,30 @@ #include "fio.h"
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, ret;
-
+ 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--;
usec += 1000000;
}
-
- sec *= 1000000UL;
- ret = sec + usec;
-
+
/*
* time warp bug on some kernels?
*/
- if (ret < 0)
- ret = 0;
-
+ if (sec < 0 || (sec == 0 && usec < 0))
+ return 0;
+
+ ret = sec * 1000000ULL + usec;
+
return ret;
}
-unsigned long utime_since_now(struct timeval *s)
+unsigned long long utime_since_now(struct timeval *s)
{
struct timeval t;
Received on Wed Nov 21 2007 - 01:07:29 CET
This archive was generated by hypermail 2.2.0 : Wed Nov 21 2007 - 01:30:02 CET