From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CFB1E61FCE; Thu, 20 Feb 2025 15:24:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740065082; cv=none; b=e2SeE4gzLEdrHjORGCFgbts6SN3jJJsyuwpaN9BupX7ulgsL/9Ugr1ua0MQzBz1dqbo2SVH+uZo1JxtK1WgbtzlmLIMzG0bdlTSkik6werZMDbgrm0XoDMf/lbVVb8Tv+YGxNU7Vg2dbcloTwrkuvBTgnkpjmSbBY9h+GIWxbGw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740065082; c=relaxed/simple; bh=knlLdW6Swx8MuQSnlA0afzhfyq5d+s+vBtjJqU1jTFg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=aCsC/u8aAV2623jQfbTCN+Oh5gN9cMPSbhcpg+90eifn0LzhONsn6O9/9JxgZiWVAZDmOb/eRuXTnV5MkVMN6ap0ftA6tMy7DlTfFz5dBglR2MX7h5b+ctJNto4gc771LGkUcxt1qlnNCdHN1Sx+sQ79kzOSWFYdx7IFbSmIzps= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=aJeYKIqW; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="aJeYKIqW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BC4E7C4CED1; Thu, 20 Feb 2025 15:24:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740065082; bh=knlLdW6Swx8MuQSnlA0afzhfyq5d+s+vBtjJqU1jTFg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=aJeYKIqW2xtbtr2a6o4Nr66cdvAQfMb9st7j15Hq6wCDMqpkdU6tlvjukgr2ZHCs4 Fufpim6q9Fg5nTZ40rqLpRiNm8shV1oVrzkL0on+Uho7Eow0r9BFUqLBsr+I+uNWhF 6G0cByQzIiQAx3xioFvZBycxy7SEitCVTu5V3KTb/qU/oow+Tb3ywEpArP9PDz2dKm OJoOh7QHJF51y8bkUoc9MugcBjvmQ4RSufYALjmFG3HQeSEwyWl3hXPKjKcKGSKcWN 2R5MXHzJJ983ymElflYGUMpWQhgMOkydcgI2kCGFtpe9amtE4FqtTqUZzC+BJkhlGi 219VuTSZqUuaA== Date: Thu, 20 Feb 2025 08:24:39 -0700 From: Keith Busch To: Pavel Begunkov Cc: Keith Busch , ming.lei@redhat.com, axboe@kernel.dk, linux-block@vger.kernel.org, io-uring@vger.kernel.org, bernd@bsbernd.com, csander@purestorage.com Subject: Re: [PATCHv4 5/5] io_uring: cache nodes and mapped buffers Message-ID: References: <20250218224229.837848-1-kbusch@meta.com> <20250218224229.837848-6-kbusch@meta.com> Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Thu, Feb 20, 2025 at 11:08:25AM +0000, Pavel Begunkov wrote: > On 2/18/25 22:42, Keith Busch wrote: > > From: Keith Busch > > > > Frequent alloc/free cycles on these is pretty costly. Use an io cache to > > more efficiently reuse these buffers. > > > > Signed-off-by: Keith Busch > > --- > > 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(-) > > > > diff --git a/include/linux/io_uring_types.h b/include/linux/io_uring_types.h > > index 810d1dccd27b1..bbfb651506522 100644 > > --- a/include/linux/io_uring_types.h > > +++ b/include/linux/io_uring_types.h > > @@ -69,8 +69,18 @@ struct io_file_table { > > unsigned int alloc_hint; > ... > > -struct io_rsrc_node *io_rsrc_node_alloc(int type) > > +struct io_rsrc_node *io_rsrc_node_alloc(struct io_ring_ctx *ctx, int type) > > { > > struct io_rsrc_node *node; > > - node = kzalloc(sizeof(*node), GFP_KERNEL); > > + if (type == IORING_RSRC_FILE) > > + node = kmalloc(sizeof(*node), GFP_KERNEL); > > + else > > + node = io_cache_alloc(&ctx->buf_table.node_cache, GFP_KERNEL); > > That's why node allocators shouldn't be a part of the buffer table. Are you saying you want file nodes to also subscribe to the cache? The two tables can be resized independently of each other, we don't know how many elements the cache needs to hold.