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 02/16] KVM: selftests: Add optional delay between consecutive clear-dirty-log calls
Date: Fri, 2 Jun 2023 09:09:00 -0700 [thread overview]
Message-ID: <20230602160914.4011728-3-vipinsh@google.com> (raw)
In-Reply-To: <20230602160914.4011728-1-vipinsh@google.com>
In dirty_log_perf_test, add option "-l" to wait between consecutive
clear-dirty-log calls. Accept delay from user in milliseconds. If option
is not provided then fallback to no wait between clear calls.
This allows dirty_log_perf_test to mimic real world use where after
clearing dirty memory, some time is spent in transferring memory before
making a subsequeunt clear-dirty-log call.
Signed-off-by: Vipin Sharma <vipinsh@google.com>
---
.../selftests/kvm/dirty_log_perf_test.c | 35 +++++++++++++++----
1 file changed, 29 insertions(+), 6 deletions(-)
diff --git a/tools/testing/selftests/kvm/dirty_log_perf_test.c b/tools/testing/selftests/kvm/dirty_log_perf_test.c
index 119ddfc7306e..2e31f13aaba6 100644
--- a/tools/testing/selftests/kvm/dirty_log_perf_test.c
+++ b/tools/testing/selftests/kvm/dirty_log_perf_test.c
@@ -135,6 +135,7 @@ struct test_params {
uint32_t random_seed;
bool random_access;
uint64_t clear_chunk_size;
+ int clear_chunk_wait_time_ms;
};
static void toggle_dirty_logging(struct kvm_vm *vm, int slots, bool enable)
@@ -173,8 +174,14 @@ static void get_dirty_log(struct kvm_vm *vm, unsigned long *bitmaps[], int slots
static void clear_dirty_log_in_chunks(struct kvm_vm *vm,
unsigned long *bitmaps[], int slots,
uint64_t pages_per_slot,
- uint64_t pages_per_clear)
+ uint64_t pages_per_clear, int wait_ms,
+ struct timespec *time_taken)
{
+ struct timespec wait = {
+ .tv_sec = wait_ms / 1000,
+ .tv_nsec = (wait_ms % 1000) * 1000000ull,
+ };
+ struct timespec start, end;
uint64_t from, clear_pages_count;
int i, slot;
@@ -186,12 +193,17 @@ static void clear_dirty_log_in_chunks(struct kvm_vm *vm,
while (from < pages_per_slot) {
if (from + clear_pages_count > pages_per_slot)
clear_pages_count = pages_per_slot - from;
+ clock_gettime(CLOCK_MONOTONIC, &start);
kvm_vm_clear_dirty_log(vm, slot, bitmaps[i], from,
clear_pages_count);
+ end = timespec_elapsed(start);
+ *time_taken = timespec_add(*time_taken, end);
from += clear_pages_count;
+ if (wait_ms)
+ nanosleep(&wait, NULL);
+
}
}
-
}
static unsigned long **alloc_bitmaps(int slots, uint64_t pages_per_slot)
@@ -329,11 +341,11 @@ static void run_test(enum vm_guest_mode mode, void *arg)
iteration, ts_diff.tv_sec, ts_diff.tv_nsec);
if (dirty_log_manual_caps) {
- clock_gettime(CLOCK_MONOTONIC, &start);
clear_dirty_log_in_chunks(vm, bitmaps, p->slots,
pages_per_slot,
- pages_per_clear);
- ts_diff = timespec_elapsed(start);
+ pages_per_clear,
+ p->clear_chunk_wait_time_ms,
+ &ts_diff);
clear_dirty_log_total = timespec_add(clear_dirty_log_total,
ts_diff);
pr_info("Iteration %d clear dirty log time: %ld.%.9lds\n",
@@ -435,6 +447,11 @@ static void help(char *name)
" the memslot size then whole memslot is cleared in one call.\n"
" Size must be aligned to the host page size. e.g. 10M or 3G\n"
" (default: UINT64_MAX, clears whole memslot in one call)\n");
+ printf(" -l: Specify time in milliseconds to wait after Clear-Dirty-Log\n"
+ " call. This allows to mimic use cases where flow is to get\n"
+ " dirty log followed by multiple clear dirty log calls and\n"
+ " sending corresponding memory to destination (in this test\n"
+ " sending will be just idle waiting)\n");
puts("");
exit(0);
}
@@ -451,6 +468,7 @@ int main(int argc, char *argv[])
.random_seed = 1,
.write_percent = 100,
.clear_chunk_size = UINT64_MAX,
+ .clear_chunk_wait_time_ms = 0,
};
int opt;
@@ -461,7 +479,7 @@ int main(int argc, char *argv[])
guest_modes_append_default();
- while ((opt = getopt(argc, argv, "ab:c:eghi:k:m:nop:r:s:v:x:w:")) != -1) {
+ while ((opt = getopt(argc, argv, "ab:c:eghi:k:l:m:nop:r:s:v:x:w:")) != -1) {
switch (opt) {
case 'a':
p.random_access = true;
@@ -488,6 +506,11 @@ int main(int argc, char *argv[])
case 'k':
p.clear_chunk_size = parse_size(optarg);
break;
+ case 'l':
+ p.clear_chunk_wait_time_ms =
+ atoi_non_negative("Clear dirty log chunks wait time",
+ optarg);
+ break;
case 'm':
guest_modes_cmdline(optarg);
break;
--
2.41.0.rc0.172.g3f132b7071-goog
next prev 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 ` Vipin Sharma [this message]
2023-06-02 16:09 ` [PATCH v2 03/16] KVM: selftests: Pass the count of read and write accesses from guest to host Vipin Sharma
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-3-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).