kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ricardo Koller <ricarkol@google.com>
To: Colton Lewis <coltonlewis@google.com>
Cc: kvm@vger.kernel.org, pbonzini@redhat.com, maz@kernel.org,
	dmatlack@google.com, seanjc@google.com, bgardon@google.com,
	oupton@google.com
Subject: Re: [PATCH 1/3] KVM: selftests: Allocate additional space for latency samples
Date: Tue, 17 Jan 2023 12:32:43 -0800	[thread overview]
Message-ID: <Y8cF65zpxOlYkAUl@google.com> (raw)
In-Reply-To: <20221115173258.2530923-2-coltonlewis@google.com>

Hi Colton,

On Tue, Nov 15, 2022 at 05:32:56PM +0000, Colton Lewis wrote:
> Allocate additional space for latency samples. This has been separated
> out to call attention to the additional VM memory allocation. The test
> runs out of physical pages without the additional allocation. The 100
> multiple for pages was determined by trial and error. A more
> well-reasoned calculation would be preferable.
> 
> Signed-off-by: Colton Lewis <coltonlewis@google.com>
> ---
>  tools/testing/selftests/kvm/lib/perf_test_util.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/testing/selftests/kvm/lib/perf_test_util.c b/tools/testing/selftests/kvm/lib/perf_test_util.c
> index 137be359b09e..a48904b64e19 100644
> --- a/tools/testing/selftests/kvm/lib/perf_test_util.c
> +++ b/tools/testing/selftests/kvm/lib/perf_test_util.c
> @@ -38,6 +38,12 @@ static bool all_vcpu_threads_running;
>  
>  static struct kvm_vcpu *vcpus[KVM_MAX_VCPUS];
>  
> +#define SAMPLES_PER_VCPU 1000
> +#define SAMPLE_CAPACITY (SAMPLES_PER_VCPU * KVM_MAX_VCPUS)
> +
> +/* Store all samples in a flat array so they can be easily sorted later. */
> +uint64_t latency_samples[SAMPLE_CAPACITY];
> +
>  /*
>   * Continuously write to the first 8 bytes of each page in the
>   * specified region.
> @@ -122,7 +128,7 @@ struct kvm_vm *perf_test_create_vm(enum vm_guest_mode mode, int nr_vcpus,
>  {
>  	struct perf_test_args *pta = &perf_test_args;
>  	struct kvm_vm *vm;
> -	uint64_t guest_num_pages, slot0_pages = 0;
> +	uint64_t guest_num_pages, sample_pages, slot0_pages = 0;
>  	uint64_t backing_src_pagesz = get_backing_src_pagesz(backing_src);
>  	uint64_t region_end_gfn;
>  	int i;
> @@ -161,7 +167,9 @@ struct kvm_vm *perf_test_create_vm(enum vm_guest_mode mode, int nr_vcpus,
>  	 * The memory is also added to memslot 0, but that's a benign side
>  	 * effect as KVM allows aliasing HVAs in meslots.
>  	 */
> -	vm = __vm_create_with_vcpus(mode, nr_vcpus, slot0_pages + guest_num_pages,
> +	sample_pages = 100 * sizeof(latency_samples) / pta->guest_page_size;

I don't think there's any need to guess. The number of accesses is
vcpu_args->pages (one access per guest page). So all memory could be
allocated dynamically to hold "vcpu_args->pages * sample_sz".

> +	vm = __vm_create_with_vcpus(mode, nr_vcpus,
> +				    slot0_pages + guest_num_pages + sample_pages,
>  				    perf_test_guest_code, vcpus);
>  
>  	pta->vm = vm;
> -- 
> 2.38.1.431.g37b22c650d-goog
> 

Thanks,
Ricardo

  reply	other threads:[~2023-01-17 22:11 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-15 17:32 [PATCH 0/3] Calculate memory access latency stats Colton Lewis
2022-11-15 17:32 ` [PATCH 1/3] KVM: selftests: Allocate additional space for latency samples Colton Lewis
2023-01-17 20:32   ` Ricardo Koller [this message]
2023-01-18 16:49   ` Sean Christopherson
2023-01-26 18:00     ` Colton Lewis
2022-11-15 17:32 ` [PATCH 2/3] KVM: selftests: Collect memory access " Colton Lewis
2023-01-17 20:43   ` Ricardo Koller
2023-01-18 16:32     ` Sean Christopherson
2023-01-26 18:00       ` Colton Lewis
2023-01-26 19:07         ` Sean Christopherson
2023-01-26 17:58     ` Colton Lewis
2023-01-26 18:30       ` Ricardo Koller
2023-01-17 20:48   ` Ricardo Koller
2023-01-26 17:59     ` Colton Lewis
2022-11-15 17:32 ` [PATCH 3/3] KVM: selftests: Print summary stats of memory latency distribution Colton Lewis
2023-01-17 20:45   ` Ricardo Koller
2023-01-26 17:58     ` Colton Lewis
2023-01-18 16:43   ` Sean Christopherson
2023-01-26 17:59     ` Colton Lewis

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=Y8cF65zpxOlYkAUl@google.com \
    --to=ricarkol@google.com \
    --cc=bgardon@google.com \
    --cc=coltonlewis@google.com \
    --cc=dmatlack@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=oupton@google.com \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).