Re: [PATCH v13 5/5] x86/sev: Re-enable RMP optimizations on SNP guest shutdown

From: Borislav Petkov

Date: Sun Sep 06 2026 - 13:25:13 EST


On Wed, Sep 02, 2026 at 09:29:21PM +0000, Ashish Kalra wrote:
> + /*
> + * Perform RMP optimizations on memory freed by terminating
> + * guests. The scan is deferred, so it normally runs after
> + * sev_gmem_invalidate() has converted this guest's pages back to
> + * shared, and picks them up then. A very large guest whose
> + * conversion has not finished by then is picked up by a later
> + * teardown's scan.
> + */

Move that comment over the function definition.

> +/*
> + * Delay, in milliseconds, before the RMP re-optimization pass runs after an
> + * SNP guest is torn down. snp_rmpopt_all_physmem() re-arms the delayed work
> + * with mod_delayed_work() on each teardown, so the pass fires this long after
> + * the last teardown. This coalesces a burst of teardowns into a single scan
> + * and gives each guest's pages time to be converted back to the shared,
> + * hypervisor-owned state before the scan re-optimizes their 1GB regions. The
> + * 10 second value is a heuristic trading re-optimization latency against
> + * scanning too eagerly.
> + */

Simplify:

"Delay, in milliseconds, before the RMP re-optimization pass runs after an SNP
guest is torn down, passed as the delay to mod_delayed_work(). This coalesces
a burst of teardowns into a single scan and gives each guest's pages time to
be converted back to the shared, hypervisor-owned state. The 10 second value
is a heuristic trading re-optimization latency against scanning too eagerly."


> +#define RMPOPT_WORK_TIMEOUT (10 * MSEC_PER_SEC)

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette