Re: [PATCH 2/2] selftests: KVM: Add page splitting test

From: Ricardo Koller
Date: Tue Jan 24 2023 - 10:54:57 EST


On Mon, Jan 23, 2023 at 10:41:18AM -0800, David Matlack wrote:
> On Fri, Jan 20, 2023 at 12:04:04PM -0800, Ben Gardon wrote:
> > On Fri, Jan 20, 2023 at 6:34 AM Ricardo Koller <ricarkol@xxxxxxxxxx> wrote:
> > >
> > ...
> > > > > > > +
> > > > > > > + run_test(&p);
> > > > > >
> > > > > > Use for_each_guest_mode() to run against all supported guest modes.
> > > > >
> > > > > I'm not sure that would actually improve coverage. None of the page
> > > > > splitting behavior depends on the mode AFAICT.
> > > >
> > > > You need to use for_each_guest_mode() for the ARM case. The issue is
> > > > that whatever mode (guest page size and VA size) you pick might not be
> > > > supported by the host. So, you first to explore what's available (via
> > > > for_each_guest_mode()).
> > >
> > > Actually, that's fixed by using the default mode, which picks the
> > > first available
> > > mode. I would prefer to use for_each_guest_mode() though, who knows and
> > > something fails with some specific guest page size for some reason.
> >
> > Okay, will do. I wasn't sure if we did eager page splitting on ARM, so
>
> Ricardo is in the process of upstreaming eager page splitting for ARM:
>
> https://lore.kernel.org/kvm/20230113035000.480021-1-ricarkol@xxxxxxxxxx/
>
> > I was only planning on making this test for x86_64 initially, hence it
> > being in that directory. If ARM rolls with the same behavior, then
> > I'll add the for_each_mode bit and move the test up a directory.
>
> In addition to for_each_guest_mode(), KVM/ARM will need to expose page
> size stats so the test can verify the splitting (yet another reason to
> have a common MMU).
>
> Ricardo, if you're interested in adding page size stats to KVM/ARM ahead
> of the Common MMU, e.g. to test eager page splitting, let me know.

Sure, I can do that. Sounds pretty useful too.

> I
> want to make sure we align on the userspace-visible stat names to avoid
> churn down the road. Specifically, do we want to expose neutral names
> like pages_{pte,pmd,pud} or expand the KVM/x86 list to include all of
> ARM's possible pages sizes like pages_{4k,16k,64k,...} (or both)?

I would prefer the latter, mainly to match the x86 names:

+ stats->pages_4k = vm_get_stat(vm, "pages_4k");
+ stats->pages_2m = vm_get_stat(vm, "pages_2m");
+ stats->pages_1g = vm_get_stat(vm, "pages_1g");
(from this patch)

but pages_{pte,pmd,pud} would certainly make this test simpler
as it would handle all guest page sizes:

+ stats->pages_pte = vm_get_stat(vm, "pages_pte");