From: sashiko-bot@kernel.org
To: "Ashish Kalra" <Ashish.Kalra@amd.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH v7 5/6] KVM: SEV: Perform RMP optimizations on SNP guest shutdown
Date: Mon, 08 Jun 2026 19:12:25 +0000 [thread overview]
Message-ID: <20260608191225.96BF81F00893@smtp.kernel.org> (raw)
In-Reply-To: <bfefc8564ae28a05be565d60e8857173d9c1ae7c.1780903370.git.ashish.kalra@amd.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The RMPOPT batching logic fails to optimize memory for guests that terminate shortly before an already-pending workqueue timer expires.
--
commit 855d23e84feebfc7b3cebafc11cb0b8453330a11
Author: Ashish Kalra <ashish.kalra@amd.com>
KVM: SEV: Perform RMP optimizations on SNP guest shutdown
This commit triggers an RMP optimization pass after an SNP guest
terminates to take advantage of pages being converted back to shared.
It batches the work so that a single optimization pass can cover
multiple guests terminating within a short period.
> diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
> index 4272293478766..0e94f81907ec2 100644
> --- a/arch/x86/kvm/svm/sev.c
> +++ b/arch/x86/kvm/svm/sev.c
> @@ -2992,6 +2992,8 @@ void sev_vm_destroy(struct kvm *kvm)
> */
> if (snp_decommission_context(kvm))
> return;
> +
> + snp_rmpopt_all_physmem();
[Severity: Medium]
Does calling snp_rmpopt_all_physmem() here trigger the optimization pass
too early in the KVM teardown sequence?
sev_vm_destroy() runs during kvm_arch_destroy_vm(), which executes before
kvm_free_memslots() where the actual conversion of guest memory from private
to shared occurs.
Additionally, looking at snp_rmpopt_all_physmem() in arch/x86/virt/svm/sev.c,
it appears to use queue_delayed_work() rather than mod_delayed_work():
queue_delayed_work(rmpopt_wq, &rmpopt_delayed_work,
msecs_to_jiffies(RMPOPT_WORK_TIMEOUT));
Because queue_delayed_work() does not reset the timer of an already-queued
work item, the timer is not extended when subsequent guests terminate.
If a second guest terminates just before the pending RMPOPT work item executes,
the optimization pass will run concurrently with or prior to the second guest's
kvm_free_memslots(). Since the second guest's memory is still private at that
point, the RMPOPT pass would skip it, leaving the memory unoptimized and
causing a performance regression for RMP checks.
Would it be safer to use mod_delayed_work() to ensure the timer is properly
extended, and perhaps trigger the pass after the memslots have actually been
freed?
> } else {
> sev_unbind_asid(kvm, sev->handle);
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1780903370.git.ashish.kalra@amd.com?part=5
next prev parent reply other threads:[~2026-06-08 19:12 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-08 18:56 [PATCH v7 0/6] Add RMPOPT support Ashish Kalra
2026-06-08 18:56 ` [PATCH v7 1/6] x86/cpufeatures: Add X86_FEATURE_RMPOPT feature flag Ashish Kalra
2026-06-08 18:56 ` [PATCH v7 2/6] x86/sev: Initialize RMPOPT configuration MSRs Ashish Kalra
2026-06-08 19:17 ` sashiko-bot
2026-06-08 18:56 ` [PATCH v7 3/6] x86/sev: Add support to perform RMP optimizations asynchronously Ashish Kalra
2026-06-08 19:12 ` sashiko-bot
2026-06-08 18:57 ` [PATCH v7 4/6] x86/sev: Add interface to re-enable RMP optimizations Ashish Kalra
2026-06-08 18:57 ` [PATCH v7 5/6] KVM: SEV: Perform RMP optimizations on SNP guest shutdown Ashish Kalra
2026-06-08 19:12 ` sashiko-bot [this message]
2026-06-08 18:57 ` [PATCH v7 6/6] x86/sev: Add debugfs support for RMPOPT Ashish Kalra
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=20260608191225.96BF81F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Ashish.Kalra@amd.com \
--cc=kvm@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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.