X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=backend.c;h=1f5f3c7f567967ab2f0d662eb6ab9845fadd9515;hp=7149c115e06163537c3417b4c398d05d1941cdb1;hb=41666588eed4ed830b1fabd0458eb2b0a93f0147;hpb=ea51b956a15dd4aee047233be892bb3607f3adbd diff --git a/backend.c b/backend.c index 7149c115..1f5f3c7f 100644 --- a/backend.c +++ b/backend.c @@ -56,13 +56,13 @@ static struct flist_head *cgroup_list; static char *cgroup_mnt; static int exit_value; static volatile int fio_abort; +static unsigned int nr_process = 0; +static unsigned int nr_thread = 0; struct io_log *agg_io_log[2]; int groupid = 0; unsigned int thread_number = 0; -unsigned int nr_process = 0; -unsigned int nr_thread = 0; int shm_id = 0; int temp_stall_ts; unsigned long done_secs = 0; @@ -494,7 +494,10 @@ sync_done: if (full || !td->o.iodepth_batch_complete) { min_events = min(td->o.iodepth_batch_complete, td->cur_depth); - if (full && !min_events && td->o.iodepth_batch_complete != 0) + /* + * if the queue is full, we MUST reap at least 1 event + */ + if (full && !min_events) min_events = 1; do { @@ -555,7 +558,8 @@ static void do_io(struct thread_data *td) td_set_runstate(td, TD_RUNNING); while ((td->o.read_iolog_file && !flist_empty(&td->io_log_list)) || - (!flist_empty(&td->trim_list)) || !io_bytes_exceeded(td)) { + (!flist_empty(&td->trim_list)) || !io_bytes_exceeded(td) || + td->o.time_based) { struct timeval comp_time; unsigned long bytes_done[2] = { 0, 0 }; int min_evts = 0; @@ -676,7 +680,10 @@ sync_done: if (full || !td->o.iodepth_batch_complete) { min_evts = min(td->o.iodepth_batch_complete, td->cur_depth); - if (full && !min_evts && td->o.iodepth_batch_complete != 0) + /* + * if the queue is full, we MUST reap at least 1 event + */ + if (full && !min_evts) min_evts = 1; if (__should_check_rate(td, 0) || @@ -962,6 +969,9 @@ static void *thread_main(void *data) dprint(FD_PROCESS, "jobs pid=%d started\n", (int) td->pid); + if (is_backend) + fio_server_send_start(td); + INIT_FLIST_HEAD(&td->io_u_freelist); INIT_FLIST_HEAD(&td->io_u_busylist); INIT_FLIST_HEAD(&td->io_u_requeues); @@ -988,6 +998,7 @@ static void *thread_main(void *data) * eating a file descriptor */ fio_mutex_remove(td->mutex); + td->mutex = NULL; /* * A new gid requires privilege, so we need to do this before setting @@ -1349,6 +1360,14 @@ static void run_threads(void) set_sig_handlers(); + nr_thread = nr_process = 0; + for_each_td(td, i) { + if (td->o.use_thread) + nr_thread++; + else + nr_process++; + } + if (!terse_output) { log_info("Starting "); if (nr_thread) @@ -1548,21 +1567,13 @@ static void run_threads(void) reap_threads(&nr_running, &t_rate, &m_rate); - if (todo) { - if (is_backend) - fio_server_idle_loop(); - else - usleep(100000); - } + if (todo) + usleep(100000); } while (nr_running) { reap_threads(&nr_running, &t_rate, &m_rate); - - if (is_backend) - fio_server_idle_loop(); - else - usleep(10000); + usleep(10000); } update_io_ticks();