Skip to contentSkip to conversation

Recent changes (master)

PATCH Jens Axboe 1 participant 1 message May 5, 2015

lore
Share & tools
lore

Jens Axboe

author
#0 lore raw

The following changes since commit 020d54bdf73e691b90b75d3abfd8e6f06cd1f637:

  configure: add support for --prefix (2015-04-29 10:29:16 -0600)

are available in the git repository at:

git://git.kernel.dk/fio.git master

for you to fetch changes up to 95603b7470fac1917cb11bc686e60b4339f8a2fc:

Fix Runtime, IOPS, bandwidth recorded incorrectly (2015-05-04 16:07:10 -0600)

----------------------------------------------------------------
Brian Fulton (1):
Fix Runtime, IOPS, bandwidth recorded incorrectly

Jens Axboe (1):
blktrace: support for non-512b sector sizes

Steven Noonan (2):
gettime: add support for CLOCK_MONOTONIC_RAW
lfsr-test: print total elapsed time correctly

 backend.c     | 36 ++++++++++++++++-----------
 blktrace.c    | 78 +++++++++++++++++++++++++++++++++++++++++------------------
 configure     | 21 ++++++++++++++++
 file.h        |  1 +
 gettime.c     |  4 ++-
 t/lfsr-test.c |  2 +-
 6 files changed, 102 insertions(+), 40 deletions(-)

---

Diff of recent changes:

backend.c +22 -14
index 65a3e18..e87c5f8 100644
@@ -363,6 +363,20 @@ static inline int runtime_exceeded(struct thread_data *td, struct timeval *t)
 	return 0;
 }
 
+/*
+ * We need to update the runtime consistently in ms, but keep a running
+ * tally of the current elapsed time in microseconds for sub millisecond
+ * updates.
+ */
+static inline void update_runtime(struct thread_data *td,
+				  unsigned long long *elapsed_us,
+				  const enum fio_ddir ddir)
+{
+	td->ts.runtime[ddir] -= (elapsed_us[ddir] + 999) / 1000;
+	elapsed_us[ddir] += utime_since_now(&td->start);
+	td->ts.runtime[ddir] += (elapsed_us[ddir] + 999) / 1000;
+}
+
 static int break_on_this_error(struct thread_data *td, enum fio_ddir ddir,
 			       int *retptr)
 {
@@ -1306,7 +1320,7 @@ static void io_workqueue_fn(struct thread_data *td, struct io_u *io_u)
  */
 static void *thread_main(void *data)
 {
-	unsigned long long elapsed;
+	unsigned long long elapsed_us[DDIR_RWDIR_CNT] = { 0, };
 	struct thread_data *td = data;
 	struct thread_options *o = &td->o;
 	pthread_condattr_t attr;
@@ -1544,18 +1558,12 @@ static void *thread_main(void *data)
 		check_update_rusage(td);
 
 		fio_mutex_down(stat_mutex);
-		if (td_read(td) && td->io_bytes[DDIR_READ]) {
-			elapsed = mtime_since_now(&td->start);
-			td->ts.runtime[DDIR_READ] += elapsed;
-		}
-		if (td_write(td) && td->io_bytes[DDIR_WRITE]) {
-			elapsed = mtime_since_now(&td->start);
-			td->ts.runtime[DDIR_WRITE] += elapsed;
-		}
-		if (td_trim(td) && td->io_bytes[DDIR_TRIM]) {
-			elapsed = mtime_since_now(&td->start);
-			td->ts.runtime[DDIR_TRIM] += elapsed;
-		}
+		if (td_read(td) && td->io_bytes[DDIR_READ])
+			update_runtime(td, elapsed_us, DDIR_READ);
+		if (td_write(td) && td->io_bytes[DDIR_WRITE])
+			update_runtime(td, elapsed_us, DDIR_WRITE);
+		if (td_trim(td) && td->io_bytes[DDIR_TRIM])
+			update_runtime(td, elapsed_us, DDIR_TRIM);
 		fio_gettime(&td->start, NULL);
 		fio_mutex_up(stat_mutex);
 
@@ -1579,7 +1587,7 @@ static void *thread_main(void *data)
 		check_update_rusage(td);
 
 		fio_mutex_down(stat_mutex);
-		td->ts.runtime[DDIR_READ] += mtime_since_now(&td->start);
+		update_runtime(td, elapsed_us, DDIR_READ);
 		fio_gettime(&td->start, NULL);
 		fio_mutex_up(stat_mutex);
 
blktrace.c +54 -24

168 lines not on this page · raw message

configure +21 -0
index 0b9874b..3b871ef 100755
@@ -721,6 +721,24 @@ fi
 echo "CLOCK_MONOTONIC               $clock_monotonic"
 
 ##########################################
+# CLOCK_MONOTONIC_RAW probe
+clock_monotonic_raw="no"
+if test "$clock_gettime" = "yes" ; then
+  cat > $TMPC << EOF
+#include <stdio.h>
+#include <time.h>
+int main(int argc, char **argv)
+{
+  return clock_gettime(CLOCK_MONOTONIC_RAW, NULL);
+}
+EOF
+  if compile_prog "" "$LIBS" "clock monotonic"; then
+      clock_monotonic_raw="yes"
+  fi
+fi
+echo "CLOCK_MONOTONIC_RAW           $clock_monotonic_raw"
+
+##########################################
 # CLOCK_MONOTONIC_PRECISE probe
 clock_monotonic_precise="no"
 if test "$clock_gettime" = "yes" ; then
@@ -1485,6 +1503,9 @@ fi
 if test "$clock_monotonic" = "yes" ; then
   output_sym "CONFIG_CLOCK_MONOTONIC"
 fi
+if test "$clock_monotonic_raw" = "yes" ; then
+  output_sym "CONFIG_CLOCK_MONOTONIC_RAW"
+fi
 if test "$clock_monotonic_precise" = "yes" ; then
   output_sym "CONFIG_CLOCK_MONOTONIC_PRECISE"
 fi
file.h +1 -0
index 22ec742..d5595c1 100644
@@ -78,6 +78,7 @@ struct fio_file {
 	 */
 	unsigned int major, minor;
 	int fileno;
+	int bs;
 	char *file_name;
 
 	/*
gettime.c +3 -1
index 180aa5f..ac54111 100644
@@ -133,7 +133,9 @@ static void fio_init gtod_init(void)
 #ifdef CONFIG_CLOCK_GETTIME
 static int fill_clock_gettime(struct timespec *ts)
 {
-#ifdef CONFIG_CLOCK_MONOTONIC
+#if defined(CONFIG_CLOCK_MONOTONIC_RAW)
+	return clock_gettime(CLOCK_MONOTONIC_RAW, ts);
+#elif defined(CONFIG_CLOCK_MONOTONIC)
 	return clock_gettime(CLOCK_MONOTONIC, ts);
 #else
 	return clock_gettime(CLOCK_REALTIME, ts);
t/lfsr-test.c +1 -1
index 901f1a6..4352b89 100644
@@ -122,7 +122,7 @@ int main(int argc, char *argv[])
 	if (verify)
 		printf("(slower due to verification)");
 	printf("\n==============================\n");
-	printf("Elapsed: %lf s\n", total / pow(10,9));
+	printf("Elapsed: %lf s\n", total / pow(10,6));
 	printf("Mean:    %lf us\n", mean);
 
 	free(v_start);