]> www.infradead.org Git - users/jedix/linux-maple.git/commit
f2fs: use vmalloc instead of kvmalloc in .init_{,de}compress_ctx
authorChao Yu <chao@kernel.org>
Tue, 13 May 2025 05:57:20 +0000 (13:57 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Tue, 27 May 2025 23:52:35 +0000 (23:52 +0000)
commit70dd07c888451503c3e93b6821e10d1ea1ec9930
tree4c5255885d664337896d79742f79291ad7582f34
parent5827e3c720e5a881bf97451e3c280445f67cba04
f2fs: use vmalloc instead of kvmalloc in .init_{,de}compress_ctx

.init_{,de}compress_ctx uses kvmalloc() to alloc memory, it will try
to allocate physically continuous page first, it may cause more memory
allocation pressure, let's use vmalloc instead to mitigate it.

[Test]
cd /data/local/tmp
touch file
f2fs_io setflags compression file
f2fs_io getflags file
for i in $(seq 1 10); do sync; echo 3 > /proc/sys/vm/drop_caches;\
time f2fs_io write 512 0 4096 zero osync file; truncate -s 0 file;\
done

[Result]
Before After Delta
21.243 21.694 -2.12%

For compression, we recommend to use ioctl to compress file data in
background for workaround.

For decompression, only zstd will be affected.

Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/compress.c
fs/f2fs/f2fs.h