linux-riscv.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Vipin Sharma <vipinsh@google.com>
To: maz@kernel.org, oliver.upton@linux.dev, james.morse@arm.com,
	 suzuki.poulose@arm.com, yuzenghui@huawei.com,
	catalin.marinas@arm.com,  will@kernel.org, chenhuacai@kernel.org,
	aleksandar.qemu.devel@gmail.com,  tsbogend@alpha.franken.de,
	anup@brainfault.org, atishp@atishpatra.org,
	 paul.walmsley@sifive.com, palmer@dabbelt.com,
	aou@eecs.berkeley.edu,  seanjc@google.com, pbonzini@redhat.com,
	dmatlack@google.com,  ricarkol@google.com
Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
	 linux-mips@vger.kernel.org, kvm-riscv@lists.infradead.org,
	 linux-riscv@lists.infradead.org,
	linux-kselftest@vger.kernel.org,  kvm@vger.kernel.org,
	linux-kernel@vger.kernel.org,  Vipin Sharma <vipinsh@google.com>
Subject: [PATCH v2 03/16] KVM: selftests: Pass the count of read and write accesses from guest to host
Date: Fri,  2 Jun 2023 09:09:01 -0700	[thread overview]
Message-ID: <20230602160914.4011728-4-vipinsh@google.com> (raw)
In-Reply-To: <20230602160914.4011728-1-vipinsh@google.com>

Pass the number of read and write accesses done in the memstress guest
code to userspace.

These counts will provide a  way to measure vCPUs performance during
memstress and dirty logging related tests. For example, in
dirty_log_perf_test this can be used to measure how much progress vCPUs
are able to do while VMM is getting and clearing dirty logs.

In dirty_log_perf_test, each vCPU runs once and then waits until
iteration value is incremented by main thread, therefore, these access
counts will not provide much useful information except for observing
read vs write counts.

However, in future commits, dirty_log_perf_test behavior will be changed
to allow vCPUs to execute independent of userspace iterations. This will
mimic real world workload where guest keeps on executing while VMM is
collecting and clearing dirty logs separately. With read and write
accesses known for each vCPU, impact of get and clear dirty log APIs can
be quantified.

Note that access counts will not be 100% reliable in knowing vCPUs
performances. Few things which can affect vCPU progress:
1. vCPUs are scheduled less by host
2. Userspace operations run for longer time which end up giving vCPUs
   more time to execute.

Signed-off-by: Vipin Sharma <vipinsh@google.com>
---
 tools/testing/selftests/kvm/lib/memstress.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/kvm/lib/memstress.c b/tools/testing/selftests/kvm/lib/memstress.c
index 5f1d3173c238..ac53cc6e36d7 100644
--- a/tools/testing/selftests/kvm/lib/memstress.c
+++ b/tools/testing/selftests/kvm/lib/memstress.c
@@ -49,6 +49,8 @@ void memstress_guest_code(uint32_t vcpu_idx)
 	struct memstress_args *args = &memstress_args;
 	struct memstress_vcpu_args *vcpu_args = &args->vcpu_args[vcpu_idx];
 	struct guest_random_state rand_state;
+	uint64_t write_access;
+	uint64_t read_access;
 	uint64_t gva;
 	uint64_t pages;
 	uint64_t addr;
@@ -64,6 +66,8 @@ void memstress_guest_code(uint32_t vcpu_idx)
 	GUEST_ASSERT(vcpu_args->vcpu_idx == vcpu_idx);
 
 	while (true) {
+		write_access = 0;
+		read_access = 0;
 		for (i = 0; i < pages; i++) {
 			if (args->random_access)
 				page = guest_random_u32(&rand_state) % pages;
@@ -72,13 +76,16 @@ void memstress_guest_code(uint32_t vcpu_idx)
 
 			addr = gva + (page * args->guest_page_size);
 
-			if (guest_random_u32(&rand_state) % 100 < args->write_percent)
+			if (guest_random_u32(&rand_state) % 100 < args->write_percent) {
 				*(uint64_t *)addr = 0x0123456789ABCDEF;
-			else
+				write_access++;
+			} else {
 				READ_ONCE(*(uint64_t *)addr);
+				read_access++;
+			}
 		}
 
-		GUEST_SYNC(1);
+		GUEST_SYNC_ARGS(1, read_access, write_access, 0, 0);
 	}
 }
 
-- 
2.41.0.rc0.172.g3f132b7071-goog


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

  parent reply	other threads:[~2023-06-02 16:09 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-02 16:08 [PATCH v2 00/16] Use MMU read lock for clear-dirty-log Vipin Sharma
2023-06-02 16:08 ` [PATCH v2 01/16] KVM: selftests: Clear dirty logs in user defined chunks sizes in dirty_log_perf_test Vipin Sharma
2023-06-02 16:09 ` [PATCH v2 02/16] KVM: selftests: Add optional delay between consecutive clear-dirty-log calls Vipin Sharma
2023-06-02 16:09 ` Vipin Sharma [this message]
2023-06-02 16:09 ` [PATCH v2 04/16] KVM: selftests: Print read-write progress by vCPUs in dirty_log_perf_test Vipin Sharma
2023-06-02 16:09 ` [PATCH v2 05/16] KVM: selftests: Allow independent execution of " Vipin Sharma
2023-06-02 16:09 ` [PATCH v2 06/16] KVM: arm64: Correct the kvm_pgtable_stage2_flush() documentation Vipin Sharma
2023-06-02 16:09 ` [PATCH v2 07/16] KVM: mmu: Move mmu lock/unlock to arch code for clear dirty log Vipin Sharma
2023-06-02 16:09 ` [PATCH v2 08/16] KMV: arm64: Pass page table walker flags to stage2_apply_range_*() Vipin Sharma
2023-06-02 16:09 ` [PATCH v2 09/16] KVM: arm64: Document the page table walker actions based on the callback's return value Vipin Sharma
2023-06-05 14:35   ` Zhi Wang
2023-06-06 17:30     ` Vipin Sharma
2023-06-07 12:37       ` Zhi Wang
2023-06-08 20:17         ` Vipin Sharma
2023-06-02 16:09 ` [PATCH v2 10/16] KVM: arm64: Return -ENOENT if PTE is not valid in stage2_attr_walker Vipin Sharma
2023-06-02 16:09 ` [PATCH v2 11/16] KVM: arm64: Use KVM_PGTABLE_WALK_SHARED flag instead of KVM_PGTABLE_WALK_HANDLE_FAULT Vipin Sharma
2023-06-02 16:09 ` [PATCH v2 12/16] KVM: arm64: Retry shared page table walks outside of fault handler Vipin Sharma
2023-06-02 16:09 ` [PATCH v2 13/16] KVM: arm64: Run clear-dirty-log under MMU read lock Vipin Sharma
2023-06-02 16:09 ` [PATCH v2 14/16] KVM: arm64: Pass page walker flags from callers of stage 2 split walker Vipin Sharma
2023-06-02 16:09 ` [PATCH v2 15/16] KVM: arm64: Provide option to pass page walker flag for huge page splits Vipin Sharma
2023-06-02 16:09 ` [PATCH v2 16/16] KVM: arm64: Split huge pages during clear-dirty-log under MMU read lock Vipin Sharma

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=20230602160914.4011728-4-vipinsh@google.com \
    --to=vipinsh@google.com \
    --cc=aleksandar.qemu.devel@gmail.com \
    --cc=anup@brainfault.org \
    --cc=aou@eecs.berkeley.edu \
    --cc=atishp@atishpatra.org \
    --cc=catalin.marinas@arm.com \
    --cc=chenhuacai@kernel.org \
    --cc=dmatlack@google.com \
    --cc=james.morse@arm.com \
    --cc=kvm-riscv@lists.infradead.org \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=maz@kernel.org \
    --cc=oliver.upton@linux.dev \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=pbonzini@redhat.com \
    --cc=ricarkol@google.com \
    --cc=seanjc@google.com \
    --cc=suzuki.poulose@arm.com \
    --cc=tsbogend@alpha.franken.de \
    --cc=will@kernel.org \
    --cc=yuzenghui@huawei.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).