X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=fio.c;h=e205b3aa52ac9f9a693fd249c52de1b84f45afb8;hp=e475a36f678673fe809612c588a9f93bf27817e9;hb=2615cc4b28e7d0e436a625dff92e6a71ccc6c49b;hpb=7d9fb455aadc0c0363489591775496f27f4a560a diff --git a/fio.c b/fio.c index e475a36f..e205b3aa 100644 --- a/fio.c +++ b/fio.c @@ -64,8 +64,8 @@ static struct fio_mutex *startup_mutex; static struct fio_mutex *writeout_mutex; static volatile int fio_abort; static int exit_value; -static timer_t ival_timer; static pthread_t gtod_thread; +static pthread_t disk_util_thread; static struct flist_head *cgroup_list; static char *cgroup_mnt; @@ -113,26 +113,6 @@ static void terminate_threads(int group_id) } } -static void status_timer_arm(void) -{ - struct itimerspec value; - - value.it_value.tv_sec = 0; - value.it_value.tv_nsec = DISK_UTIL_MSEC * 1000000; - value.it_interval.tv_sec = 0; - value.it_interval.tv_nsec = DISK_UTIL_MSEC * 1000000; - - timer_settime(ival_timer, 0, &value, NULL); -} - -static void ival_fn(union sigval sig) -{ - if (threads) { - update_io_ticks(); - print_thread_status(); - } -} - /* * Happens on thread runs with ctrl-c, ignore our own SIGQUIT */ @@ -149,22 +129,41 @@ static void sig_int(int sig) } } -static void posix_timer_teardown(void) +static void *disk_thread_main(void *data) { - timer_delete(ival_timer); + fio_mutex_up(startup_mutex); + + while (threads) { + usleep(DISK_UTIL_MSEC * 1000); + if (!threads) + break; + update_io_ticks(); + print_thread_status(); + } + + return NULL; } -static void posix_timer_setup(void) +static int create_disk_util_thread(void) { - struct sigevent evt; + int ret; - memset(&evt, 0, sizeof(evt)); - evt.sigev_notify = SIGEV_THREAD; - evt.sigev_notify_function = ival_fn; + ret = pthread_create(&disk_util_thread, NULL, disk_thread_main, NULL); + if (ret) { + log_err("Can't create disk util thread: %s\n", strerror(ret)); + return 1; + } - if (timer_create(FIO_TIMER_CLOCK, &evt, &ival_timer) < 0) - perror("timer_create"); + ret = pthread_detach(disk_util_thread); + if (ret) { + log_err("Can't detatch disk util thread: %s\n", strerror(ret)); + return 1; + } + dprint(FD_MUTEX, "wait on startup_mutex\n"); + fio_mutex_down(startup_mutex); + dprint(FD_MUTEX, "done waiting on startup_mutex\n"); + return 0; } static void set_sig_handlers(void) @@ -498,7 +497,6 @@ static void do_verify(struct thread_data *td) clear_io_u(td, io_u); } else if (io_u->resid) { int bytes = io_u->xfer_buflen - io_u->resid; - struct fio_file *f = io_u->file; /* * zero read, fail @@ -516,6 +514,7 @@ static void do_verify(struct thread_data *td) if (ddir_rw(io_u->ddir)) td->ts.short_io_u[io_u->ddir]++; + f = io_u->file; if (io_u->offset == f->real_file_size) goto sync_done; @@ -1498,14 +1497,14 @@ static void run_threads(void) todo--; } else { struct fio_file *f; - unsigned int i; + unsigned int j; /* * for sharing to work, each job must always open * its own files. so close them, if we opened them * for creation */ - for_each_file(td, f, i) { + for_each_file(td, f, j) { if (fio_file_open(f)) td_io_close_file(td, f); } @@ -1716,9 +1715,7 @@ int main(int argc, char *argv[]) return 1; set_genesis_time(); - - posix_timer_setup(); - status_timer_arm(); + create_disk_util_thread(); cgroup_list = smalloc(sizeof(*cgroup_list)); INIT_FLIST_HEAD(cgroup_list); @@ -1738,7 +1735,6 @@ int main(int argc, char *argv[]) sfree(cgroup_list); sfree(cgroup_mnt); - posix_timer_teardown(); fio_mutex_remove(startup_mutex); fio_mutex_remove(writeout_mutex); return exit_value;