Files
android_kernel_xiaomi_sm8450/include/uapi/linux
Xiaoguang Wang 6d5f904904 io_uring: export cq overflow status to userspace
For those applications which are not willing to use io_uring_enter()
to reap and handle cqes, they may completely rely on liburing's
io_uring_peek_cqe(), but if cq ring has overflowed, currently because
io_uring_peek_cqe() is not aware of this overflow, it won't enter
kernel to flush cqes, below test program can reveal this bug:

static void test_cq_overflow(struct io_uring *ring)
{
        struct io_uring_cqe *cqe;
        struct io_uring_sqe *sqe;
        int issued = 0;
        int ret = 0;

        do {
                sqe = io_uring_get_sqe(ring);
                if (!sqe) {
                        fprintf(stderr, "get sqe failed\n");
                        break;;
                }
                ret = io_uring_submit(ring);
                if (ret <= 0) {
                        if (ret != -EBUSY)
                                fprintf(stderr, "sqe submit failed: %d\n", ret);
                        break;
                }
                issued++;
        } while (ret > 0);
        assert(ret == -EBUSY);

        printf("issued requests: %d\n", issued);

        while (issued) {
                ret = io_uring_peek_cqe(ring, &cqe);
                if (ret) {
                        if (ret != -EAGAIN) {
                                fprintf(stderr, "peek completion failed: %s\n",
                                        strerror(ret));
                                break;
                        }
                        printf("left requets: %d\n", issued);
                        continue;
                }
                io_uring_cqe_seen(ring, cqe);
                issued--;
                printf("left requets: %d\n", issued);
        }
}

int main(int argc, char *argv[])
{
        int ret;
        struct io_uring ring;

        ret = io_uring_queue_init(16, &ring, 0);
        if (ret) {
                fprintf(stderr, "ring setup failed: %d\n", ret);
                return 1;
        }

        test_cq_overflow(&ring);
        return 0;
}

To fix this issue, export cq overflow status to userspace by adding new
IORING_SQ_CQ_OVERFLOW flag, then helper functions() in liburing, such as
io_uring_peek_cqe, can be aware of this cq overflow and do flush accordingly.

Signed-off-by: Xiaoguang Wang <xiaoguang.wang@linux.alibaba.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2020-07-08 19:17:06 -06:00
..
2019-01-28 08:13:52 +01:00
2020-05-28 11:22:14 +02:00
2019-12-18 18:07:31 +01:00
2019-03-07 18:32:01 -08:00
2019-10-09 22:31:14 -04:00
2019-09-25 17:51:39 -07:00
2019-08-02 14:44:02 +10:00
2020-06-01 11:49:23 -07:00
2020-04-27 16:29:41 +05:30
2018-12-20 19:13:07 +01:00
2020-05-14 16:44:25 +02:00
2019-03-27 13:30:07 -07:00
2020-05-28 22:09:47 -04:00
2018-06-18 15:11:53 +10:00
2019-08-12 19:33:50 -07:00
2019-12-11 15:31:52 +01:00
2018-09-05 22:27:11 -07:00
2020-04-20 12:43:24 -07:00
2019-09-08 15:37:04 +02:00
2018-07-07 17:41:38 +02:00
2020-05-01 10:00:19 -04:00
2018-08-03 10:03:57 -07:00
2020-05-21 08:20:35 -06:00
2017-11-28 16:54:00 +01:00
2020-03-29 22:30:57 -07:00
2019-08-19 13:04:45 -07:00
2020-03-29 22:14:49 -07:00
2018-01-14 23:06:30 -05:00
2018-01-16 16:47:29 +01:00
2020-01-18 09:19:18 -05:00
2019-10-02 20:32:27 -06:00
2019-01-22 10:21:45 +01:00
2019-07-30 20:34:34 +02:00
2020-05-21 17:04:07 -07:00
2018-03-20 03:17:41 +02:00
2020-03-29 22:30:57 -07:00
2017-11-16 10:49:00 +09:00
2020-01-26 15:28:47 +01:00
2019-12-18 18:07:31 +01:00
2018-09-03 13:29:38 +02:00
2019-12-09 09:59:07 +01:00
2020-03-29 23:29:08 +02:00
2018-02-06 18:32:44 -08:00
2019-09-18 20:17:50 +02:00
2019-08-01 21:49:46 +02:00
2020-04-20 07:26:42 +02:00