Re: [PATCH v11 4/6] x86/sev: Add support to perform RMP optimizations asynchronously

Borislav Petkov <[email protected]> Wed, 5 Aug 2026 12:28:37 -0700
Newsgroups org.kernel.vger.linux-crypto,dev.linux.lists.linux-coco,org.kernel.vger.kvm,org.kernel.vger.linux-kernel
Message-ID <20260805192837.GAanOO5SU78CzNgblB@fat_crate.local>
On Tue, Aug 04, 2026 at 09:38:05PM -0500, Kalra, Ashish wrote:
> - Under churn (many SNP guests terminating and respawning), an hourly s=
can
> is too coarse =E2=80=94 freed regions would sit un-optimized for up to =
an hour. The
> teardown trigger re-optimizes right after each burst of terminations
> (batched by the timeout), so it's more responsive than a periodic scan
> exactly when there's the most optimization work to do.

Yes.

> - When no SNP guests run, a periodic scan achieves nothing: the initial=
 pass
> already optimized all of memory and nothing has changed, so it just re-=
scans
> physmem for zero benefit.

Well, no. You won't even run that when there are no SNP guests present.

> So the event-driven approach self-scales with real work =E2=80=94 it ru=
ns as often
> as memory is actually freed and not at all when the system is idle =E2=80=
=94 whereas
> a fixed timer is both too slow under load and pure overhead when idle. =
The
> mid-life contiguous-1 GB case is then caught precisely by the 1 GB-huge=
tlb
> page-cleanup hook when that lands, rather than by a coarse sweep.

I wanted to have this in case pages do get freed up from time to time and=
 you
get some sort of a fragmentation. But I'm being told that we don't suppor=
t
balooning yet, neither memory hotplug and when the pages get freed, they
remain guest-owned. So yes, the points in time where those page become
HV-owned and potentially freed, then we should optimize.

Please hold down that in the commit message so that it is clear for futur=
e
readers why we did it this way.

Thx.

--=20
Regards/Gruss,
    Boris.

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