[英]io_uring: io_uring_wait_cqe_nr, io_uring_peek_batch_cqe
I want to experiment io_uring on the github project: https://github.com/alexhultman/io_uring_epoll_benchmark我想在github项目上试验io_uring: https ://github.com/alexhultman/io_uring_epoll_benchmark
referrence: https://unixism.net/loti/ref-liburing/completion.html参考: https ://unixism.net/loti/ref-liburing/completion.html
however I stumbled upon 2 functions:但是我偶然发现了两个功能:
unsigned io_uring_peek_batch_cqe(struct io_uring *ring, struct io_uring_cqe **cqes, unsigned count)无符号 io_uring_peek_batch_cqe(结构 io_uring *ring,结构 io_uring_cqe **cqes,无符号计数)
int io_uring_wait_cqe_nr(struct io_uring *ring, struct io_uring_cqe **cqe_ptr, unsigned wait_nr) int io_uring_wait_cqe_nr(结构 io_uring *ring,结构 io_uring_cqe **cqe_ptr,无符号 wait_nr)
I understand that the first functions will fills in an array of I/O completions up to count to the cqes and will return regardless of how many cqes completions我知道第一个函数将填充一个 I/O 完成数组,直到 cqes 计数,并且无论有多少 cqes 完成都会返回
However the second functions only fills in one I/O completions to the cqes even I wait for wait_nr completions, why is this so, if it wait for specific number of cqes completions, why i didn't fill in the array of I/O like the first function did?然而,即使我等待 wait_nr 完成,第二个函数也只向 cqes 填充一个 I/O 完成,为什么会这样,如果它等待特定数量的 cqes 完成,为什么我没有填写 I/O 数组像第一个功能一样吗?
like example i create: #define MAX_BATCH 2000比如我创建的例子:#define MAX_BATCH 2000
struct io_uring_cqe **cqes = malloc(sizeof(struct io_uring_cqe *) * MAX_BATCH);结构 io_uring_cqe **cqes = malloc(sizeof(struct io_uring_cqe *) * MAX_BATCH);
if I run on the first function, i could access cqes[i] i = (0 to completions)如果我在第一个函数上运行,我可以访问 cqes[i] i = (0 to completions)
if I run on the second function, I can only access cqes[i] i = 0如果我在第二个函数上运行,我只能访问 cqes[i] i = 0
I need to understand why the second function never update the array of cqes like the first function did我需要了解为什么第二个函数永远不会像第一个函数那样更新 cqes 数组
I've solved it, As the second function:我已经解决了,作为第二个功能:
int io_uring_wait_cqe_nr(struct io_uring *ring, struct io_uring_cqe **cqe_ptr, unsigned wait_nr) int io_uring_wait_cqe_nr(结构 io_uring *ring,结构 io_uring_cqe **cqe_ptr,无符号 wait_nr)
will wait until for wait_nr completions cqe to complete before moving on, and it will return cqe I/O completions and update only the first array of cqes, which is cqes[0],将等到 wait_nr 完成 cqe 完成后再继续,它将返回 cqe I/O 完成并仅更新 cqes 的第一个数组,即 cqes[0],
But for the first function:但是对于第一个功能:
unsigned io_uring_peek_batch_cqe(struct io_uring *ring, struct io_uring_cqe **cqes, unsigned count)无符号 io_uring_peek_batch_cqe(结构 io_uring *ring,结构 io_uring_cqe **cqes,无符号计数)
will return regardless whether or not theres a cqe, and will return the numbers of cqes and the array of cqes I/O无论是否有 cqe 都将返回,并将返回 cqes 的数量和 cqes I/O 的数组
After checking the struct of cqes whether the asynchronous was done properly, mark it with the function:在检查 cqes 的 struct 是否正确完成异步后,用函数标记它:
void io_uring_cq_advance(struct io_uring *ring, struct io_uring_cqe *cqe, unsigned count) to free up the cqes entries so the next cqes will point to cqes[0] void io_uring_cq_advance(struct io_uring *ring, struct io_uring_cqe *cqe, unsigned count) 释放 cqes 条目,以便下一个 cqes 指向 cqes[0]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.