Recent changes (master)

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

 



The following changes since commit 23893646c9306b785f866fb9e976f3db673af0ca:

  Add --cpuclock-test and clocksource= option help (2012-12-17 14:44:08 +0100)

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

Jens Axboe (7):
      gettime: fix race/bug with threads and time keeping
      gettime: use pthread_{set,get}specific() for TLS
      gettime: make last_cycles thread local too
      windowsaio: fix typo
      Fio 2.0.12
      Fixup CPUID for 32-bit x86
      Fio 2.0.12.1

 FIO-VERSION-GEN        |    2 +-
 arch/arch-x86-common.h |   17 ++++----------
 backend.c              |    2 +
 crc/crc32c-intel.c     |    2 +-
 engines/windowsaio.c   |    2 +-
 gettime.c              |   58 ++++++++++++++++++++++++++++++++++-------------
 gettime.h              |    1 +
 os/windows/install.wxs |    2 +-
 8 files changed, 54 insertions(+), 32 deletions(-)

---

Diff of recent changes:

diff --git a/FIO-VERSION-GEN b/FIO-VERSION-GEN
index 035ddaf..d5d2659 100755
--- a/FIO-VERSION-GEN
+++ b/FIO-VERSION-GEN
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 GVF=FIO-VERSION-FILE
-DEF_VER=fio-2.0.11
+DEF_VER=fio-2.0.12.1
 
 LF='
 '
diff --git a/arch/arch-x86-common.h b/arch/arch-x86-common.h
index 1e62354..d533d22 100644
--- a/arch/arch-x86-common.h
+++ b/arch/arch-x86-common.h
@@ -4,24 +4,17 @@
 static inline void do_cpuid(unsigned int *eax, unsigned int *ebx,
 			    unsigned int *ecx, unsigned int *edx)
 {
-	unsigned int id = *eax;
-
-	asm("movl %4, %%eax;"
-	    "cpuid;"
-	    "movl %%eax, %0;"
-	    "movl %%ebx, %1;"
-	    "movl %%ecx, %2;"
-	    "movl %%edx, %3;"
-		: "=r" (*eax), "=r" (*ebx), "=r" (*ecx), "=r" (*edx)
-		: "r" (id)
-		: "eax", "ebx", "ecx", "edx");
+	asm volatile("cpuid"
+		: "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx)
+		: "0" (*eax), "2" (*ecx)
+		: "memory");
 }
 
 #define ARCH_HAVE_INIT
 extern int tsc_reliable;
 static inline int arch_init(char *envp[])
 {
-	unsigned int eax, ebx, ecx, edx;
+	unsigned int eax, ebx, ecx = 0, edx;
 
 	/*
 	 * Check for TSC
diff --git a/backend.c b/backend.c
index a71d768..225d8a3 100644
--- a/backend.c
+++ b/backend.c
@@ -1011,6 +1011,8 @@ static void *thread_main(void *data)
 	} else
 		td->pid = gettid();
 
+	fio_local_clock_init(td->o.use_thread);
+
 	dprint(FD_PROCESS, "jobs pid=%d started\n", (int) td->pid);
 
 	INIT_FLIST_HEAD(&td->io_u_freelist);
diff --git a/crc/crc32c-intel.c b/crc/crc32c-intel.c
index 8e1cd58..0b0f193 100644
--- a/crc/crc32c-intel.c
+++ b/crc/crc32c-intel.c
@@ -81,7 +81,7 @@ uint32_t crc32c_intel(unsigned char const *data, unsigned long length)
 void crc32c_intel_probe(void)
 {
 	if (!crc32c_probed) {
-		unsigned int eax, ebx, ecx, edx;
+		unsigned int eax, ebx, ecx = 0, edx;
 
 		eax = 1;
 
diff --git a/engines/windowsaio.c b/engines/windowsaio.c
index edc390c..f1b0bc5 100644
--- a/engines/windowsaio.c
+++ b/engines/windowsaio.c
@@ -504,7 +504,7 @@ static int fio_windowsaio_io_u_init(struct thread_data *td, struct io_u *io_u)
 	struct fio_overlapped *o;
 
 	o = malloc(sizeof(*o));
-	o->io_complete = FALSE:
+	o->io_complete = FALSE;
 	o->io_u = io_u;
 	o->o.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
 	if (!o->o.hEvent) {
diff --git a/gettime.c b/gettime.c
index f5be6bd..248f146 100644
--- a/gettime.c
+++ b/gettime.c
@@ -15,11 +15,15 @@
 
 #ifdef ARCH_HAVE_CPU_CLOCK
 static unsigned long cycles_per_usec;
-static unsigned long last_cycles;
 int tsc_reliable = 0;
 #endif
-static struct timeval last_tv;
-static int last_tv_valid;
+
+struct tv_valid {
+	struct timeval last_tv;
+	int last_tv_valid;
+	unsigned long last_cycles;
+};
+static pthread_key_t tv_tls_key;
 
 enum fio_cs fio_clock_source = FIO_PREFERRED_CLOCK_SOURCE;
 int fio_clock_source_set = 0;
@@ -122,6 +126,8 @@ void fio_gettime(struct timeval *tp, void *caller)
 void fio_gettime(struct timeval *tp, void fio_unused *caller)
 #endif
 {
+	struct tv_valid *tv;
+
 #ifdef FIO_DEBUG_TIME
 	if (!caller)
 		caller = __builtin_return_address(0);
@@ -133,6 +139,8 @@ void fio_gettime(struct timeval *tp, void fio_unused *caller)
 		return;
 	}
 
+	tv = pthread_getspecific(tv_tls_key);
+
 	switch (fio_clock_source) {
 	case CS_GTOD:
 		gettimeofday(tp, NULL);
@@ -158,15 +166,15 @@ void fio_gettime(struct timeval *tp, void fio_unused *caller)
 		unsigned long long usecs, t;
 
 		t = get_cpu_clock();
-		if (t < last_cycles) {
+		if (tv && t < tv->last_cycles) {
 			dprint(FD_TIME, "CPU clock going back in time\n");
-			t = last_cycles;
-		}
+			t = tv->last_cycles;
+		} else if (tv)
+			tv->last_cycles = t;
 
 		usecs = t / cycles_per_usec;
 		tp->tv_sec = usecs / 1000000;
 		tp->tv_usec = usecs % 1000000;
-		last_cycles = t;
 		break;
 		}
 #endif
@@ -179,15 +187,17 @@ void fio_gettime(struct timeval *tp, void fio_unused *caller)
 	 * If Linux is using the tsc clock on non-synced processors,
 	 * sometimes time can appear to drift backwards. Fix that up.
 	 */
-	if (last_tv_valid) {
-		if (tp->tv_sec < last_tv.tv_sec)
-			tp->tv_sec = last_tv.tv_sec;
-		else if (last_tv.tv_sec == tp->tv_sec &&
-			 tp->tv_usec < last_tv.tv_usec)
-			tp->tv_usec = last_tv.tv_usec;
+	if (tv) {
+		if (tv->last_tv_valid) {
+			if (tp->tv_sec < tv->last_tv.tv_sec)
+				tp->tv_sec = tv->last_tv.tv_sec;
+			else if (tv->last_tv.tv_sec == tp->tv_sec &&
+				 tp->tv_usec < tv->last_tv.tv_usec)
+				tp->tv_usec = tv->last_tv.tv_usec;
+		}
+		tv->last_tv_valid = 1;
+		memcpy(&tv->last_tv, tp, sizeof(*tp));
 	}
-	last_tv_valid = 1;
-	memcpy(&last_tv, tp, sizeof(*tp));
 }
 
 #ifdef ARCH_HAVE_CPU_CLOCK
@@ -262,12 +272,28 @@ static void calibrate_cpu_clock(void)
 }
 #endif
 
+void fio_local_clock_init(int is_thread)
+{
+	struct tv_valid *t;
+
+	t = calloc(sizeof(*t), 1);
+	if (pthread_setspecific(tv_tls_key, t))
+		log_err("fio: can't set TLS key\n");
+}
+
+static void kill_tv_tls_key(void *data)
+{
+	free(data);
+}
+
 void fio_clock_init(void)
 {
 	if (fio_clock_source == fio_clock_source_inited)
 		return;
 
-	last_tv_valid = 0;
+	if (pthread_key_create(&tv_tls_key, kill_tv_tls_key))
+		log_err("fio: can't create TLS key\n");
+
 	fio_clock_source_inited = fio_clock_source;
 	calibrate_cpu_clock();
 
diff --git a/gettime.h b/gettime.h
index 8ca3791..f0ad20c 100644
--- a/gettime.h
+++ b/gettime.h
@@ -16,6 +16,7 @@ extern void fio_gtod_init(void);
 extern void fio_clock_init(void);
 extern int fio_start_gtod_thread(void);
 extern int fio_monotonic_clocktest(void);
+extern void fio_local_clock_init(int);
 
 extern struct timeval *fio_tv;
 
diff --git a/os/windows/install.wxs b/os/windows/install.wxs
index 86098b0..d4913b6 100755
--- a/os/windows/install.wxs
+++ b/os/windows/install.wxs
@@ -10,7 +10,7 @@
     <Product Id="C3DC8A4F-1191-412F-8287-ACB6BA798F6A"
 	  Codepage="1252" Language="1033"
 	  Manufacturer="fio" Name="fio"
-	  UpgradeCode="2338A332-5511-43cf-b9BD-5C60496CCFCC" Version="2.0.11">
+	  UpgradeCode="2338A332-5511-43cf-b9BD-5C60496CCFCC" Version="2.0.12.1">
 		<Package
 		  Comments="Contact: Your local administrator"
 		  Description="Flexible IO Tester"
--
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