Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

io_uring/fdinfo: handle mixed sized CQEs

Ensure that the CQ ring iteration handles differently sized CQEs, not
just a fixed 16b or 32b size per ring. These CQEs aren't possible just
yet, but prepare the fdinfo CQ ring dumping for handling them.

Signed-off-by: Jens Axboe <axboe@kernel.dk>

+12 -10
+12 -10
io_uring/fdinfo.c
··· 65 65 unsigned int sq_tail = READ_ONCE(r->sq.tail); 66 66 unsigned int cq_head = READ_ONCE(r->cq.head); 67 67 unsigned int cq_tail = READ_ONCE(r->cq.tail); 68 - unsigned int cq_shift = 0; 69 68 unsigned int sq_shift = 0; 70 - unsigned int sq_entries, cq_entries; 69 + unsigned int sq_entries; 71 70 int sq_pid = -1, sq_cpu = -1; 72 71 u64 sq_total_time = 0, sq_work_time = 0; 73 72 unsigned int i; 74 73 75 - if (ctx->flags & IORING_SETUP_CQE32) 76 - cq_shift = 1; 77 74 if (ctx->flags & IORING_SETUP_SQE128) 78 75 sq_shift = 1; 79 76 ··· 122 125 seq_printf(m, "\n"); 123 126 } 124 127 seq_printf(m, "CQEs:\t%u\n", cq_tail - cq_head); 125 - cq_entries = min(cq_tail - cq_head, ctx->cq_entries); 126 - for (i = 0; i < cq_entries; i++) { 127 - unsigned int entry = i + cq_head; 128 - struct io_uring_cqe *cqe = &r->cqes[(entry & cq_mask) << cq_shift]; 128 + while (cq_head < cq_tail) { 129 + struct io_uring_cqe *cqe; 130 + bool cqe32 = false; 129 131 132 + cqe = &r->cqes[(cq_head & cq_mask)]; 133 + if (cqe->flags & IORING_CQE_F_32 || ctx->flags & IORING_SETUP_CQE32) 134 + cqe32 = true; 130 135 seq_printf(m, "%5u: user_data:%llu, res:%d, flag:%x", 131 - entry & cq_mask, cqe->user_data, cqe->res, 136 + cq_head & cq_mask, cqe->user_data, cqe->res, 132 137 cqe->flags); 133 - if (cq_shift) 138 + if (cqe32) 134 139 seq_printf(m, ", extra1:%llu, extra2:%llu\n", 135 140 cqe->big_cqe[0], cqe->big_cqe[1]); 136 141 seq_printf(m, "\n"); 142 + cq_head++; 143 + if (cqe32) 144 + cq_head++; 137 145 } 138 146 139 147 if (ctx->flags & IORING_SETUP_SQPOLL) {