The following changes since commit d401b24d00244223f04ddeee0c563909ad7f4f31: Revert "Change iolog overlap assert to a debug dump" (2012-02-11 09:06:58 +0100) are available in the git repository at: git://git.kernel.dk/fio.git master Jens Axboe (7): mutex: set and use the proper clock source Fix grammatical error Fix build issue for non-cgroup support Fix typo Fixup includes Mutex fixes Mutex timeout work-around backend.c | 3 ++- cgroup.h | 2 +- fio.c | 12 ------------ libfio.c | 2 ++ mutex.c | 31 +++++++++++++++++++++++++++++++ 5 files changed, 36 insertions(+), 14 deletions(-) --- Diff of recent changes: diff --git a/backend.c b/backend.c index efb17b3..e567ad5 100644 --- a/backend.c +++ b/backend.c @@ -1493,7 +1493,8 @@ static void run_threads(void) } if (left) { - log_err("fio: %d jobs failed to start\n", left); + log_err("fio: %d job%s failed to start\n", left, + left > 1 ? "s" : ""); for (i = 0; i < this_jobs; i++) { td = map[i]; if (!td) diff --git a/cgroup.h b/cgroup.h index 68ecfcd..0bbe25a 100644 --- a/cgroup.h +++ b/cgroup.h @@ -21,7 +21,7 @@ static inline void cgroup_shutdown(struct thread_data *td, char **mnt) { } -void cgroup_kill(struct flist_head *list) +static inline void cgroup_kill(struct flist_head *list) { } diff --git a/fio.c b/fio.c index 5a99318..be60c5f 100644 --- a/fio.c +++ b/fio.c @@ -22,19 +22,8 @@ * */ #include <unistd.h> -#include <fcntl.h> -#include <string.h> -#include <limits.h> -#include <signal.h> -#include <time.h> #include <locale.h> -#include <assert.h> #include <time.h> -#include <sys/stat.h> -#include <sys/wait.h> -#include <sys/ipc.h> -#include <sys/shm.h> -#include <sys/mman.h> #include "fio.h" #include "hash.h" @@ -42,7 +31,6 @@ #include "verify.h" #include "trim.h" #include "diskutil.h" -#include "cgroup.h" #include "profile.h" #include "lib/rand.h" #include "memalign.h" diff --git a/libfio.c b/libfio.c index 76a36a6..668df45 100644 --- a/libfio.c +++ b/libfio.c @@ -23,6 +23,8 @@ */ #include <string.h> +#include <sys/types.h> +#include <signal.h> #include "fio.h" /* diff --git a/mutex.c b/mutex.c index 3a01f98..cc4e353 100644 --- a/mutex.c +++ b/mutex.c @@ -4,6 +4,7 @@ #include <stdlib.h> #include <fcntl.h> #include <time.h> +#include <errno.h> #include <pthread.h> #include <sys/mman.h> @@ -12,9 +13,12 @@ #include "arch/arch.h" #include "os/os.h" #include "helpers.h" +#include "time.h" +#include "gettime.h" void fio_mutex_remove(struct fio_mutex *mutex) { + pthread_cond_destroy(&mutex->cond); munmap((void *) mutex, sizeof(*mutex)); } @@ -57,6 +61,11 @@ struct fio_mutex *fio_mutex_init(int value) #ifdef FIO_HAVE_PSHARED_MUTEX pthread_condattr_setpshared(&cond, PTHREAD_PROCESS_SHARED); #endif +#ifdef FIO_HAVE_CLOCK_MONOTONIC + pthread_condattr_setclock(&cond, CLOCK_MONOTONIC); +#else + pthread_condattr_setclock(&cond, CLOCK_REALTIME); +#endif pthread_cond_init(&mutex->cond, &cond); ret = pthread_mutex_init(&mutex->lock, &attr); @@ -76,19 +85,41 @@ err: return NULL; } +static int mutex_timed_out(struct timeval *t, unsigned int seconds) +{ + return mtime_since_now(t) >= seconds * 1000; +} + int fio_mutex_down_timeout(struct fio_mutex *mutex, unsigned int seconds) { + struct timeval tv_s; struct timespec t; int ret = 0; + fio_gettime(&tv_s, NULL); + +#ifdef FIO_HAVE_CLOCK_MONOTONIC + clock_gettime(CLOCK_MONOTONIC, &t); +#else clock_gettime(CLOCK_REALTIME, &t); +#endif t.tv_sec += seconds; pthread_mutex_lock(&mutex->lock); while (!mutex->value && !ret) { mutex->waiters++; + + /* + * Some platforms (FreeBSD 9?) seems to return timed out + * way too early, double check. + */ ret = pthread_cond_timedwait(&mutex->cond, &mutex->lock, &t); + if (ret == ETIMEDOUT && !mutex_timed_out(&tv_s, seconds)) { + pthread_mutex_lock(&mutex->lock); + ret = 0; + } + mutex->waiters--; } -- 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