Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp2517528rwr; Fri, 21 Apr 2023 09:55:12 -0700 (PDT) X-Google-Smtp-Source: AKy350ZS13DuXFyKHP/p4VjALZaJeWu5HcXrKwy+Iy7pbrLVkY+D6dqR03lc+dYOhYGSdcCbrn4M X-Received: by 2002:a05:6a20:a10d:b0:eb:7d41:a6e6 with SMTP id q13-20020a056a20a10d00b000eb7d41a6e6mr7985981pzk.0.1682096112140; Fri, 21 Apr 2023 09:55:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682096112; cv=none; d=google.com; s=arc-20160816; b=Hde4aDfzhBS+mVpEvWqIJX5jqH4y6KB1x0M5ugVC70mBfEnWxC0iE54vUPAqMUThgy Y213mdGEaGncZow56HVLvqWf/sUq4JgRuiD+Ns9yWPV/jGn3eRA7SsPjA0T/JV+kmJNL yMAdKxLegXFP4rs+MOe+w+6DsnoR+UWYNJZrS/2RtIPtQhmvOPbcuEZn2Sxi5A1nswCs 1i63IDdfqoIG8d251w1Y+BC1BRlHHcz8OuIw9lOobQ5lqJYee9bzP5ZP+YhtVL+gcjbM 9FxEX/sYwdLHl5dR1QI21dLrWqm2OsSwyEMLoXus0LJ4b5i0x9v1RsHLXa2cVv5m1KBE sslw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=dM0sknYnz5Tr9YshwaHjySCVB3V9EWCXlRX5uFgEya8=; b=Y5Hty+g+ET0m8ebGeTBs7zEx2OFbdHkeU1awSokNF2s2DAgFa0OYxaBW7QALChzqck JZhUu6U6YZrBkRVSP5MmQkcgwHMiH2zTMtM2L/Odz02xKoaXB9qqizkkPpTYCAqcib2U prKhM5dPOd9ZekWBEvsLGEwU8PvovmC6PhXWBYWEOOvmLIsL84IbMued2dIfmCW8QTxS aeSQR6NsRXu1l7v29UWgf+KApeOUcblnXPOHG5ATWQMGkR0QxJ6hVFeOKhMtplP3m9i6 z2fRbFSe61QXN0nKaSY6mV3GXVVmOY6F4xDAfd3ROLuZl+gDknT3qbIln8AHbzHCBxMt 683w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=cKoOxJh4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h190-20020a6253c7000000b0063b5e220edasi4526334pfb.400.2023.04.21.09.54.58; Fri, 21 Apr 2023 09:55:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=cKoOxJh4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233518AbjDUQyu (ORCPT + 99 others); Fri, 21 Apr 2023 12:54:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232875AbjDUQyb (ORCPT ); Fri, 21 Apr 2023 12:54:31 -0400 Received: from mail-pj1-x1049.google.com (mail-pj1-x1049.google.com [IPv6:2607:f8b0:4864:20::1049]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C68C315A3D for ; Fri, 21 Apr 2023 09:54:15 -0700 (PDT) Received: by mail-pj1-x1049.google.com with SMTP id 98e67ed59e1d1-2472a2e72d1so2199554a91.3 for ; Fri, 21 Apr 2023 09:54:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1682095992; x=1684687992; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=dM0sknYnz5Tr9YshwaHjySCVB3V9EWCXlRX5uFgEya8=; b=cKoOxJh4k5Df809KvDrC16SHpyyANbnD88ODpXNOuka0EEfmMXb9/GGZHQjZmiaSGC PHXwzp6oJJCuBjtwH55J3xqdIM10HnXCfOmj/GRFwtdNPqo3g+mBSidFvw86YFvbU0sY QFH5aE4DJ8NgYwN0BX1m2H/84CVYfPBQlivAZjfI0w0gbJssCQFPLo6dhrf9i30gQDYK RVT9NmA3RwkhJ9wGFaj9EOO7LpEIdOpFNM2q37g3x6fVQdiBTnwi7UMa2h5IS92inTkJ 5XzKSeq94NI91RbwFfXmAf2d+oezqCbzgzE8MFn7zbTcJm/Y08tOtjCRc2EpRU8GmuIw Joug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682095992; x=1684687992; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=dM0sknYnz5Tr9YshwaHjySCVB3V9EWCXlRX5uFgEya8=; b=HZgNh/Ii5oBhelek4NE+W4/6x+byRvRpyRy8w894ZALvckvxe5b+rEoiAJKXZ/IzmT uPH0kU2sg8Ptq1SXqHvz4vCHL5k3nlxW6MuINOVXbsU9iWMaZdp7fqf6Ez0ephffRrWF Tt3hWi+OdFNhOXMxoQ91At+rXmeXYMcqpBYKOfUj8VDSsvoApPVaMFxrIQUyss1T0E2m poR3mob/AQVvAIuTaXuuX2weuBeA1e1yR2HqDQRbnyXSq26u0ch8fSbgtCmg7uDS9Lad FonBcqJF4nATyxGiMCBTNRRjcRIaNixK8jXQCMaI0CAcBUZ+/PSsLWnnzXuMPeq52TNN tMUQ== X-Gm-Message-State: AAQBX9fIq+s3SH/DFARSwOix6FHgtkz/jwIyk2PAcUXQNX3HKSfRYxyK Plu9ZKFeAs2fx3op2ir8QCZgcVsxmVbT X-Received: from vipin.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:479f]) (user=vipinsh job=sendgmr) by 2002:a17:90a:740d:b0:244:8f24:783d with SMTP id a13-20020a17090a740d00b002448f24783dmr1553862pjg.4.1682095992639; Fri, 21 Apr 2023 09:53:12 -0700 (PDT) Date: Fri, 21 Apr 2023 09:52:58 -0700 In-Reply-To: <20230421165305.804301-1-vipinsh@google.com> Mime-Version: 1.0 References: <20230421165305.804301-1-vipinsh@google.com> X-Mailer: git-send-email 2.40.0.634.g4ca3ef3211-goog Message-ID: <20230421165305.804301-3-vipinsh@google.com> Subject: [PATCH 2/9] KVM: selftests: Add optional delay between consecutive Clear-Dirty-Log calls From: Vipin Sharma 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In dirty_log_perf_test, add option "-l" to wait between consecutive Clear-Dirty-Log calls. Accept delay in milliseconds. 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 --- .../testing/selftests/kvm/dirty_log_perf_test.c | 17 +++++++++++++++-- tools/testing/selftests/kvm/include/memstress.h | 5 +++-- tools/testing/selftests/kvm/lib/memstress.c | 10 +++++++++- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/kvm/dirty_log_perf_test.c b/tools/testing/selftests/kvm/dirty_log_perf_test.c index 0852a7ba42e1..338f03a4a550 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 run_test(enum vm_guest_mode mode, void *arg) @@ -249,7 +250,8 @@ static void run_test(enum vm_guest_mode mode, void *arg) clock_gettime(CLOCK_MONOTONIC, &start); memstress_clear_dirty_log_in_chunks(vm, bitmaps, p->slots, pages_per_slot, - pages_per_clear); + pages_per_clear, + p->clear_chunk_wait_time_ms); ts_diff = timespec_elapsed(start); clear_dirty_log_total = timespec_add(clear_dirty_log_total, ts_diff); @@ -352,6 +354,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); } @@ -368,6 +375,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; @@ -378,7 +386,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; @@ -405,6 +413,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; diff --git a/tools/testing/selftests/kvm/include/memstress.h b/tools/testing/selftests/kvm/include/memstress.h index 2acc93f76fc3..01fdcea80360 100644 --- a/tools/testing/selftests/kvm/include/memstress.h +++ b/tools/testing/selftests/kvm/include/memstress.h @@ -78,12 +78,13 @@ void memstress_get_dirty_log(struct kvm_vm *vm, unsigned long *bitmaps[], int sl void memstress_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); static inline void memstress_clear_dirty_log(struct kvm_vm *vm, unsigned long *bitmaps[], int slots, uint64_t pages_per_slot) { memstress_clear_dirty_log_in_chunks(vm, bitmaps, slots, pages_per_slot, - pages_per_slot); + pages_per_slot, 0); } unsigned long **memstress_alloc_bitmaps(int slots, uint64_t pages_per_slot); void memstress_free_bitmaps(unsigned long *bitmaps[], int slots); diff --git a/tools/testing/selftests/kvm/lib/memstress.c b/tools/testing/selftests/kvm/lib/memstress.c index e0c701ab4e9a..483ecbc53a5b 100644 --- a/tools/testing/selftests/kvm/lib/memstress.c +++ b/tools/testing/selftests/kvm/lib/memstress.c @@ -358,10 +358,15 @@ void memstress_get_dirty_log(struct kvm_vm *vm, unsigned long *bitmaps[], int sl void memstress_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) { int i, slot; uint64_t from, clear_pages_count; + struct timespec wait = { + .tv_sec = wait_ms / 1000, + .tv_nsec = (wait_ms % 1000) * 1000000ull, + }; for (i = 0; i < slots; i++) { slot = MEMSTRESS_MEM_SLOT_INDEX + i; @@ -374,6 +379,9 @@ void memstress_clear_dirty_log_in_chunks(struct kvm_vm *vm, kvm_vm_clear_dirty_log(vm, slot, bitmaps[i], from, clear_pages_count); from += clear_pages_count; + if (wait_ms) + nanosleep(&wait, NULL); + } } -- 2.40.0.634.g4ca3ef3211-goog