From: Gabriel Krisman Bertazi <krisman@suse.de>
To: axboe@kernel.dk
Cc: io-uring@vger.kernel.org, Gabriel Krisman Bertazi <krisman@suse.de>
Subject: [RESEND PATCH liburing 1/2] test/iowait.t: Skip if system is not quiesced for too long
Date: Mon, 31 Aug 2026 12:52:21 -0300 [thread overview]
Message-ID: <20260831155222.121857-2-krisman@suse.de> (raw)
In-Reply-To: <20260831155222.121857-1-krisman@suse.de>
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.
Signed-off-by: Gabriel Krisman Bertazi <krisman@suse.de>
---
test/iowait.c | 26 ++++++++++++++++++++------
1 file changed, 20 insertions(+), 6 deletions(-)
diff --git a/test/iowait.c b/test/iowait.c
index 542510c1..610fa4ea 100644
--- a/test/iowait.c
+++ b/test/iowait.c
@@ -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 {
--
2.55.0
next prev parent reply other threads:[~2026-08-31 15:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-31 15:52 [RESEND PATCH liburing 0/2] couple of fixes to tests Gabriel Krisman Bertazi
2026-08-31 15:52 ` Gabriel Krisman Bertazi [this message]
2026-08-31 15:52 ` [RESEND PATCH liburing 2/2] test/iopoll: Fix clang CI build failure Gabriel Krisman Bertazi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260831155222.121857-2-krisman@suse.de \
--to=krisman@suse.de \
--cc=axboe@kernel.dk \
--cc=io-uring@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox