Skip to contentSkip to conversation

couple of fixes to tests

PATCH RESEND Applied Gabriel Krisman Bertazi 2 participants 6 messages Aug 31 io_uring

lore
Share & tools
lore
#0 lore raw

cover couple of fixes to tests

Two unrelated fixes that I sent a while ago. Jiri Slaby reported iowait sporadic failures and while patch 1 doesn't fix all of them, it makes the test much more reliable. Patch 2 is a trivial fix to CI builds.

Gabriel Krisman Bertazi (2):
test/iowait.t: Skip if system is not quiesced for too long test/iopoll: Fix clang CI build failure

 test/iopoll.c |  5 +----
 test/iowait.c | 26 ++++++++++++++++++++------
 2 files changed, 21 insertions(+), 10 deletions(-)
Signature · 1 line
2.55.0
#1 lore raw

PATCH RESEND 1/2 test/iowait.t: Skip if system is not quiesced for too long

iowait.t reads the system-wide iowait metric, which is unreliable if the cpu is busy with other tasks. Identify this scenario by checking the user+sys time, and retry to avoid spurious failures.

---
 test/iowait.c | 26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)
test/iowait.c +20 -6
index 542510c1..610fa4ea 100644
@@ -11,7 +11,7 @@
 #include "liburing.h"
 #include "helpers.h"
 
-static int get_iowait(int cpu)
+static int get_iowait(int cpu, int *cpu_time)
 {
 	char cpu_buf[32], this_cpu[32];
 	int user, nice, system, idle, iowait, ret;
@@ -33,6 +33,7 @@ static int get_iowait(int cpu)
 			continue;
 		if (strncmp(cpu_buf, this_cpu, strlen(this_cpu)))
 			continue;
+		*cpu_time = user + system;
 		ret = iowait;
 		break;
 	} while (1);
@@ -45,14 +46,20 @@ static int test(struct io_uring *ring, int with_iowait, int cpu)
 {
 	struct io_uring_sqe *sqe;
 	struct io_uring_cqe *cqe;
-	int iowait_pre, iowait_post;
+	int iowait_pre, iowait_post, cputime_pre, cputime_post;
 	struct __kernel_timespec ts;
-	int ret, fds[2], diff;
+	int ret, fds[2], diff, diff_cputime, retry = 5;
 	char buf[32];
 
 	if (!(ring->features & IORING_FEAT_NO_IOWAIT))
 		return T_EXIT_SKIP;
 
+retry:
+	if (retry < 0) {
+		fprintf(stderr,
+			"System is not quiesced for too long. skipping\n");
+		return T_EXIT_SKIP;
+	}
 	if (pipe(fds) < 0) {
 		perror("pipe");
 		return T_EXIT_FAIL;
@@ -70,14 +77,15 @@ static int test(struct io_uring *ring, int with_iowait, int cpu)
 
 	ts.tv_sec = 1;
 	ts.tv_nsec = 0;
-	iowait_pre = get_iowait(cpu);
+	iowait_pre = get_iowait(cpu, &cputime_pre);
 	ret = io_uring_wait_cqe_timeout(ring, &cqe, &ts);
 	if (ret != -ETIME) {
 		fprintf(stderr, "Unexpected wait ret: %d\n", ret);
 		return T_EXIT_FAIL;
 	}
-	iowait_post = get_iowait(cpu);
+	iowait_post = get_iowait(cpu, &cputime_post);
 	diff = iowait_post - iowait_pre;
+	diff_cputime = cputime_post - cputime_pre;
 
 	close(fds[0]);
 	close(fds[1]);
@@ -91,7 +99,13 @@ static int test(struct io_uring *ring, int with_iowait, int cpu)
 
 	if (with_iowait) {
 		if (diff < 50) {
-			fprintf(stderr, "iowait diff too small: %d\n", diff);
+			if (diff_cputime > 10) {
+				/* System is not quiesced. iowait is unreliable. */
+				retry--;
+				sleep(2);
+				goto retry;
+			}
+			fprintf(stderr, "iowait diff too small: %d (u=%d)\n", diff, diff_cputime);
 			return T_EXIT_FAIL;
 		}
 	} else {
Signature · 1 line
2.55.0
#2 lore raw

PATCH RESEND 2/2 test/iopoll: Fix clang CI build failure

In reply to Gabriel Krisman Bertazi

Clang CI builds in liburing repo do -Werror,-Wunused-but-set-global when building with clang. commit c5eead26 ("test/iopoll: fix over-eager no_hybrid check") left a lingering variable that was not used, and clang got smart enough to find for it, causing the build to fail for every commit ever since.

https://github.com/axboe/liburing/actions/runs/30404555586/job/90427017716
https://github.com/axboe/liburing/actions/runs/30404555586/job/90427017742

Fixes c5eead26 ("test/iopoll: fix over-eager no_hybrid check")
---
 test/iopoll.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
test/iopoll.c +1 -4
index 98230657..d68fde10 100644
@@ -23,7 +23,6 @@
 static struct iovec *vecs;
 static int no_buf_select;
 static int no_iopoll;
-static int no_hybrid;
 
 static int provide_buffers(struct io_uring *ring)
 {
@@ -372,10 +371,8 @@ static int test_io(const char *file, int write, int sqthread, int fixed,
 		return 0;
 	}
 	if (ret != T_SETUP_OK) {
-		if (ring_flags & IORING_SETUP_HYBRID_IOPOLL) {
-			no_hybrid = 1;
+		if (ring_flags & IORING_SETUP_HYBRID_IOPOLL)
 			return 0;
-		}
 		fprintf(stderr, "ring create failed: %d\n", ret);
 		return 1;
 	}
Signature · 1 line
2.55.0
maintainer
#3 lore raw

Re: [RESEND PATCH liburing 2/2] test/iopoll: Fix clang CI build failure

Quoted 8 lines · Gabriel Krisman Bertazi

Clang CI builds in liburing repo do -Werror,-Wunused-but-set-global when building with clang. commit c5eead26 ("test/iopoll: fix over-eager no_hybrid check") left a lingering variable that was not used, and clang got smart enough to find for it, causing the build to fail for every commit ever since.

https://github.com/axboe/liburing/actions/runs/30404555586/job/90427017716
https://github.com/axboe/liburing/actions/runs/30404555586/job/90427017742

What's this against? Doesn't apply.

Signature · 1 line
Jens Axboe
#4 lore raw

Re: [RESEND PATCH liburing 2/2] test/iopoll: Fix clang CI build failure

Quoted 11 lines · Jens Axboe
Quoted 8 lines · Gabriel Krisman Bertazi

Clang CI builds in liburing repo do -Werror,-Wunused-but-set-global when building with clang. commit c5eead26 ("test/iopoll: fix over-eager no_hybrid check") left a lingering variable that was not used, and clang got smart enough to find for it, causing the build to fail for every commit ever since.

https://github.com/axboe/liburing/actions/runs/30404555586/job/90427017716
https://github.com/axboe/liburing/actions/runs/30404555586/job/90427017742

What's this against? Doesn't apply.

Ah, it was fixed by Ammar in parallel through a github PR:

ca274ec7 ("test: Remove unused global variables found by clang-23")

Thanks for merging the rest.

Signature · 1 line
Gabriel Krisman Bertazi
maintainer Applied
#5 lore raw

Re: (subset) [RESEND PATCH liburing 0/2] couple of fixes to tests

In reply to Gabriel Krisman Bertazi
Quoted 10 lines · Gabriel Krisman Bertazi

Two unrelated fixes that I sent a while ago. Jiri Slaby reported iowait sporadic failures and while patch 1 doesn't fix all of them, it makes the test much more reliable. Patch 2 is a trivial fix to CI builds.

Gabriel Krisman Bertazi (2):
test/iowait.t: Skip if system is not quiesced for too long test/iopoll: Fix clang CI build failure

[...]

Applied, thanks!

[1/2] test/iowait.t: Skip if system is not quiesced for too long

      commit: 4cf73437863c2e492d2a1d0f24330f391c0f075b

Best regards,

Signature · 1 line
Jens Axboe