Recent changes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The following changes since commit ef6350576b1053b0491b17932dc29740d749ad4a:

  Mutex timeout work-around (2012-02-15 22:24:19 +0100)

are available in the git repository at:
  git://git.kernel.dk/fio.git master

Jens Axboe (1):
      mutex: more clock fixes

 mutex.c         |   29 +++++++++++++++++++++--------
 os/os-aix.h     |    1 +
 os/os-freebsd.h |    3 ++-
 os/os-linux.h   |    1 +
 os/os-mac.h     |    1 +
 5 files changed, 26 insertions(+), 9 deletions(-)

---

Diff of recent changes:

diff --git a/mutex.c b/mutex.c
index cc4e353..ff6ec73 100644
--- a/mutex.c
+++ b/mutex.c
@@ -8,6 +8,7 @@
 #include <pthread.h>
 #include <sys/mman.h>
 
+#include "fio.h"
 #include "log.h"
 #include "mutex.h"
 #include "arch/arch.h"
@@ -16,6 +17,8 @@
 #include "time.h"
 #include "gettime.h"
 
+static clockid_t fio_clk_id = CLOCK_REALTIME;
+
 void fio_mutex_remove(struct fio_mutex *mutex)
 {
 	pthread_cond_destroy(&mutex->cond);
@@ -62,9 +65,7 @@ struct fio_mutex *fio_mutex_init(int value)
 	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);
+	pthread_condattr_setclock(&cond, fio_clk_id);
 #endif
 	pthread_cond_init(&mutex->cond, &cond);
 
@@ -98,11 +99,7 @@ int fio_mutex_down_timeout(struct fio_mutex *mutex, unsigned int seconds)
 
 	fio_gettime(&tv_s, NULL);
 
-#ifdef FIO_HAVE_CLOCK_MONOTONIC
-	clock_gettime(CLOCK_MONOTONIC, &t);
-#else
-	clock_gettime(CLOCK_REALTIME, &t);
-#endif
+	clock_gettime(fio_clk_id, &t);
 	t.tv_sec += seconds;
 
 	pthread_mutex_lock(&mutex->lock);
@@ -202,3 +199,19 @@ void fio_mutex_up_write(struct fio_mutex *mutex)
 		pthread_cond_signal(&mutex->cond);
 	pthread_mutex_unlock(&mutex->lock);
 }
+
+static void fio_init fio_mutex_global_init(void)
+{
+#ifdef FIO_HAVE_PTHREAD_CONDATTR_SETCLOCK
+#ifdef FIO_HAVE_CLOCK_MONOTONIC
+	pthread_condattr_t cond;
+
+	pthread_condattr_init(&cond);
+
+	if (!pthread_condattr_setclock(&cond, CLOCK_MONOTONIC))
+		fio_clk_id = CLOCK_MONOTONIC;
+
+	pthread_condattr_destroy(&cond);
+#endif
+#endif
+}
diff --git a/os/os-aix.h b/os/os-aix.h
index 2f75bf8..3cbc80f 100644
--- a/os/os-aix.h
+++ b/os/os-aix.h
@@ -14,6 +14,7 @@
 #define FIO_HAVE_ODIRECT
 #define FIO_USE_GENERIC_RAND
 #define FIO_HAVE_CLOCK_MONOTONIC
+#define FIO_HAVE_PTHREAD_CONDATTR_SETCLOCK
 
 /*
  * This is broken on AIX if _LARGE_FILES is defined...
diff --git a/os/os-freebsd.h b/os/os-freebsd.h
index 93205c3..976bd84 100644
--- a/os/os-freebsd.h
+++ b/os/os-freebsd.h
@@ -17,8 +17,9 @@
 #define FIO_HAVE_STRSEP
 #define FIO_USE_GENERIC_RAND
 #define FIO_HAVE_CHARDEV_SIZE
-#define FIO_HAVE_CLOCK_MONOTONIC
 #define FIO_HAVE_GETTID
+#define FIO_HAVE_CLOCK_MONOTONIC
+#define FIO_HAVE_PTHREAD_CONDATTR_SETCLOCK
 
 #define OS_MAP_ANON		MAP_ANON
 
diff --git a/os/os-linux.h b/os/os-linux.h
index 9f547ff..61dfa30 100644
--- a/os/os-linux.h
+++ b/os/os-linux.h
@@ -44,6 +44,7 @@
 #define FIO_HAVE_TRIM
 #define FIO_HAVE_BINJECT
 #define FIO_HAVE_CLOCK_MONOTONIC
+#define FIO_HAVE_PTHREAD_CONDATTR_SETCLOCK
 #define FIO_HAVE_GETTID
 
 /*
diff --git a/os/os-mac.h b/os/os-mac.h
index aec30f9..e4c2bc8 100644
--- a/os/os-mac.h
+++ b/os/os-mac.h
@@ -29,6 +29,7 @@
 #define FIO_USE_GENERIC_RAND
 #define FIO_HAVE_GETTID
 #define FIO_HAVE_CHARDEV_SIZE
+#define FIO_HAVE_PTHREAD_CONDATTR_SETCLOCK
 
 #define OS_MAP_ANON		MAP_ANON
 
--
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


[Index of Archives]     [Linux Kernel]     [Linux SCSI]     [Linux IDE]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux