On 8/22/20 12:14 PM, Zorro Lang wrote: >>> + if ((e = io_uring_submit(&ring)) != 1) { >>> + if (v) >>> + printf("%d/%d: %s - io_uring_submit failed %d\n", procid, opno, >>> + iswrite ? "uring_write" : "uring_read", e); >>> + goto uring_out1; >>> + } >>> + if ((e = io_uring_wait_cqe(&ring, &cqe)) < 0) { >>> + if (v) >>> + printf("%d/%d: %s - io_uring_wait_cqe failed %d\n", procid, opno, >>> + iswrite ? "uring_write" : "uring_read", e); >>> + goto uring_out1; >>> + } >> >> You could use io_uring_submit_and_wait() here, that'll save a system >> call for sync IO. Same comment goes for 4/4. > > Hi Jens, > > Sorry I think I haven't learned about io_uring enough, why the > io_uring_submit_and_wait can save a system call? Is it same with > io_uring_submit(), except a wait_nr ? The io_uring_wait_cqe() and > io_uring_cqe_seen() are still needed, right? If you just call io_uring_submit(), it'll enter the kernel and submit that IO. Then right after that you're saying "I want to wait for completion of a request", which is then another system call. If you do io_uring_submit_and_wait() you're entering the kernel with the intent of "submit my request(s), and wait for N requests" hence only doing a single system call even though it's an async interface. Nothing else changes, io_uring_wait_cqe() will not enter the kernel if a cqe is available in the ring already. -- Jens Axboe