Wired result of OP_RECVMSG in EC2 environment

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux