Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support io_uring's IORING_SETUP_SQPOLL flag #255

Closed
3 tasks
tatetian opened this issue May 23, 2022 · 1 comment
Closed
3 tasks

Support io_uring's IORING_SETUP_SQPOLL flag #255

tatetian opened this issue May 23, 2022 · 1 comment

Comments

@tatetian
Copy link
Contributor

tatetian commented May 23, 2022

Motivation

To avoid exiting enclaves when submitting I/O requests, we want to push requests into io_uring's submission queue (by memory copying, thus no enclave switching) and let the Linux kernel poll requests from the submission queue (also by memory copying, thus no enclave switching). The latter is enabled with io_uring's IORING_SETUP_SQPOLL flag.

Problem

The problem is that the current implementation does not use IORING_SETUP_SQPOLL flag. This is because at the time when the code was written, Linux kernel's support for the submission queue polling was incomplete and buggy. So as a workaround, the implementation starts a separate OS thread that keeps invoking io_uring_enter system call. The workaround fulfils our demands of switchless I/O but do so at the expense of wasting CPU cycles.

Solution

As Linux's io_uring implementation gets mature, IORING_SETUP_SQPOLL flag now becomes fully supported since Linux kernel 5.11. And our development machine is installed with Linux kernel 5.11. So it is time for us to ditch the workaround and leverage IORING_SETUP_SQPOLL flag. Specifically, we need to

  • Upgrade the occlum/io-uring crate
    • The crate is a fork of tokio-rs/io-uring, with modifications to support SGX. The original tokio-rs/io-uring crate has added support for IORING_SETUP_SQPOLL.
    • Need to rebase our fork to the latest master branch of tokio-rs/io-uring
    • Make sure all unit tests pass, including the SGX sample code
  • Use the new occlum/io-uring in LibOS and other crates
    • Add the IORING_SETUP_SQPOLL flag when creating an io_uring instance
    • Set the sq_thread_idle parameter to a proper value, e.g., 500 milliseconds
    • Remove the workaround
  • Document the minimal requirement for Linux kernel is 5.11
@tatetian
Copy link
Contributor Author

tatetian commented Jun 2, 2022

It turns out that the current version of occlum/io-uring already includes the support for IORING_SETUP_SQPOLL. I tested it. And it worked. So I am going to close this issue.

@tatetian tatetian closed this as completed Jun 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant