From: Christoph Hellwig <hch@infradead.org>
To: Eric Biggers <ebiggers@kernel.org>
Cc: Yuwen Chen <ywen.chen@foxmail.com>,
hch@infradead.org, brauner@kernel.org, tytso@mit.edu,
linux-kernel@vger.kernel.org,
linux-f2fs-devel@lists.sourceforge.net, adilger.kernel@dilger.ca,
viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org,
jaegeuk@kernel.org, linux-ext4@vger.kernel.org
Subject: Re: [PATCH v3 1/2] libfs: reduce the number of memory allocations in generic_ci_match
Date: Sun, 6 Jul 2025 22:27:17 -0700 [thread overview]
Message-ID: <aGtatW8g2fV6bFkm@infradead.org> (raw)
In-Reply-To: <20250704060259.GB4199@sol>
On Thu, Jul 03, 2025 at 11:02:59PM -0700, Eric Biggers wrote:
[Can you trim your replies to the usual 73 characters? The long lines
make them quite hard to read without first reflowing them]
> The real problem is, once again, the legacy crypto_skcipher API, which requires
> that the source/destination buffers be provided as scatterlists. In Linux, the
> kernel stack can be in the vmalloc area. Thus, the buffers passed to
> crypto_skcipher cannot be stack buffers unless the caller actually is aware of
> how to turn a vmalloc'ed buffer into a scatterlist, which is hard to do. (See
> verity_ahash_update() in drivers/md/dm-verity-target.c for an example.)
I don't think setting up a scatterlist for vmalloc data is hard. But it is
extra boilerplate code that is rather annoying and adds overhead.
> code in the kernel uses is something that would be worth adopting for
> now in fname_decrypt(). As I mentioned above, it's hard to do (you
> have to go page by page), but it's possible. That would allow
> immediately moving generic_ci_match() to use a stack allocation, which
> would avoid adding all the complexity of the preallocation that you
> have in this patchset.
I suspect that all the overhead required for that get close to that of a
memory allocation.
But I wonder why generic_ci_match is even called that often. Both ext4
and f2fs support hashed lookups, so you should usually only see it called
for the main match, plus the occasional hash false positive, which should
be rate if the hash works.
Yuwen, are you using f2fs in the mode where it does a linear scan on a
hash lookup miss? That was added as a workaround for the utf8 code point
changes, but is a completely broken idea the defeats hashed lookups and
IIRC only was default for a very short time.
Note that even with this fixed, using an on-stack allocation would be
nice eventually when moving the crypto library API, as it would still
avoid the allocation entirely. But caching shouldn't be worth it if the
number of generic_ci_match per lookup is just slightly above 1.
next prev parent reply other threads:[~2025-07-07 5:27 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-03 8:21 [PATCH] f2fs: improve the performance of f2fs_lookup Yuwen Chen
2025-07-03 8:56 ` Christoph Hellwig
2025-07-04 2:43 ` [PATCH v3 1/2] libfs: reduce the number of memory allocations in generic_ci_match Yuwen Chen
2025-07-04 6:02 ` Eric Biggers
2025-07-07 5:27 ` Christoph Hellwig [this message]
2025-07-08 7:11 ` Yuwen Chen
[not found] ` <tencent_3B7E5FEB5DB445A5DC50E3F3AE4DE72A7908@qq.com>
2025-07-08 9:40 ` 回复: " Christoph Hellwig
2025-07-04 2:44 ` [PATCH v3 2/2] f2fs: improve the performance of f2fs_lookup Yuwen Chen
2025-07-03 9:54 ` [PATCH v2] " Yuwen Chen
2025-07-08 6:41 ` [PATCH v4 1/2] libfs: reduce the number of memory allocations in generic_ci_match Yuwen Chen
2025-07-09 2:42 ` [PATCH] f2fs: improve the performance of f2fs_lookup kernel test robot
-- strict thread matches above, loose matches on Subject: below --
2025-07-08 6:52 [PATCH v3 1/2] libfs: reduce the number of memory allocations in generic_ci_match ywen.chen
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=aGtatW8g2fV6bFkm@infradead.org \
--to=hch@infradead.org \
--cc=adilger.kernel@dilger.ca \
--cc=brauner@kernel.org \
--cc=ebiggers@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tytso@mit.edu \
--cc=viro@zeniv.linux.org.uk \
--cc=ywen.chen@foxmail.com \
/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;
as well as URLs for NNTP newsgroup(s).