summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@fb.com>2014-10-23 23:04:37 -0600
committerMohamad Ayyash <mkayyash@google.com>2015-03-06 17:57:25 -0800
commit04247864f004c0a20ceb9fb0c0ce3c3a3c512326 (patch)
treedfa4faa39595b332c4f91747ab443dbf9b431189
parentfdb0da8028e156c0da43aca18e1423d1b300bdad (diff)
downloadfio-04247864f004c0a20ceb9fb0c0ce3c3a3c512326.tar.gz
stat: avoid hang with race in stat thread exit and rusage update
Signed-off-by: Jens Axboe <axboe@fb.com>
-rw-r--r--backend.c15
-rw-r--r--stat.c2
2 files changed, 13 insertions, 4 deletions
diff --git a/backend.c b/backend.c
index 4437d196..90d998dc 100644
--- a/backend.c
+++ b/backend.c
@@ -1564,13 +1564,17 @@ err:
if (o->write_iolog_file)
write_iolog_close(td);
- fio_mutex_remove(td->rusage_sem);
- td->rusage_sem = NULL;
-
fio_mutex_remove(td->mutex);
td->mutex = NULL;
td_set_runstate(td, TD_EXITED);
+
+ /*
+ * Do this last after setting our runstate to exited, so we
+ * know that the stat thread is signaled.
+ */
+ check_update_rusage(td);
+
return (void *) (uintptr_t) td->error;
}
@@ -2097,8 +2101,11 @@ int fio_backend(void)
}
}
- for_each_td(td, i)
+ for_each_td(td, i) {
fio_options_free(td);
+ fio_mutex_remove(td->rusage_sem);
+ td->rusage_sem = NULL;
+ }
free_disk_util();
cgroup_kill(cgroup_list);
diff --git a/stat.c b/stat.c
index a5fd50b9..3aae76df 100644
--- a/stat.c
+++ b/stat.c
@@ -1451,6 +1451,8 @@ static void __show_running_run_stats(void)
}
for_each_td(td, i) {
+ if (td->runstate >= TD_EXITED)
+ continue;
if (td->rusage_sem) {
td->update_rusage = 1;
fio_mutex_down(td->rusage_sem);