The zstd acomp streams retain their workspaces after the last transform has been freed. The first is allocated during transform initialization; additional per-CPU streams are allocated on demand. They are released when the algorithm is unregistered. In a 4 KiB-page x86-64 build, each stream requests 1,566,281 bytes. If kvmalloc() succeeds via kmalloc(), it occupies an order-9 block (2 MiB). vmalloc() needs 383 backing pages (1,532 KiB), 516 KiB fewer per stream. Across 384 populated streams, that is 193.5 MiB less workspace backing if all would have used kmalloc(). There is no such gain when kvmalloc() already falls back to vmalloc(). Use vmalloc() and vfree() directly to avoid the high-order allocation. This uses vmalloc address space, page tables and bookkeeping; the figures above compare workspace backing only. Signed-off-by: Usama Arif --- crypto/zstd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crypto/zstd.c b/crypto/zstd.c index 76bdaca327330..f012293919368 100644 --- a/crypto/zstd.c +++ b/crypto/zstd.c @@ -44,7 +44,7 @@ static void *zstd_alloc_stream(void) if (!wksp_size) return ERR_PTR(-EINVAL); - ctx = kvmalloc_flex(*ctx, wksp, wksp_size); + ctx = vmalloc(struct_size(ctx, wksp, wksp_size)); if (!ctx) return ERR_PTR(-ENOMEM); @@ -56,7 +56,7 @@ static void *zstd_alloc_stream(void) static void zstd_free_stream(void *ctx) { - kvfree(ctx); + vfree(ctx); } static struct crypto_acomp_streams zstd_streams = { -- 2.53.0-Meta