Re: [PATCHv5 11/11] io_uring: cache nodes and mapped buffers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2/24/25 21:31, Keith Busch wrote:
From: Keith Busch <kbusch@xxxxxxxxxx>

Frequent alloc/free cycles on these is pretty costly. Use an io cache to
more efficiently reuse these buffers.

Signed-off-by: Keith Busch <kbusch@xxxxxxxxxx>
---
  include/linux/io_uring_types.h |  18 ++---
  io_uring/filetable.c           |   2 +-
  io_uring/rsrc.c                | 120 +++++++++++++++++++++++++--------
  io_uring/rsrc.h                |   2 +-
  4 files changed, 104 insertions(+), 38 deletions(-)

...
+static __cold int io_rsrc_buffer_alloc(struct io_buf_table *table, unsigned nr)
+{
+	const int imu_cache_size = struct_size_t(struct io_mapped_ubuf, bvec,
+						 IO_CACHED_BVECS_SEGS);
+	const int node_size = sizeof(struct io_rsrc_node);
+	int ret;
+
+	ret = io_rsrc_data_alloc(&table->data, nr);
+	if (ret)
+		return ret;
+
+	if (io_alloc_cache_init(&table->node_cache, nr, node_size, 0))

We shouldn't use nr for the cache size, that could be unreasonably
huge for a cache. Let's use a constant for now and that should be
good enough, at least for now. 64 would be a good default. Same for
the imu cache.

--
Pavel Begunkov





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux