X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=time.c;h=4af84bc7cc5b6a2e1f0be57f284e3e6c3d57f2c8;hp=ee9d33fa20d1682e6da44f72edf46023587eaee1;hb=ea1fd2e63ed831ae038b2778e1474517bfb15da3;hpb=581e71417760e0aa86eac0acd704253ff0eeea4f diff --git a/time.c b/time.c index ee9d33fa..4af84bc7 100644 --- a/time.c +++ b/time.c @@ -48,16 +48,13 @@ unsigned long mtime_since(struct timeval *s, struct timeval *e) usec += 1000000; } + if (sec < 0 || (sec == 0 && usec < 0)) + return 0; + sec *= 1000UL; usec /= 1000UL; ret = sec + usec; - /* - * time warp bug on some kernels? - */ - if (ret < 0) - ret = 0; - return ret; } @@ -122,30 +119,6 @@ void usec_sleep(struct thread_data *td, unsigned long usec) } while (!td->terminate); } -long rate_throttle(struct thread_data *td, unsigned long time_spent, - unsigned long bytes, enum fio_ddir ddir) -{ - unsigned int bs = td->o.min_bs[ddir]; - unsigned long usec_cycle; - - if (!td->o.rate[ddir] && !td->o.rate_iops[ddir]) - return 0; - - usec_cycle = td->rate_usec_cycle[ddir] * (bytes / bs); - - if (time_spent < usec_cycle) { - unsigned long s = usec_cycle - time_spent; - - td->rate_pending_usleep[ddir] += s; - } else { - long overtime = time_spent - usec_cycle; - - td->rate_pending_usleep[ddir] -= overtime; - } - - return td->rate_pending_usleep[ddir]; -} - unsigned long mtime_since_genesis(void) { return mtime_since_now(&genesis); @@ -174,10 +147,12 @@ int ramp_time_over(struct thread_data *td) return 0; } -static void fio_init time_init(void) +void fio_time_init(void) { int i; + fio_clock_init(); + /* * Check the granularity of the nanosleep function */