public inbox for [email protected]
 help / color / mirror / Atom feed
From: yihao yang <[email protected]>
To: [email protected]
Subject: Wired result of OP_RECVMSG in EC2 environment
Date: Thu, 29 Apr 2021 22:44:00 -0700	[thread overview]
Message-ID: <CAKVAn+CUffHxN3XTTXjOHJvfXaz0KCzp-XKFq8iY7kX0wHnvKQ@mail.gmail.com> (raw)

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

                 reply	other threads:[~2021-04-30  5:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=CAKVAn+CUffHxN3XTTXjOHJvfXaz0KCzp-XKFq8iY7kX0wHnvKQ@mail.gmail.com \
    [email protected] \
    [email protected] \
    /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