All of lore.kernel.org
 help / color / mirror / Atom feed
From: Usama Arif <usama.arif@linux.dev>
To: Usama Arif <usama.arif@linux.dev>
Cc: davem@davemloft.net, dsterba@suse.com,
	Herbert Xu <herbert@gondor.apana.org.au>,
	linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
	terrelln@fb.com, terrelln@meta.com, cyan@meta.com,
	hannes@cmpxchg.org, yosry@kernel.org, nphamcs@gmail.com,
	chengming.zhou@linux.dev, shakeel.butt@linux.dev,
	kernel-team@meta.com
Subject: Re: [PATCH 0/2] crypto: zstd - avoid initializing the workspace twice
Date: Tue,  8 Sep 2026 08:37:13 -0700	[thread overview]
Message-ID: <20260908153715.3063790-1-usama.arif@linux.dev> (raw)
In-Reply-To: <20260825220616.3842633-1-usama.arif@linux.dev>

On Tue, 25 Aug 2026 15:06:00 -0700 Usama Arif <usama.arif@linux.dev> wrote:

> Both zstd_compress() and zstd_decompress() set up the shared per-CPU
> workspace as a C/DStream before walking the request, and then, when the
> first source and destination fragments each span the whole request, hand
> off to zstd_compress_one()/zstd_decompress_one(), which immediately
> overwrite that same ctx->wksp with a CCtx/DCtx. The stream setup is
> discarded without a byte having been processed.
> 
> That one-shot path is not a corner case: zswap always takes it when
> storing, and takes it for a load whenever the stored object lies within a
> single zsmalloc page.
> 
> These two patches defer the stream initialization to the first walk
> iteration that actually streams, guarded by a flag because that iteration
> can be reached more than once.
> 
> A 4 KiB crypto_acomp benchmark [1], twelve runs of nine 30,000-operation
> rounds. Bare metal is an Intel Xeon Platinum 8321HC, turbo off,
> performance governor, pinned to one core; the VM is a one-vCPU KVM guest
> on a faster host.
> 
>                   baseline    patched     delta
>   bare metal
>     compress      52,283 ns   51,038 ns   1,245 ns   2.4%
>     decompress     2,317 ns    1,998 ns     319 ns  13.8%
>   one-vCPU KVM
>     compress      16,675 ns   15,050 ns   1,625 ns   9.8%
>     decompress     3,516 ns    2,265 ns   1,251 ns  35.6%
> 
> The guest numbers are larger because the two CPUID instructions in
> ZSTD_cpuid() become unconditional VM exits there. 
> 
> [1] https://gist.github.com/uarif1/5cf02f0e22c23f0d1b3d84348f12914c

Hi,

Just wanted to check if there was any feedback or review of the series.

I think its a nice optimization and even with the CPUID instructions
getting cached [1], this is still needed. The improvement in baremetal
is not coming (just) from CPUID instructions.

[1] https://lore.kernel.org/all/20260901110850.1805747-1-usama.arif@linux.dev/

Thanks,
Usama

  parent reply	other threads:[~2026-09-08 15:37 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-25 22:06 [PATCH 0/2] crypto: zstd - avoid initializing the workspace twice Usama Arif
2026-08-25 22:06 ` [PATCH 1/2] crypto: zstd - Avoid redundant cstream initialization Usama Arif
2026-09-10 22:58   ` Nick Terrell
2026-08-25 22:06 ` [PATCH 2/2] crypto: zstd - Avoid redundant dstream initialization Usama Arif
2026-08-25 22:27 ` [PATCH 0/2] crypto: zstd - avoid initializing the workspace twice Yosry Ahmed
2026-08-26 12:17   ` Usama Arif
2026-09-08 15:37 ` Usama Arif [this message]
2026-09-10 22:30   ` Nick Terrell
2026-09-11  5:27 ` Herbert Xu

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=20260908153715.3063790-1-usama.arif@linux.dev \
    --to=usama.arif@linux.dev \
    --cc=chengming.zhou@linux.dev \
    --cc=cyan@meta.com \
    --cc=davem@davemloft.net \
    --cc=dsterba@suse.com \
    --cc=hannes@cmpxchg.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=kernel-team@meta.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nphamcs@gmail.com \
    --cc=shakeel.butt@linux.dev \
    --cc=terrelln@fb.com \
    --cc=terrelln@meta.com \
    --cc=yosry@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.