diff --git a/io_uring/fdinfo.c b/io_uring/fdinfo.c index a87d4e26eee8..80178b69e05a 100644 --- a/io_uring/fdinfo.c +++ b/io_uring/fdinfo.c @@ -67,7 +67,7 @@ static void __io_uring_show_fdinfo(struct io_ring_ctx *ctx, struct seq_file *m) unsigned int cq_head = READ_ONCE(r->cq.head); unsigned int cq_tail = READ_ONCE(r->cq.tail); unsigned int sq_shift = 0; - unsigned int sq_entries; + unsigned int cq_entries, sq_entries; int sq_pid = -1, sq_cpu = -1; u64 sq_total_time = 0, sq_work_time = 0; unsigned int i; @@ -146,9 +146,11 @@ static void __io_uring_show_fdinfo(struct io_ring_ctx *ctx, struct seq_file *m) } } seq_printf(m, "\n"); + cond_resched(); } seq_printf(m, "CQEs:\t%u\n", cq_tail - cq_head); - while (cq_head < cq_tail) { + cq_entries = min(cq_tail - cq_head, ctx->cq_entries); + for (i = 0; i < cq_entries; i++) { struct io_uring_cqe *cqe; bool cqe32 = false; @@ -159,12 +161,15 @@ static void __io_uring_show_fdinfo(struct io_ring_ctx *ctx, struct seq_file *m) cq_head & cq_mask, cqe->user_data, cqe->res, cqe->flags); if (cqe32) - seq_printf(m, ", extra1:%llu, extra2:%llu\n", + seq_printf(m, ", extra1:%llu, extra2:%llu", cqe->big_cqe[0], cqe->big_cqe[1]); seq_printf(m, "\n"); cq_head++; - if (cqe32) + if (cqe32) { cq_head++; + i++; + } + cond_resched(); } if (ctx->flags & IORING_SETUP_SQPOLL) { diff --git a/io_uring/zcrx.c b/io_uring/zcrx.c index b99cf2c6670a..3d398283cf34 100644 --- a/io_uring/zcrx.c +++ b/io_uring/zcrx.c @@ -197,6 +197,7 @@ static int io_import_umem(struct io_zcrx_ifq *ifq, GFP_KERNEL_ACCOUNT); if (ret) { unpin_user_pages(pages, nr_pages); + kvfree(pages); return ret; } @@ -1068,8 +1069,6 @@ static unsigned zcrx_parse_rq(netmem_ref *netmem_array, unsigned nr, unsigned int mask = zcrx->rq_entries - 1; unsigned int i; - guard(spinlock_bh)(&zcrx->rq_lock); - nr = min(nr, io_zcrx_rqring_entries(zcrx)); for (i = 0; i < nr; i++) { struct io_uring_zcrx_rqe *rqe = io_zcrx_get_rqe(zcrx, mask); @@ -1114,9 +1113,11 @@ static int zcrx_flush_rq(struct io_ring_ctx *ctx, struct io_zcrx_ifq *zcrx, return -EINVAL; do { - nr = zcrx_parse_rq(netmems, ZCRX_FLUSH_BATCH, zcrx); + scoped_guard(spinlock_bh, &zcrx->rq_lock) { + nr = zcrx_parse_rq(netmems, ZCRX_FLUSH_BATCH, zcrx); + zcrx_return_buffers(netmems, nr); + } - zcrx_return_buffers(netmems, nr); total += nr; if (fatal_signal_pending(current))