The following changes since commit 50206d9b89b6649d782e988df52438e7984707af: configure: check for v2 of libnuma (2013-03-25 13:20:08 -0600) are available in the git repository at: git://git.kernel.dk/fio.git master Jens Axboe (2): Fix build if just one of libverbs or librdma is installed Fix usr/sys/ctx/majf/minf for -USR1 usage Shaohua Li (1): mutex: set pshared attributes on rw semaphore backend.c | 24 ++++++++++++++++++++++++ configure | 2 +- fio.h | 2 ++ mutex.c | 20 +++++++++++++++++++- stat.c | 10 +++++++++- 5 files changed, 55 insertions(+), 3 deletions(-) --- Diff of recent changes: diff --git a/backend.c b/backend.c index ae4216d..fcb74dc 100644 --- a/backend.c +++ b/backend.c @@ -406,6 +406,15 @@ static int break_on_this_error(struct thread_data *td, enum fio_ddir ddir, return 0; } +static void check_update_rusage(struct thread_data *td) +{ + if (td->update_rusage) { + td->update_rusage = 0; + update_rusage_stat(td); + fio_mutex_up(td->rusage_sem); + } +} + /* * The main verify engine. Runs over the writes we previously submitted, * reads the blocks back in, and checks the crc/md5 of the data. @@ -433,6 +442,8 @@ static void do_verify(struct thread_data *td, uint64_t verify_bytes) break; } + check_update_rusage(td); + if (td->error) return; @@ -444,6 +455,7 @@ static void do_verify(struct thread_data *td, uint64_t verify_bytes) int ret2, full; update_tv_cache(td); + check_update_rusage(td); if (runtime_exceeded(td, &td->tv_cache)) { __update_tv_cache(td); @@ -597,6 +609,8 @@ sync_done: break; } + check_update_rusage(td); + if (!td->error) { min_events = td->cur_depth; @@ -652,6 +666,8 @@ static uint64_t do_io(struct thread_data *td) int ret2, full; enum fio_ddir ddir; + check_update_rusage(td); + if (td->terminate || td->done) break; @@ -816,6 +832,8 @@ sync_done: } } + check_update_rusage(td); + if (td->trim_entries) log_err("fio: %d trim entries leaked?\n", td->trim_entries); @@ -1379,6 +1397,9 @@ err: if (td->o.write_iolog_file) write_iolog_close(td); + fio_mutex_remove(td->rusage_sem); + td->rusage_sem = NULL; + td_set_runstate(td, TD_EXITED); return (void *) (uintptr_t) td->error; } @@ -1627,6 +1648,9 @@ static void run_threads(void) init_disk_util(td); + td->rusage_sem = fio_mutex_init(FIO_MUTEX_LOCKED); + td->update_rusage = 0; + /* * Set state to created. Thread will transition * to TD_INITIALIZED when it's done setting up. diff --git a/configure b/configure index 76da4ba..836d7ad 100755 --- a/configure +++ b/configure @@ -1017,7 +1017,7 @@ fi if test "$sfaa" = "yes" ; then output_sym "CONFIG_SFAA" fi -if test "$libverbs" = "yes" -o "rdmacm" = "yes" ; then +if test "$libverbs" = "yes" -a "rdmacm" = "yes" ; then output_sym "CONFIG_RDMA" fi if test "$clock_gettime" = "yes" ; then diff --git a/fio.h b/fio.h index 621ed60..a1b2a93 100644 --- a/fio.h +++ b/fio.h @@ -354,6 +354,8 @@ struct thread_data { uint64_t stat_io_blocks[DDIR_RWDIR_CNT]; struct timeval iops_sample_time; + volatile int update_rusage; + struct fio_mutex *rusage_sem; struct rusage ru_start; struct rusage ru_end; diff --git a/mutex.c b/mutex.c index 6022cdd..5a65e53 100644 --- a/mutex.c +++ b/mutex.c @@ -180,6 +180,7 @@ void fio_rwlock_remove(struct fio_rwlock *lock) struct fio_rwlock *fio_rwlock_init(void) { struct fio_rwlock *lock; + pthread_rwlockattr_t attr; int ret; lock = (void *) mmap(NULL, sizeof(struct fio_rwlock), @@ -193,13 +194,30 @@ struct fio_rwlock *fio_rwlock_init(void) lock->magic = FIO_RWLOCK_MAGIC; - ret = pthread_rwlock_init(&lock->lock, NULL); + ret = pthread_rwlockattr_init(&attr); if (ret) { log_err("pthread_rwlock_init: %s\n", strerror(ret)); goto err; } +#ifdef FIO_HAVE_PSHARED_MUTEX + ret = pthread_rwlockattr_setpshared(&attr, PTHREAD_PROCESS_SHARED); + if (ret) { + log_err("pthread_rwlock_init: %s\n", strerror(ret)); + goto destroy_attr; + } +#endif + + ret = pthread_rwlock_init(&lock->lock, &attr); + if (ret) { + log_err("pthread_rwlock_init: %s\n", strerror(ret)); + goto destroy_attr; + } + + pthread_rwlockattr_destroy(&attr); return lock; +destroy_attr: + pthread_rwlockattr_destroy(&attr); err: if (lock) fio_rwlock_remove(lock); diff --git a/stat.c b/stat.c index fe09a29..59f3718 100644 --- a/stat.c +++ b/stat.c @@ -1386,13 +1386,21 @@ static void *__show_running_run_stats(void *arg) if (td_trim(td) && td->io_bytes[DDIR_TRIM]) td->ts.runtime[DDIR_TRIM] += rt[i]; - update_rusage_stat(td); + td->update_rusage = 1; td->ts.io_bytes[DDIR_READ] = td->io_bytes[DDIR_READ]; td->ts.io_bytes[DDIR_WRITE] = td->io_bytes[DDIR_WRITE]; td->ts.io_bytes[DDIR_TRIM] = td->io_bytes[DDIR_TRIM]; td->ts.total_run_time = mtime_since(&td->epoch, &tv); } + for_each_td(td, i) { + if (td->rusage_sem) { + td->update_rusage = 1; + fio_mutex_down(td->rusage_sem); + } + td->update_rusage = 0; + } + show_run_stats(); for_each_td(td, i) { -- To unsubscribe from this list: send the line "unsubscribe fio" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html