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: count allocated requests

Keep track of the number requests a ring currently has allocated (and
not freed), it'll be needed in the next patch.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/c8f8308294dc2a1cb8925d984d937d4fc14ab5d4.1746788718.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Pavel Begunkov and committed by
Jens Axboe
63de899c b0c8a640

+9 -1
+1
include/linux/io_uring_types.h
··· 435 435 436 436 /* protected by ->completion_lock */ 437 437 unsigned evfd_last_cq_tail; 438 + unsigned nr_req_allocated; 438 439 439 440 /* 440 441 * Protection for resize vs mmap races - both the mmap and resize
+8 -1
io_uring/io_uring.c
··· 957 957 } 958 958 959 959 percpu_ref_get_many(&ctx->refs, ret); 960 + ctx->nr_req_allocated += ret; 961 + 960 962 while (ret--) { 961 963 struct io_kiocb *req = reqs[ret]; 962 964 ··· 2696 2694 kmem_cache_free(req_cachep, req); 2697 2695 nr++; 2698 2696 } 2699 - if (nr) 2697 + if (nr) { 2698 + ctx->nr_req_allocated -= nr; 2700 2699 percpu_ref_put_many(&ctx->refs, nr); 2700 + } 2701 2701 mutex_unlock(&ctx->uring_lock); 2702 2702 } 2703 2703 ··· 2736 2732 percpu_ref_exit(&ctx->refs); 2737 2733 free_uid(ctx->user); 2738 2734 io_req_caches_free(ctx); 2735 + 2736 + WARN_ON_ONCE(ctx->nr_req_allocated); 2737 + 2739 2738 if (ctx->hash_map) 2740 2739 io_wq_put_hash(ctx->hash_map); 2741 2740 io_napi_free(ctx);