Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp2533440rwr; Fri, 21 Apr 2023 10:06:21 -0700 (PDT) X-Google-Smtp-Source: AKy350bAjl/yFU5VOhzozcDGqaddCcd2fSvJ3XzfbhUafJkPLtIl64DLpOrVUGsbJbimoN1C36ee X-Received: by 2002:a05:6a20:394c:b0:f0:69de:6165 with SMTP id r12-20020a056a20394c00b000f069de6165mr6272004pzg.4.1682096780540; Fri, 21 Apr 2023 10:06:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682096780; cv=none; d=google.com; s=arc-20160816; b=IlOClfSKAyOoDpf4h3rghlXrCvw4Tm2T4VWXrUsGnoT274v9/xNPoF71SdWjbyC3Si zN9ptfr1rbl6wXO53U2zIenvoHWELb9hUgfHF2P9lqVT8Cmh4AAW4QopK4GrDPOk8Lhd LRj67tqzVWz/7dFGkifbCalstTL6yEfFSwzqC8giYlJUgMgi086h83w3dVBI+zrCDxWI wMv08WV4EI1BV6S07ru1IX+vlA1/49yvazCXcRIqTBhMigBLGWz7jbVsqQFwCg+4qXvy 3ZeRBiQmU07B6lHG4oK41rW+Vo1uYnNy2RP1yzCwcrCVPm2v9AGPoQpdc9zL6Ufadwrl aqyw== 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=QAMadok09XxgFvaDO3J6Lgqv+ZDwnOLb2IYSq9G7u+A=; b=Zo5NPnHw3qZdIc0hYEUKTvlUSQ3FMtk/i31SKdUp7RKngKjgIZqOBeIjmN0Ttg0Otv GVbhjsP15qmrJ05sWGV0Mmt3JbrevDh+0mjS96gujffPntXRaIqNEmHLIcfecpilAiUI 57ScQxXZ2qYR750eCSYbqSGuCN5I4D4Utg474y+wlpSfQLVSuTu8Y2qQfDTyVcPuZtJN Wrk8YeTS3K80fH6K4U5W7MX5Ty4rzsaDpZKcp0M8FEoeLNejbcs+LAJZP3gN20j2dU9J UIqvuSHJETyDUWRJozhw5RXApMaIqwCnLyJDXW9klIM5k9xyepdpaLq1yu4B/mpMz08U FEjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=5l1CzLum; 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 x62-20020a638641000000b00520a879b9cesi4772526pgd.3.2023.04.21.10.06.06; Fri, 21 Apr 2023 10:06:20 -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=5l1CzLum; 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 S233332AbjDURA3 (ORCPT + 99 others); Fri, 21 Apr 2023 13:00:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233306AbjDURAW (ORCPT ); Fri, 21 Apr 2023 13:00:22 -0400 Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2DD8167C1 for ; Fri, 21 Apr 2023 09:59:55 -0700 (PDT) Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-52057b3d776so1488812a12.2 for ; Fri, 21 Apr 2023 09:59:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1682095996; x=1684687996; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=QAMadok09XxgFvaDO3J6Lgqv+ZDwnOLb2IYSq9G7u+A=; b=5l1CzLumfw4VvnGKs1LekidIOHm6RR2ZhVTA1I+whH2HeXgm2o8PhxoPUQLTHfydb9 MbBxamdeRZWqIzwIX6cPpq9NGQ3282H+LGUyBZpLlO6iAgfWncKkZnXQevgjEqCzsFvI /ie9WS7cdYCl1aCB7+4MGfZNo6IMNnRdfZplWSdxceYc0BIUM6d0gO/blOvoZokSUVGw Y1vWnwlcSKtpR4AbEKzTUp+leY3IooaW0MIg6qShyiSd1O990V5j6KZFgnSxmwclrSfF iRRS2VvoFH4pfGHIeK5C/wh3ElWiAy4UgpcFTrfc4JtiPWNVC38kZkoYq7eJ04Cn12As uI2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682095996; x=1684687996; 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=QAMadok09XxgFvaDO3J6Lgqv+ZDwnOLb2IYSq9G7u+A=; b=YFCdqUu1CYrz6tMJVGBIWiCTmQjD6goPc61bifbkDtQHBFcfBWnTp+D1nSynwAY0Lv DrXm63QAtHOGBBrHJhWvAEwheYOtWnUSwR34YQeWeBDuTqtKPyvr4r3Sv2/RH4ei09KF Mlj4D/bnHF016YnyyOZhVoeX+k9w7Oj6VI+VMqwNy6Nz9JBNmz5KgylBm0bnem7yjk79 SP42zs4hKrf5Q1S+VE6k56XN40YrJWzqq//6cBbmqDnbd+oFtuiAaCjVzV06DOzWyG21 6fYXaDFeU5qZC3cSYfVX/xlFCOkWe67+4MPv/V10uwAiKVgzPLpAyceeSkrhV/t2XP+J y3Mw== X-Gm-Message-State: AAQBX9dY75xpbjHv9iLdYL2ZBTQD9MlJ1Fjr8LS/jLD2utJnFydG6q6V DQT4LPGRRsLCXeN/VpWewI/Pbn6D6Xf4 X-Received: from vipin.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:479f]) (user=vipinsh job=sendgmr) by 2002:a63:105e:0:b0:520:53fa:9878 with SMTP id 30-20020a63105e000000b0052053fa9878mr1424111pgq.6.1682095996166; Fri, 21 Apr 2023 09:53:16 -0700 (PDT) Date: Fri, 21 Apr 2023 09:53:00 -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-5-vipinsh@google.com> Subject: [PATCH 4/9] KVM: selftests: Print read and write accesses of pages by vCPUs in dirty_log_perf_test 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, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=unavailable 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 Fetch read and write accesses of pages from guest code and print count across all vCPUs in dirty_log_perf_test. This data provides progress made by vCPUs during dirty logging operations. Since, vCPUs execute in lockstep with userspace dirty log iterations, this metric is not very interesting. However, in future commits when dirty_log_perf_test can execute vCPUs independently from dirty log iterations then this metric can give good measure of vCPUs performance during dirty logging. Signed-off-by: Vipin Sharma --- .../selftests/kvm/dirty_log_perf_test.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/kvm/dirty_log_perf_test.c b/tools/testing/selftests/kvm/dirty_log_perf_test.c index 338f03a4a550..0a08a3d21123 100644 --- a/tools/testing/selftests/kvm/dirty_log_perf_test.c +++ b/tools/testing/selftests/kvm/dirty_log_perf_test.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include "kvm_util.h" @@ -66,17 +67,22 @@ static u64 dirty_log_manual_caps; static bool host_quit; static int iteration; static int vcpu_last_completed_iteration[KVM_MAX_VCPUS]; +static atomic_ullong total_reads; +static atomic_ullong total_writes; static void vcpu_worker(struct memstress_vcpu_args *vcpu_args) { struct kvm_vcpu *vcpu = vcpu_args->vcpu; int vcpu_idx = vcpu_args->vcpu_idx; uint64_t pages_count = 0; + uint64_t reads = 0; + uint64_t writes = 0; struct kvm_run *run; struct timespec start; struct timespec ts_diff; struct timespec total = (struct timespec){0}; struct timespec avg; + struct ucall uc = {}; int ret; run = vcpu->run; @@ -89,7 +95,7 @@ static void vcpu_worker(struct memstress_vcpu_args *vcpu_args) ts_diff = timespec_elapsed(start); TEST_ASSERT(ret == 0, "vcpu_run failed: %d\n", ret); - TEST_ASSERT(get_ucall(vcpu, NULL) == UCALL_SYNC, + TEST_ASSERT(get_ucall(vcpu, &uc) == UCALL_SYNC, "Invalid guest sync status: exit_reason=%s\n", exit_reason_str(run->exit_reason)); @@ -101,6 +107,8 @@ static void vcpu_worker(struct memstress_vcpu_args *vcpu_args) if (current_iteration) { pages_count += vcpu_args->pages; total = timespec_add(total, ts_diff); + reads += uc.args[2]; + writes += uc.args[3]; pr_debug("vCPU %d iteration %d dirty memory time: %ld.%.9lds\n", vcpu_idx, current_iteration, ts_diff.tv_sec, ts_diff.tv_nsec); @@ -123,6 +131,8 @@ static void vcpu_worker(struct memstress_vcpu_args *vcpu_args) pr_debug("\nvCPU %d dirtied 0x%lx pages over %d iterations in %ld.%.9lds. (Avg %ld.%.9lds/iteration)\n", vcpu_idx, pages_count, vcpu_last_completed_iteration[vcpu_idx], total.tv_sec, total.tv_nsec, avg.tv_sec, avg.tv_nsec); + atomic_fetch_add(&total_reads, reads); + atomic_fetch_add(&total_writes, writes); } struct test_params { @@ -176,6 +186,8 @@ static void run_test(enum vm_guest_mode mode, void *arg) dirty_log_manual_caps); arch_setup_vm(vm, nr_vcpus); + atomic_store(&total_reads, 0); + atomic_store(&total_writes, 0); /* Start the iterations */ iteration = 0; @@ -295,6 +307,10 @@ static void run_test(enum vm_guest_mode mode, void *arg) clear_dirty_log_total.tv_nsec, avg.tv_sec, avg.tv_nsec); } + pr_info("Total pages touched: %llu (Reads: %llu, Writes: %llu)\n", + atomic_load(&total_reads) + atomic_load(&total_writes), + atomic_load(&total_reads), atomic_load(&total_writes)); + memstress_free_bitmaps(bitmaps, p->slots); arch_cleanup_vm(vm); memstress_destroy_vm(vm); -- 2.40.0.634.g4ca3ef3211-goog