diff options
author | Jens Axboe <axboe@fb.com> | 2014-10-23 23:04:37 -0600 |
---|---|---|
committer | Mohamad Ayyash <mkayyash@google.com> | 2015-03-06 17:57:25 -0800 |
commit | 04247864f004c0a20ceb9fb0c0ce3c3a3c512326 (patch) | |
tree | dfa4faa39595b332c4f91747ab443dbf9b431189 | |
parent | fdb0da8028e156c0da43aca18e1423d1b300bdad (diff) | |
download | fio-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.c | 15 | ||||
-rw-r--r-- | stat.c | 2 |
2 files changed, 13 insertions, 4 deletions
@@ -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); @@ -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); |