From: guzebing <guzebing1612@gmail.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: brauner@kernel.org, djwong@kernel.org, linux-xfs@vger.kernel.org,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
guzebing <guzebing@bytedance.com>,
Fengnan Chang <changfengnan@bytedance.com>
Subject: Re: [PATCH] iomap: add allocation cache for iomap_dio
Date: Mon, 5 Jan 2026 17:27:54 +0800 [thread overview]
Message-ID: <dc92f814-043c-45b2-8d2a-403f462434d4@gmail.com> (raw)
In-Reply-To: <aSA9VTO8vDPYZxNx@infradead.org>
在 2025/11/21 18:22, Christoph Hellwig 写道:
> On Fri, Nov 21, 2025 at 05:00:52PM +0800, guzebing wrote:
>> From: guzebing <guzebing@bytedance.com>
>>
>> As implemented by the bio structure, we do the same thing on the
>> iomap-dio structure. Add a per-cpu cache for iomap_dio allocations,
>> enabling us to quickly recycle them instead of going through the slab
>> allocator.
>>
>> By making such changes, we can reduce memory allocation on the direct
>> IO path, so that direct IO will not block due to insufficient system
>> memory. In addition, for direct IO, the read performance of io_uring
>> is improved by about 2.6%.
>
> Have you checked how much of that you'd get by using a dedicated
> slab cache that should also do per-cpu allocations? Note that even
> if we had a dedicated per-cpu cache we'd probably still want that.
I’m sorry for the long delay in replying to your email due to some other
matters. I hope you still remember this revision. First, thank you for
your response.
Yes, I try to use a dedicated kmem cache to allocate cache for iomap-dio
structure. However, when system memory is sufficient, kmalloc and kmem
cache deliver identical performance.
For direct I/O reads on the ext4 file system, the test command is:
./t/io_uring -p0 -d128 -b4096 -s32 -c32 -F1 -B1 -R1 -X1 -n1 -P1 /mnt/004.txt
The measured performance is:
kmalloc: 750K IOPS
kmem cache: 750K IOPS
per-CPU cache: 770K IOPS
>
> Also any chance you could factor this into common code?
>
For a mempool, we first allocate with kmalloc or kmem cache and finally
fall back to a reserved cache—this is for reliability. It’s not a great
fit for our high‑performance scenario.
Additionally, the current need for frequent allocation/free (hundreds of
thousands to millions of times per second) may be more suitable for the
bio or dio structures; beyond those, I’m not sure whether similar
scenarios exist.
If we were to extract a generic implementation solely for this, would it
yield significant benefits? Do you have any good suggestions?
I’d appreciate your review.
next prev parent reply other threads:[~2026-01-05 9:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-21 9:00 [PATCH] iomap: add allocation cache for iomap_dio guzebing
2025-11-21 10:22 ` Christoph Hellwig
2026-01-05 9:27 ` guzebing [this message]
2026-01-07 16:18 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=dc92f814-043c-45b2-8d2a-403f462434d4@gmail.com \
--to=guzebing1612@gmail.com \
--cc=brauner@kernel.org \
--cc=changfengnan@bytedance.com \
--cc=djwong@kernel.org \
--cc=guzebing@bytedance.com \
--cc=hch@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox