diff options
author | Jens Axboe <jens.axboe@oracle.com> | 2008-05-30 23:18:00 +0200 |
---|---|---|
committer | Jens Axboe <jens.axboe@oracle.com> | 2008-05-30 23:18:00 +0200 |
commit | ccb0fa24f0ff37f9270754ea5a1b66de9fd7053e (patch) | |
tree | 1c10f29e2826af4a388630061cb21f01b4354449 | |
parent | 739097e6e145afb98057846c419c60c2cc2dd9c0 (diff) | |
download | fio-ccb0fa24f0ff37f9270754ea5a1b66de9fd7053e.tar.gz |
Seperate status timer setup from disk util timer
It's still the same timer and shared, but move it out of
diskutil so we get proper status reporting on non-Linux.
We also need to rearm the signal handlers on each signal.
Move this to sigaction() next.
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
-rw-r--r-- | diskutil.c | 8 | ||||
-rw-r--r-- | fio.c | 26 | ||||
-rw-r--r-- | fio.h | 3 |
3 files changed, 22 insertions, 15 deletions
@@ -10,7 +10,6 @@ #include "fio.h" static int last_majdev, last_mindev; -static struct itimerval itimer; static struct list_head disk_list = LIST_HEAD_INIT(disk_list); @@ -317,13 +316,6 @@ void init_disk_util(struct thread_data *td) __init_disk_util(td, f); } -void disk_util_timer_arm(void) -{ - itimer.it_value.tv_sec = 0; - itimer.it_value.tv_usec = DISK_UTIL_MSEC * 1000; - setitimer(ITIMER_REAL, &itimer, NULL); -} - void show_disk_util(void) { struct disk_util_stat *dus; @@ -54,6 +54,7 @@ unsigned long done_secs = 0; static struct fio_mutex *startup_mutex; static volatile int fio_abort; static int exit_value; +static struct itimerval itimer; struct io_log *agg_io_log[2]; @@ -99,16 +100,34 @@ static void terminate_threads(int group_id) } } +static void status_timer_arm(void) +{ + itimer.it_value.tv_sec = 0; + itimer.it_value.tv_usec = DISK_UTIL_MSEC * 1000; + setitimer(ITIMER_REAL, &itimer, NULL); +} + +/* + * We need to rearm on BSD/solaris. Switch this to sigaction in the future... + */ +static void set_sig_handlers(void (*sighandler)(int)) +{ + signal(SIGINT, sighandler); + signal(SIGALRM, sighandler); +} + static void sig_handler(int sig) { + set_sig_handlers(sig_handler); + if (!threads) return; switch (sig) { case SIGALRM: update_io_ticks(); - disk_util_timer_arm(); print_thread_status(); + status_timer_arm(); break; default: printf("\nfio: terminating on signal %d\n", sig); @@ -1137,8 +1156,7 @@ static void run_threads(void) fflush(stdout); } - signal(SIGINT, sig_handler); - signal(SIGALRM, sig_handler); + set_sig_handlers(sig_handler); todo = thread_number; nr_running = 0; @@ -1356,7 +1374,7 @@ int main(int argc, char *argv[]) set_genesis_time(); - disk_util_timer_arm(); + status_timer_arm(); run_threads(); @@ -784,7 +784,6 @@ extern void show_run_stats(void); extern void init_disk_util(struct thread_data *); extern void update_rusage_stat(struct thread_data *); extern void update_io_ticks(void); -extern void disk_util_timer_arm(void); extern void setup_log(struct io_log **); extern void finish_log(struct thread_data *, struct io_log *, const char *); extern void __finish_log(struct io_log *, const char *); @@ -855,12 +854,10 @@ extern void print_status_init(int); */ #ifdef FIO_HAVE_DISK_UTIL extern void show_disk_util(void); -extern void disk_util_timer_arm(void); extern void init_disk_util(struct thread_data *); extern void update_io_ticks(void); #else #define show_disk_util() -#define disk_util_timer_arm() #define init_disk_util(td) #define update_io_ticks() #endif |