Skip to contentSkip to conversation

Recent changes (master)

PATCH Jens Axboe 1 participant 1 message Jan 4, 2020 Kbuild

lore
Share & tools
lore

Jens Axboe

author
#0 lore raw

The following changes since commit aae515f4e1cb0b3c003e127200d344d807032a79:

io_uring: Enable io_uring ioengine on aarch64 arch (2019-12-25 08:02:57 -0700)

are available in the Git repository at:

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

for you to fetch changes up to 235b09b68d9bbc5150891faca47f5397d7e806bb:

Merge branch 'master' of https://github.com/bvanassche/fio (2020-01-03 21:00:17 -0700)

----------------------------------------------------------------
Bart Van Assche (9):
Micro-optimize __load_ioengine()
Suppress a Coverity taint warning in check_status_file()
Makefile: Build more test code
Use CLOCK_MONOTONIC for condition variables used by pthread_cond_timedwait() t/read-to-pipe-async: Use the monotonic clock when measuring time intervals Fix a potential deadlock in helper_do_stat()
.appveyor.yml: Convert to ASCII
Only build t/read-to-pipe-async if pread() is available
Improve the pthread_condattr_setclock() test

Jens Axboe (5):
Merge branch 'unit1' of https://github.com/kusumi/fio
Merge branch 'master' of https://github.com/bvanassche/fio
Revert "Fix a potential deadlock in helper_do_stat()" Merge branch 'master' of https://github.com/kenbarr1/fio
Merge branch 'master' of https://github.com/bvanassche/fio

Ken Barr (1):
io_u: fix rate limiting to handle file wrap-around

Tomohiro Kusumi (2):
unittests: add unittest suite for oslib/strcasestr.c
unittests: add unittest suite for oslib/strsep.c

 .appveyor.yml                |   2 +-
 Makefile                     |  11 +++++
 configure                    |  45 ++++++++++++++++++
 fio_sem.c                    |  11 +++--
 helper_thread.c              |  17 ++++---
 idletime.c                   |  16 ++++++-
 io_u.c                       |   2 +-
 ioengines.c                  |  11 ++---
 pshared.c                    |   9 ++++
 stat.c                       |   3 ++
 t/read-to-pipe-async.c       |  68 +++++++++++++++++----------
 unittests/oslib/strcasestr.c |  87 +++++++++++++++++++++++++++++++++++
 unittests/oslib/strsep.c     | 107 +++++++++++++++++++++++++++++++++++++++++++
 unittests/unittest.c         |   2 +
 unittests/unittest.h         |   2 +
 15 files changed, 348 insertions(+), 45 deletions(-)
 create mode 100644 unittests/oslib/strcasestr.c
 create mode 100644 unittests/oslib/strsep.c

---

Diff of recent changes:

.appveyor.yml +1 -1
index f6934096..4fb0a90d 100644
@@ -14,7 +14,7 @@ environment:
 
 install:
   - '%CYG_ROOT%\setup-x86_64.exe --quiet-mode --no-shortcuts --only-site --site "%CYG_MIRROR%" --packages "mingw64-%PACKAGE_ARCH%-zlib,mingw64-%PACKAGE_ARCH%-CUnit" > NUL'
-  - SET PATH=C:\Python38-x64;%CYG_ROOT%\bin;%PATH% #��NB: Changed env variables persist to later sections
+  - SET PATH=C:\Python38-x64;%CYG_ROOT%\bin;%PATH% # NB: Changed env variables persist to later sections
   - python.exe -m pip install scipy
 
 build_script:
Makefile +11 -0
index 4a07fab3..dd26afca 100644
@@ -313,6 +313,13 @@ T_TEST_PROGS += $(T_GEN_RAND_PROGS)
 T_PROGS += $(T_BTRACE_FIO_PROGS)
 T_PROGS += $(T_DEDUPE_PROGS)
 T_PROGS += $(T_VS_PROGS)
+T_TEST_PROGS += $(T_MEMLOCK_PROGS)
+ifdef CONFIG_PREAD
+T_TEST_PROGS += $(T_PIPE_ASYNC_PROGS)
+endif
+ifneq (,$(findstring Linux,$(CONFIG_TARGET_OS)))
+T_TEST_PROGS += $(T_IOU_RING_PROGS)
+endif
 
 PROGS += $(T_PROGS)
 
@@ -322,10 +329,14 @@ UT_OBJS += unittests/lib/memalign.o
 UT_OBJS += unittests/lib/strntol.o
 UT_OBJS += unittests/oslib/strlcat.o
 UT_OBJS += unittests/oslib/strndup.o
+UT_OBJS += unittests/oslib/strcasestr.o
+UT_OBJS += unittests/oslib/strsep.o
 UT_TARGET_OBJS = lib/memalign.o
 UT_TARGET_OBJS += lib/strntol.o
 UT_TARGET_OBJS += oslib/strlcat.o
 UT_TARGET_OBJS += oslib/strndup.o
+UT_TARGET_OBJS += oslib/strcasestr.o
+UT_TARGET_OBJS += oslib/strsep.o
 UT_PROGS = unittests/unittest
 else
 UT_OBJS =
configure +45 -0

69 lines not on this page · raw message

fio_sem.c +7 -4
index 3b48061c..c34d8bf7 100644
@@ -85,16 +85,19 @@ static bool sem_timed_out(struct timespec *t, unsigned int msecs)
 
 int fio_sem_down_timeout(struct fio_sem *sem, unsigned int msecs)
 {
-	struct timeval tv_s;
 	struct timespec base;
 	struct timespec t;
 	int ret = 0;
 
 	assert(sem->magic == FIO_SEM_MAGIC);
 
-	gettimeofday(&tv_s, NULL);
-	base.tv_sec = t.tv_sec = tv_s.tv_sec;
-	base.tv_nsec = t.tv_nsec = tv_s.tv_usec * 1000;
+#ifdef CONFIG_PTHREAD_CONDATTR_SETCLOCK
+	clock_gettime(CLOCK_MONOTONIC, &t);
+#else
+	clock_gettime(CLOCK_REALTIME, &t);
+#endif
+
+	base = t;
 
 	t.tv_sec += msecs / 1000;
 	t.tv_nsec += ((msecs * 1000000ULL) % 1000000000);
helper_thread.c +10 -7
index f0c717f5..eba2898a 100644
@@ -78,15 +78,16 @@ static void *helper_thread_main(void *data)
 {
 	struct helper_data *hd = data;
 	unsigned int msec_to_next_event, next_log, next_ss = STEADYSTATE_MSEC;
-	struct timeval tv;
 	struct timespec ts, last_du, last_ss;
 	int ret = 0;
 
 	sk_out_assign(hd->sk_out);
 
-	gettimeofday(&tv, NULL);
-	ts.tv_sec = tv.tv_sec;
-	ts.tv_nsec = tv.tv_usec * 1000;
+#ifdef CONFIG_PTHREAD_CONDATTR_SETCLOCK
+	clock_gettime(CLOCK_MONOTONIC, &ts);
+#else
+	clock_gettime(CLOCK_REALTIME, &ts);
+#endif
 	memcpy(&last_du, &ts, sizeof(ts));
 	memcpy(&last_ss, &ts, sizeof(ts));
 
@@ -101,9 +102,11 @@ static void *helper_thread_main(void *data)
 		pthread_mutex_lock(&hd->lock);
 		pthread_cond_timedwait(&hd->cond, &hd->lock, &ts);
 
-		gettimeofday(&tv, NULL);
-		ts.tv_sec = tv.tv_sec;
-		ts.tv_nsec = tv.tv_usec * 1000;
+#ifdef CONFIG_PTHREAD_CONDATTR_SETCLOCK
+		clock_gettime(CLOCK_MONOTONIC, &ts);
+#else
+		clock_gettime(CLOCK_REALTIME, &ts);
+#endif
 
 		if (hd->reset) {
 			memcpy(&last_du, &ts, sizeof(ts));
idletime.c +14 -2
index 2f59f510..fc1df8e9 100644
@@ -186,6 +186,7 @@ void fio_idle_prof_init(void)
 	int i, ret;
 	struct timespec ts;
 	pthread_attr_t tattr;
+	pthread_condattr_t cattr;
 	struct idle_prof_thread *ipt;
 
 	ipc.nr_cpus = cpus_online();
@@ -194,6 +195,13 @@ void fio_idle_prof_init(void)
 	if (ipc.opt == IDLE_PROF_OPT_NONE)
 		return;
 
+	ret = pthread_condattr_init(&cattr);
+	assert(ret == 0);
+#ifdef CONFIG_PTHREAD_CONDATTR_SETCLOCK
+	ret = pthread_condattr_setclock(&cattr, CLOCK_MONOTONIC);
+	assert(ret == 0);
+#endif
+
 	if ((ret = pthread_attr_init(&tattr))) {
 		log_err("fio: pthread_attr_init %s\n", strerror(ret));
 		return;
@@ -239,7 +247,7 @@ void fio_idle_prof_init(void)
 			break;
 		}
 
-		if ((ret = pthread_cond_init(&ipt->cond, NULL))) {
+		if ((ret = pthread_cond_init(&ipt->cond, &cattr))) {
 			ipc.status = IDLE_PROF_STATUS_ABORT;
 			log_err("fio: pthread_cond_init %s\n", strerror(ret));
 			break;
@@ -282,7 +290,11 @@ void fio_idle_prof_init(void)
 		pthread_mutex_lock(&ipt->init_lock);
 		while ((ipt->state != TD_EXITED) &&
 		       (ipt->state!=TD_INITIALIZED)) {
-			fio_gettime(&ts, NULL);
+#ifdef CONFIG_PTHREAD_CONDATTR_SETCLOCK
+			clock_gettime(CLOCK_MONOTONIC, &ts);
+#else
+			clock_gettime(CLOCK_REALTIME, &ts);
+#endif
 			ts.tv_sec += 1;
 			pthread_cond_timedwait(&ipt->cond, &ipt->init_lock, &ts);
 		}
io_u.c +1 -1
index b5c31335..4a0c725a 100644
@@ -644,7 +644,7 @@ static enum fio_ddir rate_ddir(struct thread_data *td, enum fio_ddir ddir)
 	uint64_t now;
 
 	assert(ddir_rw(ddir));
-	now = utime_since_now(&td->start);
+	now = utime_since_now(&td->epoch);
 
 	/*
 	 * if rate_next_io_time is in the past, need to catch up to rate
ioengines.c +4 -7
index 9e3fcc9f..b9200ba9 100644
@@ -121,18 +121,15 @@ static struct ioengine_ops *dlopen_ioengine(struct thread_data *td,
 	return ops;
 }
 
-static struct ioengine_ops *__load_ioengine(const char *name)
+static struct ioengine_ops *__load_ioengine(const char *engine)
 {
-	char engine[64];
-
-	snprintf(engine, sizeof(engine), "%s", name);
-
 	/*
 	 * linux libaio has alias names, so convert to what we want
 	 */
 	if (!strncmp(engine, "linuxaio", 8)) {
-		dprint(FD_IO, "converting ioengine name: %s -> libaio\n", name);
-		strcpy(engine, "libaio");
+		dprint(FD_IO, "converting ioengine name: %s -> libaio\n",
+		       engine);
+		engine = "libaio";
 	}
 
 	dprint(FD_IO, "load ioengine %s\n", engine);
pshared.c +9 -0
index 74812ede..21192556 100644
@@ -21,6 +21,15 @@ int cond_init_pshared(pthread_cond_t *cond)
 		return ret;
 	}
 #endif
+
+#ifdef CONFIG_PTHREAD_CONDATTR_SETCLOCK
+	ret = pthread_condattr_setclock(&cattr, CLOCK_MONOTONIC);
+	if (ret) {
+		log_err("pthread_condattr_setclock: %s\n", strerror(ret));
+		return ret;
+	}
+#endif
+
 	ret = pthread_cond_init(cond, &cattr);
 	if (ret) {
 		log_err("pthread_cond_init: %s\n", strerror(ret));
stat.c +3 -0
index 05663e07..e2bc8ddb 100644
@@ -2123,6 +2123,9 @@ static int check_status_file(void)
 	}
 	if (temp_dir == NULL)
 		temp_dir = "/tmp";
+#ifdef __COVERITY__
+	__coverity_tainted_data_sanitize__(temp_dir);
+#endif
 
 	snprintf(fio_status_file_path, sizeof(fio_status_file_path), "%s/%s", temp_dir, FIO_STATUS_FILE);
 
t/read-to-pipe-async.c +45 -23

166 lines not on this page · raw message

unittests/oslib/strcasestr.c new file +87 -0

87 lines not on this page · raw message

unittests/oslib/strsep.c new file +107 -0

107 lines not on this page · raw message

unittests/unittest.c +2 -0
index 1166e6ef..66789e4f 100644
@@ -62,6 +62,8 @@ int main(void)
 	fio_unittest_register(fio_unittest_lib_strntol);
 	fio_unittest_register(fio_unittest_oslib_strlcat);
 	fio_unittest_register(fio_unittest_oslib_strndup);
+	fio_unittest_register(fio_unittest_oslib_strcasestr);
+	fio_unittest_register(fio_unittest_oslib_strsep);
 
 	CU_basic_set_mode(CU_BRM_VERBOSE);
 	CU_basic_run_tests();
unittests/unittest.h +2 -0
index d3e3822f..bbc49613 100644
@@ -22,5 +22,7 @@ CU_ErrorCode fio_unittest_lib_memalign(void);
 CU_ErrorCode fio_unittest_lib_strntol(void);
 CU_ErrorCode fio_unittest_oslib_strlcat(void);
 CU_ErrorCode fio_unittest_oslib_strndup(void);
+CU_ErrorCode fio_unittest_oslib_strcasestr(void);
+CU_ErrorCode fio_unittest_oslib_strsep(void);
 
 #endif