* Wired result of OP_RECVMSG in EC2 environment
@ 2021-04-30 5:44 yihao yang
0 siblings, 0 replies; only message in thread
From: yihao yang @ 2021-04-30 5:44 UTC (permalink / raw)
To: io-uring
Hi folks,
Need some help on using Liburing 0.6.
I am trying io_uring in EC2 environment (kernel version
5.4.95-47.164.amzn2int.x86_64, github
https://github.com/amazonlinux/linux/tree/kernel-5.4.95-47.164.amzn2int).
The test code logic is simple. I use one uring and two threads.
One thread is continuously submitting nonblocking recvmsg from a TCP socket
struct msghdr msg;
struct io_uring_sqe* sqe = nullptr;
memset(&msg, 0, sizeof(msg));
msg.msg_iov = iov;
msg.msg_iovlen = count;
sqe = io_uring_get_sqe(m_ring);
io_uring_prep_recvmsg(sqe, sockfd, &msg, 0);
sqe->user_data = (uint64_t) context;
int ret = io_uring_submit(m_ring);
if (ret < 0) {
GLOG(ERRO, "failed to submit io: %d", ret);
}
Another thread is continuously polling by calling io_uring_wait_cqes.
struct io_uring_cqe *cqe = nullptr;
while (!m_stopped) {
int ret = ::io_uring_wait_cqes(m_ring, &cqe, 0, nullptr, nullptr);
if (ret != 0) {
if (ret != -EAGAIN) {
GLOG(ERRO, "cqe wait failed: %d", ret);
}
continue;
}
::io_uring_cqe_seen(m_ring, cqe);
void *ctx = ::io_uring_cqe_get_data(cqe);
if (ctx == nullptr || cqe->res == 0) {
continue;
}
if (cqe->res != -EAGAIN) {
// For some reason, randomly I will get EMSGSIZE or
EINVAL. Retry on the same sockfd will succeed.
GLOG(ERRO, "cqe: %p %d %llu", cqe, cqe->res, cqe->user_data);
}
int err = (cqe->res > 0) ? 0 : -cqe->res;
int transferred = (err == 0) ? cqe->res : 0;
}
Would like to know what could be the reason for the random EMSGSIZE or
EINVAL error (see comments above).
Thanks a lot.
Yihao
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-04-30 5:44 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-30 5:44 Wired result of OP_RECVMSG in EC2 environment yihao yang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox