projects
/
fio.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
docs: serialize_overlap=1 with io_submit_mode=offload no longer requires threads
[fio.git]
/
backend.c
diff --git
a/backend.c
b/backend.c
index bb8bd13bd11f973e616fd3897483e27ec833cbc5..d6450baf1efdef1da5945445e7f9325c2e7f0efd 100644
(file)
--- a/
backend.c
+++ b/
backend.c
@@
-29,6
+29,7
@@
#include <sys/stat.h>
#include <sys/wait.h>
#include <math.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <math.h>
+#include <pthread.h>
#include "fio.h"
#include "smalloc.h"
#include "fio.h"
#include "smalloc.h"
@@
-53,7
+54,7
@@
static struct fio_sem *startup_sem;
static struct flist_head *cgroup_list;
static struct cgroup_mnt *cgroup_mnt;
static int exit_value;
static struct flist_head *cgroup_list;
static struct cgroup_mnt *cgroup_mnt;
static int exit_value;
-static volatile
int
fio_abort;
+static volatile
bool
fio_abort;
static unsigned int nr_process = 0;
static unsigned int nr_thread = 0;
static unsigned int nr_process = 0;
static unsigned int nr_thread = 0;
@@
-65,6
+66,7
@@
unsigned int stat_number = 0;
int shm_id = 0;
int temp_stall_ts;
unsigned long done_secs = 0;
int shm_id = 0;
int temp_stall_ts;
unsigned long done_secs = 0;
+pthread_mutex_t overlap_check = PTHREAD_MUTEX_INITIALIZER;
#define JOB_START_TIMEOUT (5 * 1000)
#define JOB_START_TIMEOUT (5 * 1000)
@@
-567,7
+569,7
@@
static int unlink_all_files(struct thread_data *td)
/*
* Check if io_u will overlap an in-flight IO in the queue
*/
/*
* Check if io_u will overlap an in-flight IO in the queue
*/
-
static
bool in_flight_overlap(struct io_u_queue *q, struct io_u *io_u)
+bool in_flight_overlap(struct io_u_queue *q, struct io_u *io_u)
{
bool overlap;
struct io_u *check_io_u;
{
bool overlap;
struct io_u *check_io_u;
@@
-1187,14
+1189,14
@@
static void cleanup_io_u(struct thread_data *td)
if (td->io_ops->io_u_free)
td->io_ops->io_u_free(td, io_u);
if (td->io_ops->io_u_free)
td->io_ops->io_u_free(td, io_u);
- fio_memfree(io_u, sizeof(*io_u));
+ fio_memfree(io_u, sizeof(*io_u)
, td_offload_overlap(td)
);
}
free_io_mem(td);
io_u_rexit(&td->io_u_requeues);
}
free_io_mem(td);
io_u_rexit(&td->io_u_requeues);
- io_u_qexit(&td->io_u_freelist);
- io_u_qexit(&td->io_u_all);
+ io_u_qexit(&td->io_u_freelist
, false
);
+ io_u_qexit(&td->io_u_all
, td_offload_overlap(td)
);
free_file_completion_logging(td);
}
free_file_completion_logging(td);
}
@@
-1209,8
+1211,8
@@
static int init_io_u(struct thread_data *td)
err = 0;
err += !io_u_rinit(&td->io_u_requeues, td->o.iodepth);
err = 0;
err += !io_u_rinit(&td->io_u_requeues, td->o.iodepth);
- err += !io_u_qinit(&td->io_u_freelist, td->o.iodepth);
- err += !io_u_qinit(&td->io_u_all, td->o.iodepth);
+ err += !io_u_qinit(&td->io_u_freelist, td->o.iodepth
, false
);
+ err += !io_u_qinit(&td->io_u_all, td->o.iodepth
, td_offload_overlap(td)
);
if (err) {
log_err("fio: failed setting up IO queues\n");
if (err) {
log_err("fio: failed setting up IO queues\n");
@@
-1225,7
+1227,7
@@
static int init_io_u(struct thread_data *td)
if (td->terminate)
return 1;
if (td->terminate)
return 1;
- ptr = fio_memalign(cl_align, sizeof(*io_u));
+ ptr = fio_memalign(cl_align, sizeof(*io_u)
, td_offload_overlap(td)
);
if (!ptr) {
log_err("fio: unable to allocate aligned memory\n");
break;
if (!ptr) {
log_err("fio: unable to allocate aligned memory\n");
break;
@@
-1872,7
+1874,16
@@
static void *thread_main(void *data)
"perhaps try --debug=io option for details?\n",
td->o.name, td->io_ops->name);
"perhaps try --debug=io option for details?\n",
td->o.name, td->io_ops->name);
+ /*
+ * Acquire this lock if we were doing overlap checking in
+ * offload mode so that we don't clean up this job while
+ * another thread is checking its io_u's for overlap
+ */
+ if (td_offload_overlap(td))
+ pthread_mutex_lock(&overlap_check);
td_set_runstate(td, TD_FINISHING);
td_set_runstate(td, TD_FINISHING);
+ if (td_offload_overlap(td))
+ pthread_mutex_unlock(&overlap_check);
update_rusage_stat(td);
td->ts.total_run_time = mtime_since_now(&td->epoch);
update_rusage_stat(td);
td->ts.total_run_time = mtime_since_now(&td->epoch);
@@
-2371,7
+2382,7
@@
reap:
if (fio_sem_down_timeout(startup_sem, 10000)) {
log_err("fio: job startup hung? exiting.\n");
fio_terminate_threads(TERMINATE_ALL);
if (fio_sem_down_timeout(startup_sem, 10000)) {
log_err("fio: job startup hung? exiting.\n");
fio_terminate_threads(TERMINATE_ALL);
- fio_abort =
1
;
+ fio_abort =
true
;
nr_started--;
free(fd);
break;
nr_started--;
free(fd);
break;