Linux Test Project
 help / color / mirror / Atom feed
From: Martin Doucha <mdoucha@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] syscalls/io_submit: Flush IO completion queue
Date: Mon, 11 Apr 2022 11:44:24 +0200	[thread overview]
Message-ID: <20220411094424.15286-1-mdoucha@suse.cz> (raw)

Running io_submit01 or io_submit02 with high number of iterations
(e.g. io_submit01 -i 200) would result in bogus errors because the kernel
queue will get clogged with completed requests. Fix this by calling
io_getevents() to flush the completion queue.

Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---
 testcases/kernel/syscalls/io_submit/io_submit01.c | 8 +++++++-
 testcases/kernel/syscalls/io_submit/io_submit02.c | 9 +++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/io_submit/io_submit01.c b/testcases/kernel/syscalls/io_submit/io_submit01.c
index 28d93d7f1..db541fc01 100644
--- a/testcases/kernel/syscalls/io_submit/io_submit01.c
+++ b/testcases/kernel/syscalls/io_submit/io_submit01.c
@@ -114,13 +114,19 @@ static const char *errno_name(int err)
 static void verify_io_submit(unsigned int n)
 {
 	struct tcase *t = &tcases[n];
-	int ret;
+	struct io_event evbuf;
+	struct timespec timeout = { .tv_sec = 1 };
+	int i, ret;
 
 	ret = io_submit(*t->ctx, t->nr, t->iocbs);
 
 	if (ret == t->exp_errno) {
 		tst_res(TPASS, "io_submit() with %s failed with %s",
 			t->desc, errno_name(t->exp_errno));
+
+		for (i = 0; i < ret; i++)
+			io_getevents(*t->ctx, 1, 1, &evbuf, &timeout);
+
 		return;
 	}
 
diff --git a/testcases/kernel/syscalls/io_submit/io_submit02.c b/testcases/kernel/syscalls/io_submit/io_submit02.c
index acb42cb8f..38b8555d8 100644
--- a/testcases/kernel/syscalls/io_submit/io_submit02.c
+++ b/testcases/kernel/syscalls/io_submit/io_submit02.c
@@ -70,12 +70,21 @@ static void cleanup(void)
 
 static void run(unsigned int i)
 {
+	struct io_event evbuf;
+	struct timespec timeout = { .tv_sec = 1 };
+	long j;
+
 	TEST(tst_syscall(__NR_io_submit, *tc[i].ctx, tc[i].nr, tc[i].iocbs));
 
 	if (TST_RET == tc[i].nr)
 		tst_res(TPASS, "io_submit() %s", tc[i].desc);
 	else
 		tst_res(TFAIL, "io_submit() returns %ld, expected %ld", TST_RET, tc[i].nr);
+
+	for (j = 0; j < TST_RET; j++) {
+		tst_syscall(__NR_io_getevents, *tc[i].ctx, 1, 1, &evbuf,
+			&timeout);
+	}
 }
 
 static struct tst_test test = {
-- 
2.35.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

             reply	other threads:[~2022-04-11  9:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-11  9:44 Martin Doucha [this message]
2022-04-19  5:07 ` [LTP] [PATCH] syscalls/io_submit: Flush IO completion queue Petr Vorel

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=20220411094424.15286-1-mdoucha@suse.cz \
    --to=mdoucha@suse.cz \
    --cc=ltp@lists.linux.it \
    /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