From: Pavel Begunkov <asml.silence@gmail.com>
To: io-uring@vger.kernel.org
Cc: asml.silence@gmail.com
Subject: [PATCH liburing v4 3/3] test/query: signal query loop
Date: Tue, 14 Oct 2025 16:02:57 +0100 [thread overview]
Message-ID: <d81ccb3c3e3114cedf9434033c0ad496c7186650.1760453798.git.asml.silence@gmail.com> (raw)
In-Reply-To: <cover.1760453798.git.asml.silence@gmail.com>
Instead of relying on the kernel limiting the number of queries in a
chain, send a signal. That must be able to abort the syscall.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
test/ring-query.c | 41 ++++++++++++++++++++++++++---------------
1 file changed, 26 insertions(+), 15 deletions(-)
diff --git a/test/ring-query.c b/test/ring-query.c
index e266b4a9..4c335d64 100644
--- a/test/ring-query.c
+++ b/test/ring-query.c
@@ -5,11 +5,14 @@
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
+#include <pthread.h>
#include "liburing.h"
#include "test.h"
#include "helpers.h"
+pthread_barrier_t barrier;
+
struct io_uring_query_opcode_short {
__u32 nr_request_opcodes;
__u32 nr_register_opcodes;
@@ -153,9 +156,8 @@ static int test_chain(void)
return T_EXIT_PASS;
}
-static int test_chain_loop(void)
+static void *chain_loop_thread(void *arg)
{
- int ret;
struct io_uring_query_opcode op1 = {}, op2 = {};
struct io_uring_query_hdr hdr2 = {
.query_op = IO_URING_QUERY_OPCODES,
@@ -167,27 +169,36 @@ static int test_chain_loop(void)
.query_data = uring_ptr_to_u64(&op1),
.size = sizeof(struct io_uring_query_opcode),
};
- struct io_uring_query_hdr hdr_self_circular = {
- .query_op = IO_URING_QUERY_OPCODES,
- .query_data = uring_ptr_to_u64(&op1),
- .size = sizeof(struct io_uring_query_opcode),
- .next_entry = uring_ptr_to_u64(&hdr_self_circular),
- };
hdr1.next_entry = uring_ptr_to_u64(&hdr2);
hdr2.next_entry = uring_ptr_to_u64(&hdr1);
- ret = io_uring_query(NULL, &hdr1);
- if (!ret) {
- fprintf(stderr, "chain loop failed %i\n", ret);
+
+ pthread_barrier_wait(&barrier);
+
+ (void)io_uring_query(NULL, &hdr1);
+ return NULL;
+}
+
+static int test_chain_loop(void)
+{
+ pthread_t thread;
+ int ret;
+
+ ret = pthread_barrier_init(&barrier, NULL, 2);
+ if (ret != 0) {
+ fprintf(stderr, "pthread_barrier_init failed %i\n", ret);
return T_EXIT_FAIL;
}
-
- ret = io_uring_query(NULL, &hdr_self_circular);
- if (!ret) {
- fprintf(stderr, "chain loop failed %i\n", ret);
+ if (pthread_create(&thread, NULL, chain_loop_thread, NULL) != 0) {
+ fprintf(stderr, "pthread_create failed %i\n", ret);
return T_EXIT_FAIL;
}
+ pthread_barrier_wait(&barrier);
+ sleep(1);
+ pthread_kill(thread, SIGKILL);
+ pthread_join(thread, NULL);
+ pthread_barrier_destroy(&barrier);
return T_EXIT_PASS;
}
--
2.49.0
prev parent reply other threads:[~2025-10-14 15:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-14 15:02 [PATCH liburing v4 0/3] some query related updates Pavel Begunkov
2025-10-14 15:02 ` [PATCH liburing v4 1/3] tests/query: get rid of uninit struct warnings Pavel Begunkov
2025-10-14 15:02 ` [PATCH liburing v4 2/3] register: expose a query helper Pavel Begunkov
2025-10-14 15:02 ` Pavel Begunkov [this message]
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=d81ccb3c3e3114cedf9434033c0ad496c7186650.1760453798.git.asml.silence@gmail.com \
--to=asml.silence@gmail.com \
--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