summaryrefslogtreecommitdiff
path: root/io_u.c
diff options
context:
space:
mode:
authorBart Van Assche <bart.vanassche@wdc.com>2018-03-16 08:38:34 -0700
committerBart Van Assche <bart.vanassche@wdc.com>2018-03-16 12:46:05 -0700
commit564de8d10188bc855343f915ca9fdbbf9c722465 (patch)
treeeefc344dfdc0512dd75047a17bbb9986a1dedb9b /io_u.c
parent93b45bb2e4c511f2d9a9a7552d74e1d921b0bf76 (diff)
downloadfio-564de8d10188bc855343f915ca9fdbbf9c722465.tar.gz
fio-564de8d10188bc855343f915ca9fdbbf9c722465.tar.bz2
Signal td->free_cond with the associated mutex held
Calling pthread_cond_signal() or pthread_cond_broadcast() without holding the associated mutex can lead to missed wakeups. Hence ensure that td->io_u_lock is held around pthread_cond_signal(&td->free_cond) calls. A quote from the POSIX spec (http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_cond_broadcast.html): "The pthread_cond_broadcast() or pthread_cond_signal() functions may be called by a thread whether or not it currently owns the mutex that threads calling pthread_cond_wait() or pthread_cond_timedwait() have associated with the condition variable during their waits; however, if predictable scheduling behavior is required, then that mutex shall be locked by the thread calling pthread_cond_broadcast() or pthread_cond_signal()." Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Diffstat (limited to 'io_u.c')
-rw-r--r--io_u.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/io_u.c b/io_u.c
index 84d93155..f3b59322 100644
--- a/io_u.c
+++ b/io_u.c
@@ -856,8 +856,8 @@ void put_io_u(struct thread_data *td, struct io_u *io_u)
assert(!(td->flags & TD_F_CHILD));
}
io_u_qpush(&td->io_u_freelist, io_u);
- td_io_u_unlock(td);
td_io_u_free_notify(td);
+ td_io_u_unlock(td);
}
void clear_io_u(struct thread_data *td, struct io_u *io_u)
@@ -889,8 +889,8 @@ void requeue_io_u(struct thread_data *td, struct io_u **io_u)
}
io_u_rpush(&td->io_u_requeues, __io_u);
- td_io_u_unlock(td);
td_io_u_free_notify(td);
+ td_io_u_unlock(td);
*io_u = NULL;
}