occlum / ngo

Next-Gen Occlum, a work-in-progress fork of Occlum that is optimized for the next-generation of Intel SGX (on Xeon SP processors)
Other
33 stars 18 forks source link

Support io_uring's IORING_SETUP_SQPOLL flag #255

Closed tatetian closed 2 years ago

tatetian commented 2 years ago

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

tatetian commented 2 years ago

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.