diff options
author | Jens Axboe <axboe@kernel.dk> | 2022-07-07 22:20:54 +0200 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2022-07-25 02:39:17 +0200 |
commit | 9731bc9855dc169f27433fef3c4d0ff3496c512d (patch) | |
tree | b28facb6c0ee4796e2787a5c736231a73520993f /io_uring/io_uring.c | |
parent | io_uring: add abstraction around apoll cache (diff) | |
download | linux-9731bc9855dc169f27433fef3c4d0ff3496c512d.tar.xz linux-9731bc9855dc169f27433fef3c4d0ff3496c512d.zip |
io_uring: impose max limit on apoll cache
Caches like this tend to grow to the peak size, and then never get any
smaller. Impose a max limit on the size, to prevent it from growing too
big.
A somewhat randomly chosen 512 is the max size we'll allow the cache
to get. If a batch of frees come in and would bring it over that, we
simply start kfree'ing the surplus.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring/io_uring.c')
-rw-r--r-- | io_uring/io_uring.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index a360a3d390c6..c9c23e459766 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -1181,7 +1181,8 @@ void io_free_batch_list(struct io_ring_ctx *ctx, struct io_wq_work_node *node) if (apoll->double_poll) kfree(apoll->double_poll); - io_alloc_cache_put(&ctx->apoll_cache, &apoll->cache); + if (!io_alloc_cache_put(&ctx->apoll_cache, &apoll->cache)) + kfree(apoll); req->flags &= ~REQ_F_POLLED; } if (req->flags & IO_REQ_LINK_FLAGS) |