Skip to contentSkip to conversation

fix runtime when used with thinktime

PATCH Applied Ankit Kumar 2 participants 3 messages Feb 17, 2023 – Feb 18, 2023 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): CGME20230217070403epcas5p1f2c7eec62578c28429e8029681f7d341@epcas5p1.samsung.com

#1 lore raw

cover fix runtime when used with thinktime

Runtime for fio jobs when used in conjuction with thinktime, thinktime_iotime and thinktime_spin were sometimes more than what is specified. Added a fix so that fio doesn't spin or sleep for any duration beyond runtime.

For the first cycle when we specify thinktime and thinktime_iotime, fio starts by doing I/O for thinktime + thinktime_iotime, which should just be for thinktime_iotime. Addedd a fix for that.

Ankit Kumar (1):
backend: fix runtime when used with thinktime

 backend.c | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)
Signature · 1 line
2.17.1
#2 lore raw

PATCH 1/1 backend: fix runtime when used with thinktime

Runtime for fio jobs when used in conjuction with thinktime, thinktime_iotime and thinktime_spin were sometimes more than what is specified. Add a fix so that fio doesn't spin or sleep for any duration beyond runtime.

For the first cycle fio starts by doing I/O for thinktime + thinktime_iotime, which should just be for thinktime_iotime. Add a fix for that.

---
 backend.c | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)
backend.c +20 -4
index 0ccc7c2b..995be032 100644
@@ -866,6 +866,7 @@ static void handle_thinktime(struct thread_data *td, enum fio_ddir ddir,
 			     struct timespec *time)
 {
 	unsigned long long b;
+	unsigned long long runtime_left;
 	uint64_t total;
 	int left;
 	struct timespec now;
@@ -874,7 +875,7 @@ static void handle_thinktime(struct thread_data *td, enum fio_ddir ddir,
 	if (td->o.thinktime_iotime) {
 		fio_gettime(&now, NULL);
 		if (utime_since(&td->last_thinktime, &now)
-		    >= td->o.thinktime_iotime + td->o.thinktime) {
+		    >= td->o.thinktime_iotime) {
 			stall = true;
 		} else if (!fio_option_is_set(&td->o, thinktime_blocks)) {
 			/*
@@ -897,11 +898,24 @@ static void handle_thinktime(struct thread_data *td, enum fio_ddir ddir,
 
 	io_u_quiesce(td);
 
+	left = td->o.thinktime_spin;
+	if (td->o.timeout) {
+		runtime_left = td->o.timeout - utime_since_now(&td->epoch);
+		if (runtime_left < (unsigned long long)left)
+			left = runtime_left;
+	}
+
 	total = 0;
-	if (td->o.thinktime_spin)
-		total = usec_spin(td->o.thinktime_spin);
+	if (left)
+		total = usec_spin(left);
 
 	left = td->o.thinktime - total;
+	if (td->o.timeout) {
+		runtime_left = td->o.timeout - utime_since_now(&td->epoch);
+		if (runtime_left < (unsigned long long)left)
+			left = runtime_left;
+	}
+
 	if (left)
 		total += usec_sleep(td, left);
 
@@ -930,8 +944,10 @@ static void handle_thinktime(struct thread_data *td, enum fio_ddir ddir,
 		fio_gettime(time, NULL);
 
 	td->last_thinktime_blocks = b;
-	if (td->o.thinktime_iotime)
+	if (td->o.thinktime_iotime) {
+		fio_gettime(&now, NULL);
 		td->last_thinktime = now;
+	}
 }
 
 /*
Signature · 1 line
2.17.1
Applied
#3 lore raw
In reply to Ankit Kumar
Quoted 10 lines · Ankit Kumar

Runtime for fio jobs when used in conjuction with thinktime, thinktime_iotime and thinktime_spin were sometimes more than what is specified. Added a fix so that fio doesn't spin or sleep for any duration beyond runtime.

For the first cycle when we specify thinktime and thinktime_iotime, fio starts by doing I/O for thinktime + thinktime_iotime, which should just be for thinktime_iotime. Addedd a fix for that.

[...]

Applied, thanks!

[1/1] backend: fix runtime when used with thinktime

      commit: f9fc7a27cae5ea2dbb310c05f7b693c68ba15537

Best regards,

Signature · 1 line
Jens Axboe