Recent changes (master)

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

 



The following changes since commit 798827c895a585f284842f6b99378be19c821263:

  init: complain on unrecognized option with builtin getopt_long_only() (2013-01-23 18:11:48 -0700)

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

Huadong Liu (1):
      Use RUSAGE_THREAD, if available

Jens Axboe (9):
      Add lib/getrusage.c
      configure: add that windows has RUSGE_THREAD
      Correct ifdef checks for posix and linux fallocate
      hash: make 64-bit type ULL
      NAN: use __builtin_nanf() if not available
      configure: fix more old FIO_HAVE_ checks
      options: add help to experimental_verify
      configure: solaris and windowsaio fixups
      configure: kill windows FIO_HAVE_FDATASYNC

 Makefile                                |   15 ++++++++++---
 backend.c                               |    4 +-
 configure                               |   32 +++++++++++++++++++++++++++---
 filesetup.c                             |   10 ++++----
 fio.h                                   |    2 +-
 hash.h                                  |    2 +-
 lib/getrusage.c                         |   14 +++++++++++++
 lib/getrusage.h                         |    9 ++++++++
 options.c                               |   15 +++++++------
 os/os-solaris.h                         |    1 -
 os/os-windows.h                         |    3 --
 os/windows/posix.c                      |   14 +++++++++++-
 os/windows/posix/include/sys/resource.h |    1 +
 parse.c                                 |    3 ++
 stat.c                                  |    8 +-----
 15 files changed, 97 insertions(+), 36 deletions(-)
 create mode 100644 lib/getrusage.c
 create mode 100644 lib/getrusage.h

---

Diff of recent changes:

diff --git a/Makefile b/Makefile
index 22ea022..dab6e88 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,5 @@
 DEBUGFLAGS = -D_FORTIFY_SOURCE=2 -DFIO_INC_DEBUG
-CPPFLAGS= -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 \
-	$(DEBUGFLAGS)
+CPPFLAGS= -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 $(DEBUGFLAGS)
 OPTFLAGS= -O3 -g -ffast-math $(EXTFLAGS)
 CFLAGS	= -std=gnu99 -Wwrite-strings -Wall $(OPTFLAGS)
 LIBS	= -lm $(EXTLIBS)
@@ -29,7 +28,7 @@ SOURCE := gettime.c fio.c ioengines.c init.c stat.c log.c time.c filesetup.c \
 		engines/mmap.c engines/sync.c engines/null.c engines/net.c \
 		memalign.c server.c client.c iolog.c backend.c libfio.c flow.c \
 		json.c lib/zipf.c lib/axmap.c lib/lfsr.c gettime-thread.c \
-		helpers.c lib/flist_sort.c lib/hweight.c
+		helpers.c lib/flist_sort.c lib/hweight.c lib/getrusage.c
 
 ifdef CONFIG_64BIT_LLP64
   CFLAGS += -DBITS_PER_LONG=32
@@ -62,6 +61,7 @@ ifdef CONFIG_LINUX_FALLOCATE
   SOURCE += engines/falloc.c
 endif
 ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
+  CFLAGS += -DCONFIG_LINUX_EXT4_MOVE_EXTENT
   SOURCE += engines/e4defrag.c
 endif
 ifdef CONFIG_LINUX_SPLICE
@@ -80,6 +80,10 @@ ifdef CONFIG_SOLARISAIO
   CFLAGS += -DCONFIG_SOLARISAIO
   SOURCE += engines/solarisaio.c
 endif
+ifdef CONFIG_WINDOWSAIO
+  CFLAGS += -DCONFIG_WINDOWSAIO
+  SOURCE += engines/windowsaio.c
+endif
 
 ifndef CONFIG_STRSEP
   CFLAGS += -DCONFIG_STRSEP
@@ -142,6 +146,9 @@ endif
 ifdef CONFIG_LINUX_FALLOCATE
   CFLAGS += -DCONFIG_LINUX_FALLOCATE
 endif
+ifdef CONFIG_RUSAGE_THREAD
+  CFLAGS += -DCONFIG_RUSAGE_THREAD
+endif
 
 ifeq ($(UNAME), Linux)
   SOURCE += diskutil.c fifo.c blktrace.c cgroup.c trim.c engines/sg.c \
@@ -181,7 +188,7 @@ ifeq ($(UNAME), Darwin)
 endif
 ifneq (,$(findstring CYGWIN,$(UNAME)))
   SOURCE := $(filter-out engines/mmap.c,$(SOURCE))
-  SOURCE += engines/windowsaio.c os/windows/posix.c
+  SOURCE += os/windows/posix.c
   LIBS	 += -lpthread -lpsapi -lws2_32
   CFLAGS += -DPSAPI_VERSION=1 -Ios/windows/posix/include -Wno-format
 endif
diff --git a/backend.c b/backend.c
index e025dbf..87810e8 100644
--- a/backend.c
+++ b/backend.c
@@ -50,6 +50,7 @@
 #include "lib/rand.h"
 #include "memalign.h"
 #include "server.h"
+#include "lib/getrusage.h"
 
 static pthread_t disk_util_thread;
 static struct fio_mutex *disk_thread_mutex;
@@ -1210,8 +1211,7 @@ static void *thread_main(void *data)
 	}
 
 	fio_gettime(&td->epoch, NULL);
-	getrusage(RUSAGE_SELF, &td->ru_start);
-
+	fio_getrusage(&td->ru_start);
 	clear_state = 0;
 	while (keep_running(td)) {
 		uint64_t verify_bytes;
diff --git a/configure b/configure
index f730dfd..b49497b 100755
--- a/configure
+++ b/configure
@@ -26,6 +26,9 @@ rm -rf config.log
 config_host_mak="config-host.mak"
 config_host_ld="config-host.ld"
 
+# Default CFLAGS
+CFLAGS="-D_GNU_SOURCE"
+
 # Print a helpful header at the top of config.log
 echo "# FIO configure log $(date)" >> config.log
 printf "# Configured with:" >> config.log
@@ -161,6 +164,9 @@ CYGWIN*)
   echo "CONFIG_POSIX_FALLOCATE=y"  >> $config_host_mak
   echo "CONFIG_FADVISE=y"          >> $config_host_mak
   echo "CONFIG_SFAA=y"             >> $config_host_mak
+  echo "CONFIG_RUSAGE_THREAD=y"    >> $config_host_mak
+  echo "CONFIG_WINDOWSAIO=y"       >> $config_host_mak
+  echo "CONFIG_FDATASYNC=y"        >> $config_host_mak
   exit 0
 esac
 
@@ -480,7 +486,6 @@ echo "POSIX fallocate               $posix_fallocate"
 linux_2arg_affinity="no"
 linux_3arg_affinity="no"
 cat > $TMPC << EOF
-#define _GNU_SOURCE
 #include <sched.h>
 int main(int argc, char **argv)
 {
@@ -492,7 +497,6 @@ if compile_prog "" "" "sched_setaffinity(,,)"; then
   linux_3arg_affinity="yes"
 else
   cat > $TMPC << EOF
-#define _GNU_SOURCE
 #include <sched.h>
 int main(int argc, char **argv)
 {
@@ -601,7 +605,6 @@ sync_file_range="no"
 cat > $TMPC << EOF
 #include <stdio.h>
 #include <unistd.h>
-#define _GNU_SOURCE
 #include <fcntl.h>
 #include <linux/fs.h>
 int main(int argc, char **argv)
@@ -642,7 +645,6 @@ echo "EXT4 move extent              $ext4_me"
 # splice probe
 linux_splice="no"
 cat > $TMPC << EOF
-#define _GNU_SOURCE
 #include <stdio.h>
 #include <fcntl.h>
 int main(int argc, char **argv)
@@ -789,6 +791,24 @@ if compile_prog "" "" "__thread"; then
 fi
 echo "__thread                      $tls_thread"
 
+##########################################
+# Check whether we have getrusage(RUSAGE_THREAD)
+rusage_thread="no"
+cat > $TMPC << EOF
+#include <sys/time.h>
+#include <sys/resource.h>
+int main(int argc, char **argv)
+{
+  struct rusage ru;
+  getrusage(RUSAGE_THREAD, &ru);
+  return 0;
+}
+EOF
+if compile_prog "" "" "RUSAGE_THREAD"; then
+  rusage_thread="yes"
+fi
+echo "RUSAGE_THREAD                 $rusage_thread"
+
 #############################################################################
 
 echo "# Automatically generated by configure - do not modify" > $config_host_mak
@@ -889,6 +909,10 @@ fi
 if test "$tls_thread" = "yes" ; then
   echo "CONFIG_TLS_THREAD=y" >> $config_host_mak
 fi
+if test "$rusage_thread" = "yes" ; then
+  echo "CONFIG_RUSAGE_THREAD=y" >> $config_host_mak
+fi
 
 echo "LIBS+=$LIBS" >> $config_host_mak
 echo "CC=$cc" >> $config_host_mak
+echo "CFLAGS=$CFLAGS" >> $config_host_mak
diff --git a/filesetup.c b/filesetup.c
index d0aef21..6f0a876 100644
--- a/filesetup.c
+++ b/filesetup.c
@@ -15,7 +15,7 @@
 #include "hash.h"
 #include "lib/axmap.h"
 
-#ifdef FIO_HAVE_LINUX_FALLOCATE
+#ifdef CONFIG_LINUX_FALLOCATE
 #include <linux/falloc.h>
 #endif
 
@@ -72,7 +72,7 @@ static int extend_file(struct thread_data *td, struct fio_file *f)
 		return 1;
 	}
 
-#ifdef FIO_HAVE_FALLOCATE
+#ifdef CONFIG_POSIX_FALLOCATE
 	if (!td->o.fill_device) {
 		switch (td->o.fallocate_mode) {
 		case FIO_FALLOCATE_NONE:
@@ -87,7 +87,7 @@ static int extend_file(struct thread_data *td, struct fio_file *f)
 						strerror(r));
 			}
 			break;
-#ifdef FIO_HAVE_LINUX_FALLOCATE
+#ifdef CONFIG_LINUX_FALLOCATE
 		case FIO_FALLOCATE_KEEP_SIZE:
 			dprint(FD_FILE,
 				"fallocate(FALLOC_FL_KEEP_SIZE) "
@@ -100,14 +100,14 @@ static int extend_file(struct thread_data *td, struct fio_file *f)
 				td_verror(td, errno, "fallocate");
 			}
 			break;
-#endif /* FIO_HAVE_LINUX_FALLOCATE */
+#endif /* CONFIG_LINUX_FALLOCATE */
 		default:
 			log_err("fio: unknown fallocate mode: %d\n",
 				td->o.fallocate_mode);
 			assert(0);
 		}
 	}
-#endif /* FIO_HAVE_FALLOCATE */
+#endif /* CONFIG_POSIX_FALLOCATE */
 
 	if (!new_layout)
 		goto done;
diff --git a/fio.h b/fio.h
index 1ff384f..3a26335 100644
--- a/fio.h
+++ b/fio.h
@@ -40,7 +40,7 @@ struct thread_data;
 #include "stat.h"
 #include "flow.h"
 
-#ifdef FIO_HAVE_SOLARISAIO
+#ifdef CONFIG_SOLARISAIO
 #include <sys/asynch.h>
 #endif
 
diff --git a/hash.h b/hash.h
index 13600f4..02b0614 100644
--- a/hash.h
+++ b/hash.h
@@ -28,7 +28,7 @@
 #error Define GOLDEN_RATIO_PRIME for your wordsize.
 #endif
 
-#define GR_PRIME_64	0x9e37fffffffc0001UL
+#define GR_PRIME_64	0x9e37fffffffc0001ULL
 
 static inline unsigned long __hash_long(unsigned long val)
 {
diff --git a/lib/getrusage.c b/lib/getrusage.c
new file mode 100644
index 0000000..96dcf6d
--- /dev/null
+++ b/lib/getrusage.c
@@ -0,0 +1,14 @@
+#include <errno.h>
+#include "getrusage.h"
+
+int fio_getrusage(struct rusage *ru)
+{
+#ifdef CONFIG_RUSAGE_THREAD
+	if (!getrusage(RUSAGE_THREAD, ru))
+		return 0;
+	if (errno != EINVAL)
+		return -1;
+	/* Fall through to RUSAGE_SELF */
+#endif
+	return getrusage(RUSAGE_SELF, ru);
+}
diff --git a/lib/getrusage.h b/lib/getrusage.h
new file mode 100644
index 0000000..49e6427
--- /dev/null
+++ b/lib/getrusage.h
@@ -0,0 +1,9 @@
+#ifndef FIO_GETRUSAGE_H
+#define FIO_GETRUSAGE_H
+
+#include <sys/time.h>
+#include <sys/resource.h>
+
+extern int fio_getrusage(struct rusage *ru);
+
+#endif
diff --git a/options.c b/options.c
index 2b71abd..1009df3 100644
--- a/options.c
+++ b/options.c
@@ -1277,12 +1277,12 @@ static struct fio_option options[FIO_MAX_OPTS] = {
 			    .help = "POSIX asynchronous IO",
 			  },
 #endif
-#ifdef FIO_HAVE_SOLARISAIO
+#ifdef CONFIG_SOLARISAIO
 			  { .ival = "solarisaio",
 			    .help = "Solaris native asynchronous IO",
 			  },
 #endif
-#ifdef FIO_HAVE_WINDOWSAIO
+#ifdef CONFIG_WINDOWSAIO
 			  { .ival = "windowsaio",
 			    .help = "Windows native asynchronous IO"
 			  },
@@ -1332,12 +1332,12 @@ static struct fio_option options[FIO_MAX_OPTS] = {
 			    .help = "Fusion-io atomic write engine",
 			  },
 #endif
-#ifdef FIO_HAVE_E4_ENG
+#ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
 			  { .ival = "e4defrag",
 			    .help = "ext4 defrag engine",
 			  },
 #endif
-#ifdef FIO_HAVE_FALLOC_ENG
+#ifdef CONFIG_LINUX_FALLOCATE
 			  { .ival = "falloc",
 			    .help = "fallocate() file based engine",
 			  },
@@ -1578,7 +1578,7 @@ static struct fio_option options[FIO_MAX_OPTS] = {
 		},
 		.parent = "nrfiles",
 	},
-#ifdef FIO_HAVE_FALLOCATE
+#ifdef CONFIG_POSIX_FALLOCATE
 	{
 		.name	= "fallocate",
 		.type	= FIO_OPT_STR,
@@ -1594,7 +1594,7 @@ static struct fio_option options[FIO_MAX_OPTS] = {
 			    .oval = FIO_FALLOCATE_POSIX,
 			    .help = "Use posix_fallocate()",
 			  },
-#ifdef FIO_HAVE_LINUX_FALLOCATE
+#ifdef CONFIG_LINUX_FALLOCATE
 			  { .ival = "keep",
 			    .oval = FIO_FALLOCATE_KEEP_SIZE,
 			    .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
@@ -1611,7 +1611,7 @@ static struct fio_option options[FIO_MAX_OPTS] = {
 			  },
 		},
 	},
-#endif	/* FIO_HAVE_FALLOCATE */
+#endif	/* CONFIG_POSIX_FALLOCATE */
 	{
 		.name	= "fadvise_hint",
 		.type	= FIO_OPT_BOOL,
@@ -1965,6 +1965,7 @@ static struct fio_option options[FIO_MAX_OPTS] = {
 		.name	= "experimental_verify",
 		.off1	= td_var_offset(experimental_verify),
 		.type	= FIO_OPT_BOOL,
+		.help	= "Enable experimental verification",
 	},
 #ifdef FIO_HAVE_TRIM
 	{
diff --git a/os/os-solaris.h b/os/os-solaris.h
index de59f77..e661211 100644
--- a/os/os-solaris.h
+++ b/os/os-solaris.h
@@ -14,7 +14,6 @@
 
 #include "../file.h"
 
-#define FIO_HAVE_SOLARISAIO
 #define FIO_HAVE_CPU_AFFINITY
 #define FIO_HAVE_PSHARED_MUTEX
 #define FIO_HAVE_CHARDEV_SIZE
diff --git a/os/os-windows.h b/os/os-windows.h
index f68f654..ef71dd7 100644
--- a/os/os-windows.h
+++ b/os/os-windows.h
@@ -20,9 +20,6 @@
 #define FIO_HAVE_ODIRECT
 #define FIO_HAVE_CPU_AFFINITY
 #define FIO_HAVE_CHARDEV_SIZE
-#define FIO_HAVE_FDATASYNC
-#define FIO_HAVE_WINDOWSAIO
-#define FIO_HAVE_FALLOCATE
 #define FIO_HAVE_GETTID
 #define FIO_USE_GENERIC_RAND
 
diff --git a/os/windows/posix.c b/os/windows/posix.c
index 67e71c8..05fa5a9 100755
--- a/os/windows/posix.c
+++ b/os/windows/posix.c
@@ -547,11 +547,21 @@ int getrusage(int who, struct rusage *r_usage)
 	const uint64_t SECONDS_BETWEEN_1601_AND_1970 = 11644473600;
 	FILETIME cTime, eTime, kTime, uTime;
 	time_t time;
+	HANDLE h;
 
 	memset(r_usage, 0, sizeof(*r_usage));
 
-	HANDLE hProcess = GetCurrentProcess();
-	GetProcessTimes(hProcess, &cTime, &eTime, &kTime, &uTime);
+	if (who == RUSAGE_SELF) {
+		h = GetCurrentProcess();
+		GetProcessTimes(h, &cTime, &eTime, &kTime, &uTime);
+	} else if (who == RUSAGE_THREAD) {
+		h = GetCurrentThread();
+		GetThreadTimes(h, &cTime, &eTime, &kTime, &uTime);
+	} else {
+		log_err("fio: getrusage %d is not implemented\n", who);
+		return -1;
+	}
+
 	time = ((uint64_t)uTime.dwHighDateTime << 32) + uTime.dwLowDateTime;
 	/* Divide by 10,000,000 to get the number of seconds and move the epoch from
 	 * 1601 to 1970 */
diff --git a/os/windows/posix/include/sys/resource.h b/os/windows/posix/include/sys/resource.h
index 837d657..fd46b28 100644
--- a/os/windows/posix/include/sys/resource.h
+++ b/os/windows/posix/include/sys/resource.h
@@ -2,6 +2,7 @@
 #define SYS_RESOURCE_H
 
 #define RUSAGE_SELF	0
+#define RUSAGE_THREAD	1
 
 struct rusage
 {
diff --git a/parse.c b/parse.c
index 18c4530..d15d22b 100644
--- a/parse.c
+++ b/parse.c
@@ -1096,6 +1096,9 @@ void option_init(struct fio_option *o)
 			o->maxval = UINT_MAX;
 	}
 	if (o->type == FIO_OPT_FLOAT_LIST) {
+#ifndef NAN
+#define NAN __builtin_nanf("")
+#endif
 		o->minfp = NAN;
 		o->maxfp = NAN;
 	}
diff --git a/stat.c b/stat.c
index 522901a..8e1034b 100644
--- a/stat.c
+++ b/stat.c
@@ -11,17 +11,13 @@
 #include "diskutil.h"
 #include "lib/ieee754.h"
 #include "json.h"
+#include "lib/getrusage.h"
 
 void update_rusage_stat(struct thread_data *td)
 {
 	struct thread_stat *ts = &td->ts;
 
-#ifdef RUSAGE_THREAD
-	getrusage(RUSAGE_THREAD, &td->ru_end);
-#else
-	getrusage(RUSAGE_SELF, &td->ru_end);
-#endif
-
+	fio_getrusage(&td->ru_end);
 	ts->usr_time += mtime_since(&td->ru_start.ru_utime,
 					&td->ru_end.ru_utime);
 	ts->sys_time += mtime_since(&td->ru_start.ru_stime,
--
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