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: deduplicate caches deallocation

Add a function that frees all ring caches since we already have two
spots repeating the same thing and it's easy to miss it and change only
one of them.

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

authored by

Pavel Begunkov and committed by
Jens Axboe
40b99183 7d568502

+12 -12
+12 -12
io_uring/io_uring.c
··· 282 282 return 0; 283 283 } 284 284 285 + static void io_free_alloc_caches(struct io_ring_ctx *ctx) 286 + { 287 + io_alloc_cache_free(&ctx->apoll_cache, kfree); 288 + io_alloc_cache_free(&ctx->netmsg_cache, io_netmsg_cache_free); 289 + io_alloc_cache_free(&ctx->rw_cache, io_rw_cache_free); 290 + io_alloc_cache_free(&ctx->uring_cache, kfree); 291 + io_alloc_cache_free(&ctx->msg_cache, kfree); 292 + io_futex_cache_free(ctx); 293 + } 294 + 285 295 static __cold struct io_ring_ctx *io_ring_ctx_alloc(struct io_uring_params *p) 286 296 { 287 297 struct io_ring_ctx *ctx; ··· 370 360 free_ref: 371 361 percpu_ref_exit(&ctx->refs); 372 362 err: 373 - io_alloc_cache_free(&ctx->apoll_cache, kfree); 374 - io_alloc_cache_free(&ctx->netmsg_cache, io_netmsg_cache_free); 375 - io_alloc_cache_free(&ctx->rw_cache, io_rw_cache_free); 376 - io_alloc_cache_free(&ctx->uring_cache, kfree); 377 - io_alloc_cache_free(&ctx->msg_cache, kfree); 378 - io_futex_cache_free(ctx); 363 + io_free_alloc_caches(ctx); 379 364 kvfree(ctx->cancel_table.hbs); 380 365 xa_destroy(&ctx->io_bl_xa); 381 366 kfree(ctx); ··· 2707 2702 io_sqe_files_unregister(ctx); 2708 2703 io_cqring_overflow_kill(ctx); 2709 2704 io_eventfd_unregister(ctx); 2710 - io_alloc_cache_free(&ctx->apoll_cache, kfree); 2711 - io_alloc_cache_free(&ctx->netmsg_cache, io_netmsg_cache_free); 2712 - io_alloc_cache_free(&ctx->rw_cache, io_rw_cache_free); 2713 - io_alloc_cache_free(&ctx->uring_cache, kfree); 2714 - io_alloc_cache_free(&ctx->msg_cache, kfree); 2715 - io_futex_cache_free(ctx); 2705 + io_free_alloc_caches(ctx); 2716 2706 io_destroy_buffers(ctx); 2717 2707 io_free_region(ctx, &ctx->param_region); 2718 2708 mutex_unlock(&ctx->uring_lock);