Skip to contentSkip to conversation

Recent changes (master)

PATCH Jens Axboe 1 participant 1 message Oct 13, 2021 Kbuild

lore
Share & tools
lore

Jens Axboe

author
#0 lore raw

The following changes since commit c4cb947e8f92c10835164b67deed06828cfc01be:

io_u: don't attempt to requeue for full residual (2021-10-11 09:49:21 -0600)

are available in the Git repository at:

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

for you to fetch changes up to 702b0be2fe3b6cf5b3556920edaf0637a33b36e1:

t/io_uring: update for new DMA map buffers API (2021-10-12 18:41:14 -0600)

----------------------------------------------------------------
Brandon Paupore (1):
Query Windows clock frequency and use reported max

Erwan Velu (1):
t/one-core-peak: Improving check_sysblock_value error handling

Jens Axboe (6):
Merge branch 'windows-res' of https://github.com/bjpaupor/fio
t/io_uring: show IOPS in increments of 1000 IOPS if necessary Merge branch 'evelu-onecore' of https://github.com/ErwanAliasr1/fio
t/io_uring: fix silly identical branch error t/io_uring: add test support for pre mapping DMA buffers t/io_uring: update for new DMA map buffers API

 Makefile           |  4 ++--
 helper_thread.c    | 21 +++++++++-----------
 os/os.h            |  9 +++++++++
 os/windows/dlls.c  | 33 +++++++++++++++++++++++++++++++
 stat.c             |  4 ++++
 t/io_uring.c       | 57 +++++++++++++++++++++++++++++++++++++++++++++++++-----
 t/one-core-peak.sh |  5 ++---
 7 files changed, 111 insertions(+), 22 deletions(-)
 create mode 100644 os/windows/dlls.c

---

Diff of recent changes:

Makefile +2 -2
index 5198f70e..c3feb53f 100644
@@ -275,8 +275,8 @@ ifeq ($(CONFIG_TARGET_OS), Darwin)
   LIBS	 += -lpthread -ldl
 endif
 ifneq (,$(findstring CYGWIN,$(CONFIG_TARGET_OS)))
-  SOURCE += os/windows/cpu-affinity.c os/windows/posix.c
-  WINDOWS_OBJS = os/windows/cpu-affinity.o os/windows/posix.o lib/hweight.o
+  SOURCE += os/windows/cpu-affinity.c os/windows/posix.c os/windows/dlls.c
+  WINDOWS_OBJS = os/windows/cpu-affinity.o os/windows/posix.o os/windows/dlls.o lib/hweight.o
   LIBS	 += -lpthread -lpsapi -lws2_32 -lssp
   FIO_CFLAGS += -DPSAPI_VERSION=1 -Ios/windows/posix/include -Wno-format
 endif
helper_thread.c +9 -12
index d8e7ebfe..b9b83db3 100644
@@ -9,6 +9,10 @@
 #define DRD_IGNORE_VAR(x) do { } while (0)
 #endif
 
+#ifdef WIN32
+#include "os/os-windows.h"
+#endif
+
 #include "fio.h"
 #include "smalloc.h"
 #include "helper_thread.h"
@@ -283,19 +287,12 @@ static void *helper_thread_main(void *data)
 		}
 	};
 	struct timespec ts;
-	int clk_tck, ret = 0;
+	long clk_tck;
+	int ret = 0;
 
-#ifdef _SC_CLK_TCK
-	clk_tck = sysconf(_SC_CLK_TCK);
-#else
-	/*
-	 * The timer frequence is variable on Windows. Instead of trying to
-	 * query it, use 64 Hz, the clock frequency lower bound. See also
-	 * https://carpediemsystems.co.uk/2019/07/18/windows-system-timer-granularity/.
-	 */
-	clk_tck = 64;
-#endif
-	dprint(FD_HELPERTHREAD, "clk_tck = %d\n", clk_tck);
+	os_clk_tck(&clk_tck);
+
+	dprint(FD_HELPERTHREAD, "clk_tck = %ld\n", clk_tck);
 	assert(clk_tck > 0);
 	sleep_accuracy_ms = (1000 + clk_tck - 1) / clk_tck;
 
os/os.h +9 -0
index 827b61e9..5965d7b8 100644
@@ -412,4 +412,13 @@ static inline bool os_cpu_has(cpu_features feature)
 # define fio_mkdir(path, mode)	mkdir(path, mode)
 #endif
 
+#ifdef _SC_CLK_TCK
+static inline void os_clk_tck(long *clk_tck)
+{
+	*clk_tck = sysconf(_SC_CLK_TCK);
+}
+#else
+extern void os_clk_tck(long *clk_tck);
+#endif
+
 #endif /* FIO_OS_H */
os/windows/dlls.c new file +33 -0
new file mode 100644
index 00000000..774b1c61
@@ -0,0 +1,33 @@
+#include "os/os.h"
+
+#include <windows.h>
+
+void os_clk_tck(long *clk_tck)
+{
+	/*
+	 * The timer resolution is variable on Windows. Try to query it 
+	 * or use 64 Hz, the clock frequency lower bound. See also
+	 * https://carpediemsystems.co.uk/2019/07/18/windows-system-timer-granularity/.
+	 */
+	unsigned long minRes, maxRes, curRes;
+	HMODULE lib;
+	FARPROC queryTimer;
+	FARPROC setTimer;
+
+	if (!(lib = LoadLibrary(TEXT("ntdll.dll"))) ||
+		!(queryTimer = GetProcAddress(lib, "NtQueryTimerResolution")) ||
+		!(setTimer = GetProcAddress(lib, "NtSetTimerResolution"))) {
+		dprint(FD_HELPERTHREAD, 
+			"Failed to load ntdll library, set to lower bound 64 Hz\n");
+		*clk_tck = 64;
+	} else {
+		queryTimer(&minRes, &maxRes, &curRes);
+		dprint(FD_HELPERTHREAD, 
+			"minRes = %lu, maxRes = %lu, curRes = %lu\n",
+			minRes, maxRes, curRes);
+
+		/* Use maximum resolution for most accurate timestamps */
+		setTimer(maxRes, 1, &curRes);
+		*clk_tck = (long) (10000000L / maxRes);
+	}
+}
\ No newline at end of file
stat.c +4 -0
index ac53463d..30f9b5c1 100644
@@ -17,7 +17,11 @@
 #include "zbd.h"
 #include "oslib/asprintf.h"
 
+#ifdef WIN32
+#define LOG_MSEC_SLACK	2
+#else
 #define LOG_MSEC_SLACK	1
+#endif
 
 struct fio_sem *stat_sem;
 
t/io_uring.c +52 -5

123 lines not on this page · raw message

t/one-core-peak.sh +2 -3
index 11b1d69a..fba4ec95 100755
@@ -153,10 +153,9 @@ check_sysblock_value() {
   target_file="${sys_block_dir}/$2"
   value=$3
   [ -f "${target_file}" ] || return
-  content=$(cat ${target_file})
+  content=$(cat ${target_file} 2>/dev/null)
   if [ "${content}" != "${value}" ]; then
-    info "${device_name}" "${target_file} set to ${value}."
-    echo ${value} > ${target_file} 2>/dev/null || hint "${device_name}: Cannot set ${value} on ${target_file}"
+    echo ${value} > ${target_file} 2>/dev/null && info "${device_name}" "${target_file} set to ${value}." || hint "${device_name}: Cannot set ${value} on ${target_file}"
   fi
 }