aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2024-02-14 13:10:13 -0700
committerJens Axboe <axboe@kernel.dk>2024-02-14 13:10:13 -0700
commitf49d641e4914ade8bed4b3542686fe9d5df380fa (patch)
tree4e14267a16429214bd5956c24953af3b52c16d81
parente8447308e0b54d23e487afb8cbe3cb34636d5ec7 (diff)
downloadliburing-f49d641e4914ade8bed4b3542686fe9d5df380fa.tar.gz
examples/napi: add option for DEFER_TASKRUN
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--examples/napi-busy-poll-client.c13
-rw-r--r--examples/napi-busy-poll-server.c13
2 files changed, 22 insertions, 4 deletions
diff --git a/examples/napi-busy-poll-client.c b/examples/napi-busy-poll-client.c
index bf8cabe1..4ae0354f 100644
--- a/examples/napi-busy-poll-client.c
+++ b/examples/napi-busy-poll-client.c
@@ -72,6 +72,7 @@ struct options
__u32 timeout;
bool sq_poll;
+ bool defer_tw;
bool busy_loop;
bool prefer_busy_poll;
bool ipv6;
@@ -301,7 +302,7 @@ int main(int argc, char *argv[])
memset(&opt, 0, sizeof(struct options));
// Process flags.
- while ((flag = getopt_long(argc, argv, ":hsbua:n:p:t:6", longopts, NULL)) != -1) {
+ while ((flag = getopt_long(argc, argv, ":hsbua:n:p:t:6d:", longopts, NULL)) != -1) {
switch (flag) {
case 'a':
strcpy(opt.addr, optarg);
@@ -331,6 +332,9 @@ int main(int argc, char *argv[])
case '6':
opt.ipv6 = true;
break;
+ case 'd':
+ opt.defer_tw = !!atoi(optarg);
+ break;
case ':':
printError("Missing argument", optopt);
printUsage(argv[0]);
@@ -397,9 +401,14 @@ int main(int argc, char *argv[])
memset(&ts, 0, sizeof(ts));
memset(&napi, 0, sizeof(napi));
- if (opt.sq_poll) {
+ params.flags = IORING_SETUP_SINGLE_ISSUER;
+ if (opt.defer_tw) {
+ params.flags |= IORING_SETUP_DEFER_TASKRUN;
+ } else if (opt.sq_poll) {
params.flags = IORING_SETUP_SQPOLL;
params.sq_thread_idle = 50;
+ } else {
+ params.flags |= IORING_SETUP_COOP_TASKRUN;
}
ret = io_uring_queue_init_params(RINGSIZE, &ctx.ring, &params);
diff --git a/examples/napi-busy-poll-server.c b/examples/napi-busy-poll-server.c
index a1bd17c5..9a4d1226 100644
--- a/examples/napi-busy-poll-server.c
+++ b/examples/napi-busy-poll-server.c
@@ -70,6 +70,7 @@ struct options
__u32 timeout;
bool listen;
+ bool defer_tw;
bool sq_poll;
bool busy_loop;
bool prefer_busy_poll;
@@ -262,7 +263,7 @@ int main(int argc, char *argv[])
memset(&opt, 0, sizeof(struct options));
// Process flags.
- while ((flag = getopt_long(argc, argv, ":lhsbua:n:p:t:6", longopts, NULL)) != -1) {
+ while ((flag = getopt_long(argc, argv, ":lhsbua:n:p:t:6d:", longopts, NULL)) != -1) {
switch (flag) {
case 'a':
strcpy(opt.addr, optarg);
@@ -295,6 +296,9 @@ int main(int argc, char *argv[])
case '6':
opt.ipv6 = true;
break;
+ case 'd':
+ opt.defer_tw = !!atoi(optarg);
+ break;
case ':':
printError("Missing argument", optopt);
printUsage(argv[0]);
@@ -361,9 +365,14 @@ int main(int argc, char *argv[])
memset(&ts, 0, sizeof(ts));
memset(&napi, 0, sizeof(napi));
- if (opt.sq_poll) {
+ params.flags = IORING_SETUP_SINGLE_ISSUER;
+ if (opt.defer_tw) {
+ params.flags |= IORING_SETUP_DEFER_TASKRUN;
+ } else if (opt.sq_poll) {
params.flags = IORING_SETUP_SQPOLL;
params.sq_thread_idle = 50;
+ } else {
+ params.flags |= IORING_SETUP_COOP_TASKRUN;
}
ret = io_uring_queue_init_params(RINGSIZE, &ctx.ring, &params);