X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=backend.c;h=119c4f982fb32e39e2f141fa792dab3e9f6cd290;hb=941bda94;hp=5f862abeead5ba6fc16c82a4112a33e0f32fc7d5;hpb=4896473eb0c69d870c41a6a679765d2d5f03e199;p=fio.git diff --git a/backend.c b/backend.c index 5f862abe..119c4f98 100644 --- a/backend.c +++ b/backend.c @@ -61,14 +61,14 @@ 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[DDIR_RWDIR_CNT]; int groupid = 0; unsigned int thread_number = 0; unsigned int stat_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; @@ -1095,6 +1095,7 @@ static void *thread_main(void *data) struct thread_options *o = &td->o; pthread_condattr_t attr; int clear_state; + int ret; if (!o->use_thread) { setsid(); @@ -1106,6 +1107,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); @@ -1133,6 +1137,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 @@ -1159,7 +1164,8 @@ static void *thread_main(void *data) * allocations. */ if (o->cpumask_set) { - if (fio_setaffinity(td->pid, o->cpumask) == -1) { + ret = fio_setaffinity(td->pid, o->cpumask); + if (ret == -1) { td_verror(td, errno, "cpu_set_affinity"); goto err; } @@ -1224,8 +1230,9 @@ static void *thread_main(void *data) if (o->verify_async && verify_async_init(td)) goto err; - if (td->ioprio_set) { - if (ioprio_set(IOPRIO_WHO_PROCESS, 0, td->ioprio) == -1) { + if (o->ioprio) { + ret = ioprio_set(IOPRIO_WHO_PROCESS, 0, o->ioprio_class, o->ioprio); + if (ret == -1) { td_verror(td, errno, "ioprio_set"); goto err; } @@ -1558,6 +1565,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 (output_format == FIO_OUTPUT_NORMAL) { log_info("Starting "); if (nr_thread) @@ -1763,21 +1778,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); } fio_idle_prof_stop(); @@ -1860,9 +1867,9 @@ int fio_backend(void) return 0; if (write_bw_log) { - setup_log(&agg_io_log[DDIR_READ], 0); - setup_log(&agg_io_log[DDIR_WRITE], 0); - setup_log(&agg_io_log[DDIR_TRIM], 0); + setup_log(&agg_io_log[DDIR_READ], 0, IO_LOG_TYPE_BW); + setup_log(&agg_io_log[DDIR_WRITE], 0, IO_LOG_TYPE_BW); + setup_log(&agg_io_log[DDIR_TRIM], 0, IO_LOG_TYPE_BW); } startup_mutex = fio_mutex_init(FIO_MUTEX_LOCKED);