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

From: David Matlack
Date: Thu Jan 26 2023 - 19:14:45 EST


On Thu, Jan 26, 2023 at 3:12 PM Ben Gardon <bgardon@xxxxxxxxxx> wrote:
>
> On Thu, Jan 26, 2023 at 3:04 PM Vipin Sharma <vipinsh@xxxxxxxxxx> wrote:
> >
> > On Thu, Jan 26, 2023 at 2:52 PM Ben Gardon <bgardon@xxxxxxxxxx> wrote:
> > >
> > > On Thu, Jan 26, 2023 at 12:06 PM Vipin Sharma <vipinsh@xxxxxxxxxx> wrote:
> > > >
> > > > On Wed, Jan 25, 2023 at 10:23 AM Ben Gardon <bgardon@xxxxxxxxxx> wrote:
> > > >
> > > > > +static void run_vcpus_get_page_stats(struct kvm_vm *vm, struct kvm_page_stats *stats, const char *stage)
> > > > > +{
> > > > > + int i;
> > > > > +
> > > > > + iteration++;
> > > > > + for (i = 0; i < VCPUS; i++) {
> > > > > + while (READ_ONCE(vcpu_last_completed_iteration[i]) !=
> > > > > + iteration)
> > > > > + ;
> > > > > + }
> > > > > +
> > > > > + get_page_stats(vm, stats, stage);
> > > >
> > > > get_page_stats() is already called in run_test() explicitly for other
> > > > stats. I think it's better to split this function and make the flow
> > > > like:
> > > >
> > > > run_vcpus_till_iteration(iteration++);
> > > > get_page_stats(vm, &stats_populated, "populating memory");
> > > >
> > > > This makes it easy to follow run_test_till_iteration() and easy to see
> > > > where stats are collected. run_test_till_iteration() can also be a
> > > > library function used by other tests like dirty_log_perf_test
> > >
> > > Yeah, either way works. We can do it all in the run_tests function as
> > > I originally had or we can have the run vcpus and get stats in a
> > > helper as David suggested or we can separate run_vcpus and get_stats
> > > helpers as you're suggesting. I don't think it makes much of a
> > > difference.
> > > If you feel strongly I can send out another iteration of this test.
> > >
> >
> > I should have read David's comment and responded in that version.
> > No strong feelings. It is up to you.
>
> No worries, it probably would have been easier to track down if I had
> links in the cover letter. :)

I mostly wanted the loop to go in a helper and threw in the stats
without really thinking about it. Now that I see it I like Vipin's
idea of having the stats call separate.