projects
/
fio.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
stats: Add hint information to per priority level stats
[fio.git]
/
time.c
diff --git
a/time.c
b/time.c
index edfe779bc2423876e949be48b11fb3ed354af986..5c4d6de0399c5cc681e9ca362c019870baf9db98 100644
(file)
--- a/
time.c
+++ b/
time.c
@@
-8,17
+8,17
@@
static unsigned long ns_granularity;
void timespec_add_msec(struct timespec *ts, unsigned int msec)
{
void timespec_add_msec(struct timespec *ts, unsigned int msec)
{
- u
nsigned long adj_nsec = 1000000
* msec;
+ u
int64_t adj_nsec = 1000000ULL
* msec;
ts->tv_nsec += adj_nsec;
if (adj_nsec >= 1000000000) {
ts->tv_nsec += adj_nsec;
if (adj_nsec >= 1000000000) {
- u
nsigned long adj_sec = adj_nsec / 1000000000UL
;
+ u
int64_t adj_sec = adj_nsec / 1000000000
;
- ts->tv_nsec -=
adj_sec * 1000000000UL
;
+ ts->tv_nsec -=
adj_sec * 1000000000
;
ts->tv_sec += adj_sec;
}
ts->tv_sec += adj_sec;
}
- if (ts->tv_nsec >= 1000000000
UL
){
- ts->tv_nsec -= 1000000000
UL
;
+ if (ts->tv_nsec >= 1000000000){
+ ts->tv_nsec -= 1000000000;
ts->tv_sec++;
}
}
ts->tv_sec++;
}
}
@@
-57,6
+57,13
@@
uint64_t usec_sleep(struct thread_data *td, unsigned long usec)
if (ts >= 1000000) {
req.tv_sec = ts / 1000000;
ts -= 1000000 * req.tv_sec;
if (ts >= 1000000) {
req.tv_sec = ts / 1000000;
ts -= 1000000 * req.tv_sec;
+ /*
+ * Limit sleep to ~1 second at most, otherwise we
+ * don't notice then someone signaled the job to
+ * exit manually.
+ */
+ if (req.tv_sec > 1)
+ req.tv_sec = 1;
} else
req.tv_sec = 0;
} else
req.tv_sec = 0;
@@
-97,16
+104,17
@@
bool in_ramp_time(struct thread_data *td)
return td->o.ramp_time && !td->ramp_time_over;
}
return td->o.ramp_time && !td->ramp_time_over;
}
-static
void
parent_update_ramp(struct thread_data *td)
+static
bool
parent_update_ramp(struct thread_data *td)
{
struct thread_data *parent = td->parent;
if (!parent || parent->ramp_time_over)
{
struct thread_data *parent = td->parent;
if (!parent || parent->ramp_time_over)
- return;
+ return
false
;
reset_all_stats(parent);
reset_all_stats(parent);
- parent->ramp_time_over =
1
;
+ parent->ramp_time_over =
true
;
td_set_runstate(parent, TD_RAMP);
td_set_runstate(parent, TD_RAMP);
+ return true;
}
bool ramp_time_over(struct thread_data *td)
}
bool ramp_time_over(struct thread_data *td)
@@
-115,10
+123,19
@@
bool ramp_time_over(struct thread_data *td)
return true;
if (utime_since_now(&td->epoch) >= td->o.ramp_time) {
return true;
if (utime_since_now(&td->epoch) >= td->o.ramp_time) {
- td->ramp_time_over =
1
;
+ td->ramp_time_over =
true
;
reset_all_stats(td);
reset_all_stats(td);
+ reset_io_stats(td);
td_set_runstate(td, TD_RAMP);
td_set_runstate(td, TD_RAMP);
- parent_update_ramp(td);
+
+ /*
+ * If we have a parent, the parent isn't doing IO. Hence
+ * the parent never enters do_io(), which will switch us
+ * from RAMP -> RUNNING. Do this manually here.
+ */
+ if (parent_update_ramp(td))
+ td_set_runstate(td, TD_RUNNING);
+
return true;
}
return true;
}
@@
-155,14
+172,14
@@
void set_genesis_time(void)
fio_gettime(&genesis, NULL);
}
fio_gettime(&genesis, NULL);
}
-void set_epoch_time(struct thread_data *td, int log_
unix_epoch
)
+void set_epoch_time(struct thread_data *td, int log_
alternate_epoch, clockid_t clock_id
)
{
fio_gettime(&td->epoch, NULL);
{
fio_gettime(&td->epoch, NULL);
- if (log_
unix
_epoch) {
- struct time
val tv
;
-
gettimeofday(&tv, NULL
);
- td->
unix_epoch = (unsigned long long)(tv
.tv_sec) * 1000 +
- (unsigned long long)(t
v.tv_usec) / 1
000;
+ if (log_
alternate
_epoch) {
+ struct time
spec ts
;
+
clock_gettime(clock_id, &ts
);
+ td->
alternate_epoch = (unsigned long long)(ts
.tv_sec) * 1000 +
+ (unsigned long long)(t
s.tv_nsec) / 1000
000;
}
}
}
}