From patchwork Thu Nov 11 00:02:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Matlack X-Patchwork-Id: 12613633 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73C25C433F5 for ; Thu, 11 Nov 2021 00:03:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4BFF061105 for ; Thu, 11 Nov 2021 00:03:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234278AbhKKAGH (ORCPT ); Wed, 10 Nov 2021 19:06:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234143AbhKKAGG (ORCPT ); Wed, 10 Nov 2021 19:06:06 -0500 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 923BCC061766 for ; Wed, 10 Nov 2021 16:03:18 -0800 (PST) Received: by mail-pj1-x104a.google.com with SMTP id jx2-20020a17090b46c200b001a62e9db321so1909455pjb.7 for ; Wed, 10 Nov 2021 16:03:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=UZSxYvi0qVP1F++cVUOnkEBRLDYe6xqDOy+3nDoOuSU=; b=Nu4Xe1RNrAHjwd8Y9T19r7uxMhVbmeFSDxMLfs+feMXLVSp991YAqWJrGC2Osm4M4q ANRopmYWxfUAR6GPOELfEQCgaTy1pZjGTQtfO3OaH1DoOxjxiJZ6elEaediRI3/r70R8 gIBBhnd+h8uUjkTNVJNdLlisXByH5CNDp7xtOETQrFKtYjImReiNMIJHGYAcfof6UA1G Z0QAmF1j0LXrbC6zTd9wmD6HLeGp+8Vrp1HV1nWt+xMjBvJJHMjDU29ErmLnBJd58xZb g15/gpSSOnsXrTlj01Mqi12DhCIhtlDCygRHtSZMkh2GETe7q+9WeKE8NaELFK1ymuIu NfUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=UZSxYvi0qVP1F++cVUOnkEBRLDYe6xqDOy+3nDoOuSU=; b=Q/sdKNf9yH82CIeUYRwVJCGSU7YMRibCO6EMXbc5ai6w3rENU6+6i+BxUZrH+pX+b5 8fDT4JjptwCBBKmOAhCNwxEVXoIy1LF+IhcuYBBRYgJbQQABN5DEy1S3lhBlK2mXKdpX ScsaqeC2LZelWTcqHeIsqnSdy1kK3a3/SL+IxkzUe0/ukEH/sTIlfyDTb6x6d1FIOboK ulGGbigif8+LGb8PUdcVpwfKhBBWezF8LwP3BT/Y0vxKSEwPS5cvBCbbLI5EGnV8C1Yf lx0CeENm5pW0WbLXtsFWRFN4mdsONZwPPi0UP/TdxiTUa4Z6CQfoQ1QIj/e/iCtfF/0n j7Iw== X-Gm-Message-State: AOAM532hWbPgbLlyXe6I4LvqavXiCi0K5UoKbcXEk3RzHL/T+eZBYFmq k+bmgEC4jMi/ylKzFqY6aHJt1z5gnx8Iuw== X-Google-Smtp-Source: ABdhPJyzQxB4rxgT/wTBpDIrco6bFSolY9rdi0OTTQ91XYSKRxdfvQS3XXpAi1KKLSjsMnPDwuMMRGb1p+tAwA== X-Received: from dmatlack-heavy.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:19cd]) (user=dmatlack job=sendgmr) by 2002:a05:6a00:1a8e:b0:49f:a4a9:8f1e with SMTP id e14-20020a056a001a8e00b0049fa4a98f1emr2860990pfv.67.1636588998080; Wed, 10 Nov 2021 16:03:18 -0800 (PST) Date: Thu, 11 Nov 2021 00:02:59 +0000 In-Reply-To: <20211111000310.1435032-1-dmatlack@google.com> Message-Id: <20211111000310.1435032-2-dmatlack@google.com> Mime-Version: 1.0 References: <20211111000310.1435032-1-dmatlack@google.com> X-Mailer: git-send-email 2.34.0.rc1.387.gb447b232ab-goog Subject: [PATCH v2 01/12] KVM: selftests: Explicitly state indicies for vm_guest_mode_params array From: David Matlack To: Paolo Bonzini Cc: kvm@vger.kernel.org, Sean Christopherson , Ben Gardon , Andrew Jones , Jim Mattson , Yanan Wang , Peter Xu , Aaron Lewis , David Matlack Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Sean Christopherson Explicitly state the indices when populating vm_guest_mode_params to make it marginally easier to visualize what's going on. No functional change intended. Signed-off-by: Sean Christopherson Reviewed-by: Ben Gardon [Added indices for new guest modes.] Signed-off-by: David Matlack --- tools/testing/selftests/kvm/lib/kvm_util.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c index 041004c0fda7..b624c24290dd 100644 --- a/tools/testing/selftests/kvm/lib/kvm_util.c +++ b/tools/testing/selftests/kvm/lib/kvm_util.c @@ -187,15 +187,15 @@ const char *vm_guest_mode_string(uint32_t i) } const struct vm_guest_mode_params vm_guest_mode_params[] = { - { 52, 48, 0x1000, 12 }, - { 52, 48, 0x10000, 16 }, - { 48, 48, 0x1000, 12 }, - { 48, 48, 0x10000, 16 }, - { 40, 48, 0x1000, 12 }, - { 40, 48, 0x10000, 16 }, - { 0, 0, 0x1000, 12 }, - { 47, 64, 0x1000, 12 }, - { 44, 64, 0x1000, 12 }, + [VM_MODE_P52V48_4K] = { 52, 48, 0x1000, 12 }, + [VM_MODE_P52V48_64K] = { 52, 48, 0x10000, 16 }, + [VM_MODE_P48V48_4K] = { 48, 48, 0x1000, 12 }, + [VM_MODE_P48V48_64K] = { 48, 48, 0x10000, 16 }, + [VM_MODE_P40V48_4K] = { 40, 48, 0x1000, 12 }, + [VM_MODE_P40V48_64K] = { 40, 48, 0x10000, 16 }, + [VM_MODE_PXXV48_4K] = { 0, 0, 0x1000, 12 }, + [VM_MODE_P47V64_4K] = { 47, 64, 0x1000, 12 }, + [VM_MODE_P44V64_4K] = { 44, 64, 0x1000, 12 }, }; _Static_assert(sizeof(vm_guest_mode_params)/sizeof(struct vm_guest_mode_params) == NUM_VM_MODES, "Missing new mode params?"); From patchwork Thu Nov 11 00:03:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Matlack X-Patchwork-Id: 12613635 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78133C433EF for ; Thu, 11 Nov 2021 00:03:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5A78A61213 for ; Thu, 11 Nov 2021 00:03:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234282AbhKKAGJ (ORCPT ); Wed, 10 Nov 2021 19:06:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234143AbhKKAGI (ORCPT ); Wed, 10 Nov 2021 19:06:08 -0500 Received: from mail-pf1-x449.google.com (mail-pf1-x449.google.com [IPv6:2607:f8b0:4864:20::449]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24D6AC061766 for ; Wed, 10 Nov 2021 16:03:20 -0800 (PST) Received: by mail-pf1-x449.google.com with SMTP id z19-20020aa79593000000b0049472f5e52dso2829456pfj.13 for ; Wed, 10 Nov 2021 16:03:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=WtDMBXK2xKejOW7vJx3s9hYalI/00GyHa6SMuePndz4=; b=MIQwflEc6oqXjx70AVZ5eD9bECa7/wR2oaCnLFO1sgudZJUmsZZiAHGaQl6KVll1HS OE26HkuzYdDoJI4BUx3G/iYamd71ylH3jzaF7ISeStVqPlyhU1lf9CLUNM5ehD1nfB1B Myk2NDce9ijnp3HWA+Ex76LbliZ100faFXcIa7esrgFFGhfN9YLqPuW7BUAi1F8uV6Ck J2p2qiPR1itAITCJFgNWF95GAR2sd4zKNBUPOKyGliCw6ofoNT2UfkdKNgaHvWTYADkM 2yIaYLX9tLIXnB0L1KJR7I7J6ns+0dfaZUKnOYShBRdnsZBH87Vuuiaoz7jQvlAj+Tm/ vwmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=WtDMBXK2xKejOW7vJx3s9hYalI/00GyHa6SMuePndz4=; b=J8UeOO27ISQzXERJS0o/fv6mi9j80WOD9F/t5y/cALRg2Y/kWsg7HnHTFvZDmjKTfL Kqs8KBIVEf9PgEN1KKuCm0aVYV0CEaNZKFxVK8vwxuV6hUKPSEKXijXvEC3bHLWKpGvz BriLe1yHy/D9dhPR8yYdLIMxFAziY6tlq0s71Va/Btdm0yMF5smyymwU8XmSFlElZDSi /jzYZ+5MQsAqa4j56l/cCInwLKQhI2CpitkDqMO/uVVqvKxOR2RwJcWnHHMi5XoCrbI4 TXzSKy4psVsoTjDiBjQ+xlRFMPtjUCHS6eoaaO3jztSUzP1kzTZ9QHhtzVTeXghRTT47 akbA== X-Gm-Message-State: AOAM532+xjUs82RU8E+76FzuH2o1Jws64Rt/2lm2TPZgbwirw07Pz7HZ EV4168sTqFz8UeDDBR8ZWunW1y9slU4Cxw== X-Google-Smtp-Source: ABdhPJyjwwDbvwMkJuAXBlyZitIg5ob7ltdE+zySMBMf2rRxbOp7FDC5CCbx17iUukikZcqmABazxAFbSHItow== X-Received: from dmatlack-heavy.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:19cd]) (user=dmatlack job=sendgmr) by 2002:a17:903:24c:b0:13f:2377:ef3a with SMTP id j12-20020a170903024c00b0013f2377ef3amr2949466plh.59.1636588999681; Wed, 10 Nov 2021 16:03:19 -0800 (PST) Date: Thu, 11 Nov 2021 00:03:00 +0000 In-Reply-To: <20211111000310.1435032-1-dmatlack@google.com> Message-Id: <20211111000310.1435032-3-dmatlack@google.com> Mime-Version: 1.0 References: <20211111000310.1435032-1-dmatlack@google.com> X-Mailer: git-send-email 2.34.0.rc1.387.gb447b232ab-goog Subject: [PATCH v2 02/12] KVM: selftests: Expose align() helpers to tests From: David Matlack To: Paolo Bonzini Cc: kvm@vger.kernel.org, Sean Christopherson , Ben Gardon , Andrew Jones , Jim Mattson , Yanan Wang , Peter Xu , Aaron Lewis , David Matlack Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Sean Christopherson Refactor align() to work with non-pointers and split into separate helpers for aligning up vs. down. Add align_ptr_up() for use with pointers. Expose all helpers so that they can be used by tests and/or other utilities. The align_down() helper in particular will be used to ensure gpa alignment for hugepages. No functional change intended. Signed-off-by: Sean Christopherson [Added sepearate up/down helpers and replaced open-coded alignment bit math throughout the KVM selftests.] Signed-off-by: David Matlack Reviewed-by: Ben Gardon --- tools/testing/selftests/kvm/dirty_log_test.c | 6 ++--- .../testing/selftests/kvm/include/test_util.h | 25 +++++++++++++++++++ .../selftests/kvm/kvm_page_table_test.c | 2 +- tools/testing/selftests/kvm/lib/elf.c | 3 +-- tools/testing/selftests/kvm/lib/kvm_util.c | 13 ++-------- .../selftests/kvm/lib/perf_test_util.c | 4 +-- 6 files changed, 34 insertions(+), 19 deletions(-) diff --git a/tools/testing/selftests/kvm/dirty_log_test.c b/tools/testing/selftests/kvm/dirty_log_test.c index 792c60e1b17d..3fcd89e195c7 100644 --- a/tools/testing/selftests/kvm/dirty_log_test.c +++ b/tools/testing/selftests/kvm/dirty_log_test.c @@ -115,7 +115,7 @@ static void guest_code(void) addr = guest_test_virt_mem; addr += (READ_ONCE(random_array[i]) % guest_num_pages) * guest_page_size; - addr &= ~(host_page_size - 1); + addr = align_down(addr, host_page_size); *(uint64_t *)addr = READ_ONCE(iteration); } @@ -737,14 +737,14 @@ static void run_test(enum vm_guest_mode mode, void *arg) if (!p->phys_offset) { guest_test_phys_mem = (vm_get_max_gfn(vm) - guest_num_pages) * guest_page_size; - guest_test_phys_mem &= ~(host_page_size - 1); + guest_test_phys_mem = align_down(guest_test_phys_mem, host_page_size); } else { guest_test_phys_mem = p->phys_offset; } #ifdef __s390x__ /* Align to 1M (segment size) */ - guest_test_phys_mem &= ~((1 << 20) - 1); + guest_test_phys_mem = align_down(guest_test_phys_mem, 1 << 20); #endif pr_info("guest physical test memory offset: 0x%lx\n", guest_test_phys_mem); diff --git a/tools/testing/selftests/kvm/include/test_util.h b/tools/testing/selftests/kvm/include/test_util.h index f8fddc84c0d3..78c06310cc0e 100644 --- a/tools/testing/selftests/kvm/include/test_util.h +++ b/tools/testing/selftests/kvm/include/test_util.h @@ -117,4 +117,29 @@ static inline bool backing_src_is_shared(enum vm_mem_backing_src_type t) return vm_mem_backing_src_alias(t)->flag & MAP_SHARED; } +/* Aligns x up to the next multiple of size. Size must be a power of 2. */ +static inline uint64_t align_up(uint64_t x, uint64_t size) +{ + uint64_t mask = size - 1; + + TEST_ASSERT(size != 0 && !(size & (size - 1)), + "size not a power of 2: %lu", size); + return ((x + mask) & ~mask); +} + +static inline uint64_t align_down(uint64_t x, uint64_t size) +{ + uint64_t x_aligned_up = align_up(x, size); + + if (x == x_aligned_up) + return x; + else + return x_aligned_up - size; +} + +static inline void *align_ptr_up(void *x, size_t size) +{ + return (void *)align_up((unsigned long)x, size); +} + #endif /* SELFTEST_KVM_TEST_UTIL_H */ diff --git a/tools/testing/selftests/kvm/kvm_page_table_test.c b/tools/testing/selftests/kvm/kvm_page_table_test.c index 36407cb0ec85..3836322add00 100644 --- a/tools/testing/selftests/kvm/kvm_page_table_test.c +++ b/tools/testing/selftests/kvm/kvm_page_table_test.c @@ -280,7 +280,7 @@ static struct kvm_vm *pre_init_before_test(enum vm_guest_mode mode, void *arg) #ifdef __s390x__ alignment = max(0x100000, alignment); #endif - guest_test_phys_mem &= ~(alignment - 1); + guest_test_phys_mem = align_down(guest_test_virt_mem, alignment); /* Set up the shared data structure test_args */ test_args.vm = vm; diff --git a/tools/testing/selftests/kvm/lib/elf.c b/tools/testing/selftests/kvm/lib/elf.c index eac44f5d0db0..13e8e3dcf984 100644 --- a/tools/testing/selftests/kvm/lib/elf.c +++ b/tools/testing/selftests/kvm/lib/elf.c @@ -157,8 +157,7 @@ void kvm_vm_elf_load(struct kvm_vm *vm, const char *filename) "memsize of 0,\n" " phdr index: %u p_memsz: 0x%" PRIx64, n1, (uint64_t) phdr.p_memsz); - vm_vaddr_t seg_vstart = phdr.p_vaddr; - seg_vstart &= ~(vm_vaddr_t)(vm->page_size - 1); + vm_vaddr_t seg_vstart = align_down(phdr.p_vaddr, vm->page_size); vm_vaddr_t seg_vend = phdr.p_vaddr + phdr.p_memsz - 1; seg_vend |= vm->page_size - 1; size_t seg_size = seg_vend - seg_vstart + 1; diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c index b624c24290dd..63375118d48f 100644 --- a/tools/testing/selftests/kvm/lib/kvm_util.c +++ b/tools/testing/selftests/kvm/lib/kvm_util.c @@ -22,15 +22,6 @@ static int vcpu_mmap_sz(void); -/* Aligns x up to the next multiple of size. Size must be a power of 2. */ -static void *align(void *x, size_t size) -{ - size_t mask = size - 1; - TEST_ASSERT(size != 0 && !(size & (size - 1)), - "size not a power of 2: %lu", size); - return (void *) (((size_t) x + mask) & ~mask); -} - /* * Open KVM_DEV_PATH if available, otherwise exit the entire program. * @@ -911,7 +902,7 @@ void vm_userspace_mem_region_add(struct kvm_vm *vm, region->mmap_start, errno); /* Align host address */ - region->host_mem = align(region->mmap_start, alignment); + region->host_mem = align_ptr_up(region->mmap_start, alignment); /* As needed perform madvise */ if ((src_type == VM_MEM_SRC_ANONYMOUS || @@ -954,7 +945,7 @@ void vm_userspace_mem_region_add(struct kvm_vm *vm, "mmap of alias failed, errno: %i", errno); /* Align host alias address */ - region->host_alias = align(region->mmap_alias, alignment); + region->host_alias = align_ptr_up(region->mmap_alias, alignment); } } diff --git a/tools/testing/selftests/kvm/lib/perf_test_util.c b/tools/testing/selftests/kvm/lib/perf_test_util.c index 0ef80dbdc116..6b8d5020dc54 100644 --- a/tools/testing/selftests/kvm/lib/perf_test_util.c +++ b/tools/testing/selftests/kvm/lib/perf_test_util.c @@ -92,10 +92,10 @@ struct kvm_vm *perf_test_create_vm(enum vm_guest_mode mode, int vcpus, guest_test_phys_mem = (vm_get_max_gfn(vm) - guest_num_pages) * perf_test_args.guest_page_size; - guest_test_phys_mem &= ~(perf_test_args.host_page_size - 1); + guest_test_phys_mem = align_down(guest_test_phys_mem, perf_test_args.host_page_size); #ifdef __s390x__ /* Align to 1M (segment size) */ - guest_test_phys_mem &= ~((1 << 20) - 1); + guest_test_phys_mem = align_down(guest_test_phys_mem, 1 << 20); #endif pr_info("guest physical test memory offset: 0x%lx\n", guest_test_phys_mem); From patchwork Thu Nov 11 00:03:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Matlack X-Patchwork-Id: 12613637 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F139C433F5 for ; Thu, 11 Nov 2021 00:03:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3CAD061213 for ; Thu, 11 Nov 2021 00:03:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234310AbhKKAGL (ORCPT ); Wed, 10 Nov 2021 19:06:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234143AbhKKAGK (ORCPT ); Wed, 10 Nov 2021 19:06:10 -0500 Received: from mail-pf1-x44a.google.com (mail-pf1-x44a.google.com [IPv6:2607:f8b0:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29556C061766 for ; Wed, 10 Nov 2021 16:03:22 -0800 (PST) Received: by mail-pf1-x44a.google.com with SMTP id f206-20020a6238d7000000b004a02dd7156bso1278823pfa.5 for ; Wed, 10 Nov 2021 16:03:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=9I1vEfUzF0fIg2NkKXs5rUv0nbug7Sm5Bkxz8KRA3Ew=; b=KFoekFATRR6k/UnlF7jju0y7F1G+vI0rMS9+lxHk8+nBxJgZTUjH+uf47hwZ5FxCPW whSGN7FLJ7SZoqpSnVfKSwIVqLTisxJ/JTKJjZ7JfufgBMyav54zNIBPWrvhC0S1RNqF QDnmHsBHOvFCRZ1ATWZBMAwproq2IYM1+7OC6Yvlev4rUG6+tg5r4YK1jOuzDfviOy19 WZ36pjXyXSJgsS9XjrOiw42hgM07sQT028c2yZIQdFF+1cV03sSaXn12dJudD9dGTEIw gm0RJJP6o1EuYJno+OjAHYLqBSZty0WDi4p6JVU8qnbDKbY5n++a525e8dJeMmH5R9vN f6FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=9I1vEfUzF0fIg2NkKXs5rUv0nbug7Sm5Bkxz8KRA3Ew=; b=Nxykq2g6jmuP5jtg/RcYNAwkj1CaN/4eYpKZvImhoPFFbCyQFIticQVAOeMvAjyzxX GotckHBpYzUt4W2t3FGGvzvPeojwvnFC4XnLFSd3M15cOsbxdwPJs7Wi4IM4HEC6n3YT 45Aj4Z3wCc/1WKXruwg/jZKfJsX6mVr39k6N7dF3ZxVnJ0k4F3qvzVe+PlcAqsnCkKIa mIGzvs7GQOw7yidZCujseTq0F1vseI7SkW7RGdkTX4/E/twazVEvcpiE2coFN31tmJsG ezdpHFXzm/7pIHwVQlN3urus5J+DhgAqkMR6/93C2yIUQtZfSTcVc3JS675D4heACAEL czbw== X-Gm-Message-State: AOAM5332q1tsc5ryL/1hGBiK4O2LTxJ5x01kZ5nCuxLmrxcU2/x0/Z+D DAmu5war4edDmh51fyxM5sdL429nZaq/9A== X-Google-Smtp-Source: ABdhPJwNzAk/IL/P6vBP9cQwPI+KD4OFkjXWk6wHPXNBb/vK6/obTvM6lNGJo0AYRGFCq7BtFb9UPTCGri1Q7g== X-Received: from dmatlack-heavy.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:19cd]) (user=dmatlack job=sendgmr) by 2002:a17:90a:284f:: with SMTP id p15mr89935pjf.1.1636589001326; Wed, 10 Nov 2021 16:03:21 -0800 (PST) Date: Thu, 11 Nov 2021 00:03:01 +0000 In-Reply-To: <20211111000310.1435032-1-dmatlack@google.com> Message-Id: <20211111000310.1435032-4-dmatlack@google.com> Mime-Version: 1.0 References: <20211111000310.1435032-1-dmatlack@google.com> X-Mailer: git-send-email 2.34.0.rc1.387.gb447b232ab-goog Subject: [PATCH v2 03/12] KVM: selftests: Assert mmap HVA is aligned when using HugeTLB From: David Matlack To: Paolo Bonzini Cc: kvm@vger.kernel.org, Sean Christopherson , Ben Gardon , Andrew Jones , Jim Mattson , Yanan Wang , Peter Xu , Aaron Lewis , David Matlack Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Sean Christopherson Manually padding and aligning the mmap region is only needed when using THP. When using HugeTLB, mmap will always return an address aligned to the HugeTLB page size. Add a comment to clarify this and assert the mmap behavior for HugeTLB. Cc: Ben Gardon Cc: Yanan Wang Cc: Andrew Jones Cc: Peter Xu Cc: Aaron Lewis Signed-off-by: Sean Christopherson [Removed requirement that HugeTLB mmaps must be padded per Yanan's feedback and added assertion that mmap returns aligned addresses when using HugeTLB.] Signed-off-by: David Matlack --- tools/testing/selftests/kvm/include/test_util.h | 1 + tools/testing/selftests/kvm/lib/kvm_util.c | 11 +++++++++++ tools/testing/selftests/kvm/lib/test_util.c | 5 +++++ 3 files changed, 17 insertions(+) diff --git a/tools/testing/selftests/kvm/include/test_util.h b/tools/testing/selftests/kvm/include/test_util.h index 78c06310cc0e..99e0dcdc923f 100644 --- a/tools/testing/selftests/kvm/include/test_util.h +++ b/tools/testing/selftests/kvm/include/test_util.h @@ -104,6 +104,7 @@ size_t get_trans_hugepagesz(void); size_t get_def_hugetlb_pagesz(void); const struct vm_mem_backing_src_alias *vm_mem_backing_src_alias(uint32_t i); size_t get_backing_src_pagesz(uint32_t i); +bool is_backing_src_hugetlb(uint32_t i); void backing_src_help(const char *flag); enum vm_mem_backing_src_type parse_backing_src_type(const char *type_name); long get_run_delay(void); diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c index 63375118d48f..07f37456bba0 100644 --- a/tools/testing/selftests/kvm/lib/kvm_util.c +++ b/tools/testing/selftests/kvm/lib/kvm_util.c @@ -866,6 +866,12 @@ void vm_userspace_mem_region_add(struct kvm_vm *vm, alignment = 1; #endif + /* + * When using THP mmap is not guaranteed to returned a hugepage aligned + * address so we have to pad the mmap. Padding is not needed for HugeTLB + * because mmap will always return an address aligned to the HugeTLB + * page size. + */ if (src_type == VM_MEM_SRC_ANONYMOUS_THP) alignment = max(backing_src_pagesz, alignment); @@ -901,6 +907,11 @@ void vm_userspace_mem_region_add(struct kvm_vm *vm, "test_malloc failed, mmap_start: %p errno: %i", region->mmap_start, errno); + TEST_ASSERT(!is_backing_src_hugetlb(src_type) || + region->mmap_start == align_ptr_up(region->mmap_start, backing_src_pagesz), + "mmap_start %p is not aligned to HugeTLB page size 0x%lx", + region->mmap_start, backing_src_pagesz); + /* Align host address */ region->host_mem = align_ptr_up(region->mmap_start, alignment); diff --git a/tools/testing/selftests/kvm/lib/test_util.c b/tools/testing/selftests/kvm/lib/test_util.c index b72429108993..6d23878bbfe1 100644 --- a/tools/testing/selftests/kvm/lib/test_util.c +++ b/tools/testing/selftests/kvm/lib/test_util.c @@ -283,6 +283,11 @@ size_t get_backing_src_pagesz(uint32_t i) } } +bool is_backing_src_hugetlb(uint32_t i) +{ + return !!(vm_mem_backing_src_alias(i)->flag & MAP_HUGETLB); +} + static void print_available_backing_src_types(const char *prefix) { int i; From patchwork Thu Nov 11 00:03:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Matlack X-Patchwork-Id: 12613639 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48E5CC433EF for ; Thu, 11 Nov 2021 00:03:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1F61E61105 for ; Thu, 11 Nov 2021 00:03:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234320AbhKKAGO (ORCPT ); Wed, 10 Nov 2021 19:06:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234298AbhKKAGL (ORCPT ); Wed, 10 Nov 2021 19:06:11 -0500 Received: from mail-pf1-x449.google.com (mail-pf1-x449.google.com [IPv6:2607:f8b0:4864:20::449]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BF48C061766 for ; Wed, 10 Nov 2021 16:03:23 -0800 (PST) Received: by mail-pf1-x449.google.com with SMTP id e12-20020aa7980c000000b0049fa3fc29d0so2851431pfl.10 for ; Wed, 10 Nov 2021 16:03:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=B8cm2qYWROOtIl5gOndE9XoYMKnnSnuEUS9XIYWaW0E=; b=FGHd0rNtDhbC8/teZ4SMfK2SKHrj53ddkDEogPUQBPaSz4rKwtmYvw6fAaIkct9S0m EKy8ppo+R2/+mKhy6gNq8AxXEE1oB8AI3gC/TMQd3/ovpFk/v1hZoEEVhrAeaWA+LxCH F0+p2xd/jdmIOeKmgPusxz3Job9oz+p/nAWfRxsZP7Vq3uO84jyn1AuYyPW89nZNc9lO MoyPw8tixKYol2PcFzmZ6ymm2uS9o8pRj6eCJ61mgLWh6XrQpjXIz0f9gDYi9U4V693F cctox7c0L9wB3S+l6HOHmqwfXQNINPLpRBldZDT3rHPFXajNiFg84ZdQtE8mQ/ZSIGiG o9qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=B8cm2qYWROOtIl5gOndE9XoYMKnnSnuEUS9XIYWaW0E=; b=KYYFNDfyC9cEVm9pvr/mt5CMUj/z88o/u6bs9dl/DgcJI2yfTnD0GrwbhxOVPSsR4t 7Alt054LA3TlpgDVSmNmAqngPDG9JBBt11jsJWrdann6OGTjwx7wkjbzI4vifg94PE8H LBNLdd0Q2yHdMIVJ6mA2kr443znFIDBTe9Cdc/rvEHze8epU8Du3shgysFBhGUQrbWT2 KuJO9cxSsIW0K53MmJznJdB+Xrhiy9x3Ggd2jinU4bDrKiQ0d/xQibM8EfW9KsK1M/gI r3Q4I320ppcRV+WOCygYkjYu55VoYZj1HovcxUevvLR28mzaynAU9qxhudmoomPBoU6l FwSw== X-Gm-Message-State: AOAM533YhxrFp10rjBuUJAfBqriVBPx/G+F4z8H4C1ZeT5OvIocvgvpw QYXKk7PMteis6A0Jl2Rok6eJCHeejQjEXw== X-Google-Smtp-Source: ABdhPJym0I4bUp2j9QUcsaaLlRS1m9gACZ5l/RAWeIUiMUtptxbNufJmNCRzjfkLtdm0LbWzOH7gBXuqoLM1dA== X-Received: from dmatlack-heavy.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:19cd]) (user=dmatlack job=sendgmr) by 2002:a17:90a:3045:: with SMTP id q5mr3492640pjl.58.1636589002881; Wed, 10 Nov 2021 16:03:22 -0800 (PST) Date: Thu, 11 Nov 2021 00:03:02 +0000 In-Reply-To: <20211111000310.1435032-1-dmatlack@google.com> Message-Id: <20211111000310.1435032-5-dmatlack@google.com> Mime-Version: 1.0 References: <20211111000310.1435032-1-dmatlack@google.com> X-Mailer: git-send-email 2.34.0.rc1.387.gb447b232ab-goog Subject: [PATCH v2 04/12] KVM: selftests: Require GPA to be aligned when backed by hugepages From: David Matlack To: Paolo Bonzini Cc: kvm@vger.kernel.org, Sean Christopherson , Ben Gardon , Andrew Jones , Jim Mattson , Yanan Wang , Peter Xu , Aaron Lewis , David Matlack Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Sean Christopherson Assert that the GPA for a memslot backed by a hugepage is aligned to the hugepage size and fix perf_test_util accordingly. Lack of GPA alignment prevents KVM from backing the guest with hugepages, e.g. x86's write-protection of hugepages when dirty logging is activated is otherwise not exercised. Add a comment explaining that guest_page_size is for non-huge pages to try and avoid confusion about what it actually tracks. Cc: Ben Gardon Cc: Yanan Wang Cc: Andrew Jones Cc: Peter Xu Cc: Aaron Lewis Signed-off-by: Sean Christopherson [Used get_backing_src_pagesz() to determine alignment dynamically.] Signed-off-by: David Matlack --- tools/testing/selftests/kvm/lib/kvm_util.c | 2 ++ tools/testing/selftests/kvm/lib/perf_test_util.c | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c index 07f37456bba0..1f6a01c33dce 100644 --- a/tools/testing/selftests/kvm/lib/kvm_util.c +++ b/tools/testing/selftests/kvm/lib/kvm_util.c @@ -875,6 +875,8 @@ void vm_userspace_mem_region_add(struct kvm_vm *vm, if (src_type == VM_MEM_SRC_ANONYMOUS_THP) alignment = max(backing_src_pagesz, alignment); + ASSERT_EQ(guest_paddr, align_up(guest_paddr, backing_src_pagesz)); + /* Add enough memory to align up if necessary */ if (alignment > 1) region->mmap_size += alignment; diff --git a/tools/testing/selftests/kvm/lib/perf_test_util.c b/tools/testing/selftests/kvm/lib/perf_test_util.c index 6b8d5020dc54..a015f267d945 100644 --- a/tools/testing/selftests/kvm/lib/perf_test_util.c +++ b/tools/testing/selftests/kvm/lib/perf_test_util.c @@ -55,11 +55,16 @@ struct kvm_vm *perf_test_create_vm(enum vm_guest_mode mode, int vcpus, { struct kvm_vm *vm; uint64_t guest_num_pages; + uint64_t backing_src_pagesz = get_backing_src_pagesz(backing_src); int i; pr_info("Testing guest mode: %s\n", vm_guest_mode_string(mode)); perf_test_args.host_page_size = getpagesize(); + /* + * Snapshot the non-huge page size. This is used by the guest code to + * access/dirty pages at the logging granularity. + */ perf_test_args.guest_page_size = vm_guest_mode_params[mode].page_size; guest_num_pages = vm_adjust_num_guest_pages(mode, @@ -92,7 +97,7 @@ struct kvm_vm *perf_test_create_vm(enum vm_guest_mode mode, int vcpus, guest_test_phys_mem = (vm_get_max_gfn(vm) - guest_num_pages) * perf_test_args.guest_page_size; - guest_test_phys_mem = align_down(guest_test_phys_mem, perf_test_args.host_page_size); + guest_test_phys_mem = align_down(guest_test_phys_mem, backing_src_pagesz); #ifdef __s390x__ /* Align to 1M (segment size) */ guest_test_phys_mem = align_down(guest_test_phys_mem, 1 << 20); From patchwork Thu Nov 11 00:03:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Matlack X-Patchwork-Id: 12613645 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C948C433F5 for ; Thu, 11 Nov 2021 00:03:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5FCFB61213 for ; Thu, 11 Nov 2021 00:03:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234324AbhKKAGR (ORCPT ); Wed, 10 Nov 2021 19:06:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234315AbhKKAGN (ORCPT ); Wed, 10 Nov 2021 19:06:13 -0500 Received: from mail-pf1-x449.google.com (mail-pf1-x449.google.com [IPv6:2607:f8b0:4864:20::449]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1288BC0613F5 for ; Wed, 10 Nov 2021 16:03:25 -0800 (PST) Received: by mail-pf1-x449.google.com with SMTP id e12-20020aa7980c000000b0049fa3fc29d0so2851486pfl.10 for ; Wed, 10 Nov 2021 16:03:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=ixtDEsrmQegbuMXL4qtAfwrCVIUP/EwC7eFMjrlz0FY=; b=UZ1xzYCTus0otnrDbFNuj8+u/tnLwjb73kSF6QupVWMkyPP3r+kliFKOOyL9/nRL0Z tHgANyASUuSU9ABAkceHo0gn/2rDnJewZFC0e1moGbtL2VRuQ0mXb0vHh/2OfLwvQUsV yjO8s0K3RoX9HSo8LM0naTxqp+i1B4hnOm1AjZ7oIe9UDyRG1uQvVRL7j3ZPAP62zjfF 6MjQn8YqZxpcZEZC+u74Nw5eyBpIPCV2c5c6Rn0iJQCLyXe31LlyWqeXX/ywO2xvL7MX zc0yoXXnMMGZ4pDqg+mJJouwKPh6+wjVzhV9lERn51yHCLWmVUqzwGoOgI07GBwYuter pnIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=ixtDEsrmQegbuMXL4qtAfwrCVIUP/EwC7eFMjrlz0FY=; b=TgPdy1ZjTwLFMShw31TZOcDlT8LO/dw4FFblk/zVfATnTa1U9tBHAq46jz+pHrIeAI +kpMAp/oPNJILLlTiX9EMlFPjr401mjCvcDMaQGrzwUjh9V/mvtSsKQfMJOWS91oN65M 85aO26fiEpCnOte5IMuRu8oG60cCMoGnnzIWgMFzCYCG3mgno8PNqKloTgV930QtlmSi MiGmxO8k62ou9LaoYCpxWTRh2AYuPzIEG5ZKOJlXQqu8uk4N+krZKTLIuHZIlt7ZWEY6 KEC7dOxsa+oaZVSfyRsu4w3DAdDjUrC2bL8vS97ji6CmCJDWvJNwC0oFQa+I4jzRGqz1 JxSw== X-Gm-Message-State: AOAM532xAb5Fik4shjqOITh0xhdrNgSGc+9RxJeqDkrA6ogP7ZM5IBEp JEk1msphpz2dZkZR19rsBNzQZDP/6a4KNQ== X-Google-Smtp-Source: ABdhPJxJmKLIjw4qWGdZWRks4nnBcy8pdHYButyTVKyc/5wqhzgbZ2ELt8V1U/24mihHi9J/NLwzRA346lfUOg== X-Received: from dmatlack-heavy.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:19cd]) (user=dmatlack job=sendgmr) by 2002:a63:5c4b:: with SMTP id n11mr1204330pgm.105.1636589004600; Wed, 10 Nov 2021 16:03:24 -0800 (PST) Date: Thu, 11 Nov 2021 00:03:03 +0000 In-Reply-To: <20211111000310.1435032-1-dmatlack@google.com> Message-Id: <20211111000310.1435032-6-dmatlack@google.com> Mime-Version: 1.0 References: <20211111000310.1435032-1-dmatlack@google.com> X-Mailer: git-send-email 2.34.0.rc1.387.gb447b232ab-goog Subject: [PATCH v2 05/12] KVM: selftests: Use shorthand local var to access struct perf_tests_args From: David Matlack To: Paolo Bonzini Cc: kvm@vger.kernel.org, Sean Christopherson , Ben Gardon , Andrew Jones , Jim Mattson , Yanan Wang , Peter Xu , Aaron Lewis , David Matlack Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Sean Christopherson Use 'pta' as a local pointer to the global perf_tests_args in order to shorten line lengths and make the code borderline readable. No functional change intended. Signed-off-by: Sean Christopherson Reviewed-by: Ben Gardon Signed-off-by: David Matlack --- .../selftests/kvm/lib/perf_test_util.c | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/tools/testing/selftests/kvm/lib/perf_test_util.c b/tools/testing/selftests/kvm/lib/perf_test_util.c index a015f267d945..ccdc950c829e 100644 --- a/tools/testing/selftests/kvm/lib/perf_test_util.c +++ b/tools/testing/selftests/kvm/lib/perf_test_util.c @@ -24,7 +24,8 @@ static uint64_t guest_test_virt_mem = DEFAULT_GUEST_TEST_MEM; */ static void guest_code(uint32_t vcpu_id) { - struct perf_test_vcpu_args *vcpu_args = &perf_test_args.vcpu_args[vcpu_id]; + struct perf_test_args *pta = &perf_test_args; + struct perf_test_vcpu_args *vcpu_args = &pta->vcpu_args[vcpu_id]; uint64_t gva; uint64_t pages; int i; @@ -37,9 +38,9 @@ static void guest_code(uint32_t vcpu_id) while (true) { for (i = 0; i < pages; i++) { - uint64_t addr = gva + (i * perf_test_args.guest_page_size); + uint64_t addr = gva + (i * pta->guest_page_size); - if (i % perf_test_args.wr_fract == 0) + if (i % pta->wr_fract == 0) *(uint64_t *)addr = 0x0123456789ABCDEF; else READ_ONCE(*(uint64_t *)addr); @@ -53,6 +54,7 @@ struct kvm_vm *perf_test_create_vm(enum vm_guest_mode mode, int vcpus, uint64_t vcpu_memory_bytes, int slots, enum vm_mem_backing_src_type backing_src) { + struct perf_test_args *pta = &perf_test_args; struct kvm_vm *vm; uint64_t guest_num_pages; uint64_t backing_src_pagesz = get_backing_src_pagesz(backing_src); @@ -60,29 +62,29 @@ struct kvm_vm *perf_test_create_vm(enum vm_guest_mode mode, int vcpus, pr_info("Testing guest mode: %s\n", vm_guest_mode_string(mode)); - perf_test_args.host_page_size = getpagesize(); + pta->host_page_size = getpagesize(); /* * Snapshot the non-huge page size. This is used by the guest code to * access/dirty pages at the logging granularity. */ - perf_test_args.guest_page_size = vm_guest_mode_params[mode].page_size; + pta->guest_page_size = vm_guest_mode_params[mode].page_size; guest_num_pages = vm_adjust_num_guest_pages(mode, - (vcpus * vcpu_memory_bytes) / perf_test_args.guest_page_size); + (vcpus * vcpu_memory_bytes) / pta->guest_page_size); - TEST_ASSERT(vcpu_memory_bytes % perf_test_args.host_page_size == 0, + TEST_ASSERT(vcpu_memory_bytes % pta->host_page_size == 0, "Guest memory size is not host page size aligned."); - TEST_ASSERT(vcpu_memory_bytes % perf_test_args.guest_page_size == 0, + TEST_ASSERT(vcpu_memory_bytes % pta->guest_page_size == 0, "Guest memory size is not guest page size aligned."); TEST_ASSERT(guest_num_pages % slots == 0, "Guest memory cannot be evenly divided into %d slots.", slots); vm = vm_create_with_vcpus(mode, vcpus, DEFAULT_GUEST_PHY_PAGES, - (vcpus * vcpu_memory_bytes) / perf_test_args.guest_page_size, + (vcpus * vcpu_memory_bytes) / pta->guest_page_size, 0, guest_code, NULL); - perf_test_args.vm = vm; + pta->vm = vm; /* * If there should be more memory in the guest test region than there @@ -96,7 +98,7 @@ struct kvm_vm *perf_test_create_vm(enum vm_guest_mode mode, int vcpus, vcpu_memory_bytes); guest_test_phys_mem = (vm_get_max_gfn(vm) - guest_num_pages) * - perf_test_args.guest_page_size; + pta->guest_page_size; guest_test_phys_mem = align_down(guest_test_phys_mem, backing_src_pagesz); #ifdef __s390x__ /* Align to 1M (segment size) */ @@ -108,7 +110,7 @@ struct kvm_vm *perf_test_create_vm(enum vm_guest_mode mode, int vcpus, for (i = 0; i < slots; i++) { uint64_t region_pages = guest_num_pages / slots; vm_paddr_t region_start = guest_test_phys_mem + - region_pages * perf_test_args.guest_page_size * i; + region_pages * pta->guest_page_size * i; vm_userspace_mem_region_add(vm, backing_src, region_start, PERF_TEST_MEM_SLOT_INDEX + i, @@ -133,25 +135,26 @@ void perf_test_setup_vcpus(struct kvm_vm *vm, int vcpus, uint64_t vcpu_memory_bytes, bool partition_vcpu_memory_access) { + struct perf_test_args *pta = &perf_test_args; vm_paddr_t vcpu_gpa; struct perf_test_vcpu_args *vcpu_args; int vcpu_id; for (vcpu_id = 0; vcpu_id < vcpus; vcpu_id++) { - vcpu_args = &perf_test_args.vcpu_args[vcpu_id]; + vcpu_args = &pta->vcpu_args[vcpu_id]; vcpu_args->vcpu_id = vcpu_id; if (partition_vcpu_memory_access) { vcpu_args->gva = guest_test_virt_mem + (vcpu_id * vcpu_memory_bytes); vcpu_args->pages = vcpu_memory_bytes / - perf_test_args.guest_page_size; + pta->guest_page_size; vcpu_gpa = guest_test_phys_mem + (vcpu_id * vcpu_memory_bytes); } else { vcpu_args->gva = guest_test_virt_mem; vcpu_args->pages = (vcpus * vcpu_memory_bytes) / - perf_test_args.guest_page_size; + pta->guest_page_size; vcpu_gpa = guest_test_phys_mem; } @@ -159,6 +162,6 @@ void perf_test_setup_vcpus(struct kvm_vm *vm, int vcpus, pr_debug("Added VCPU %d with test mem gpa [%lx, %lx)\n", vcpu_id, vcpu_gpa, vcpu_gpa + - (vcpu_args->pages * perf_test_args.guest_page_size)); + (vcpu_args->pages * pta->guest_page_size)); } } From patchwork Thu Nov 11 00:03:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Matlack X-Patchwork-Id: 12613641 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5A185C433EF for ; Thu, 11 Nov 2021 00:03:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3F01B61105 for ; Thu, 11 Nov 2021 00:03:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234303AbhKKAGQ (ORCPT ); Wed, 10 Nov 2021 19:06:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234319AbhKKAGO (ORCPT ); Wed, 10 Nov 2021 19:06:14 -0500 Received: from mail-pl1-x64a.google.com (mail-pl1-x64a.google.com [IPv6:2607:f8b0:4864:20::64a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA604C06127A for ; Wed, 10 Nov 2021 16:03:26 -0800 (PST) Received: by mail-pl1-x64a.google.com with SMTP id z3-20020a170903018300b0014224dca4a1so2178860plg.0 for ; Wed, 10 Nov 2021 16:03:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=sFLbWO4bOI5I9JoMGkKQ6ckt7pYNE6wIcP4cuGr2rxs=; b=OJU6vrgnj3uSZ8ycvuKmSQR63UBrpBUMkDD76zH8p79gq0uiRL7U/o80DIp7as0HeS y3UFG8IcseXw+b1ZjLL5NvowOx/vwofPs2Bjxxpbrx4FXwsqHpwjFcKbXQS0ZiHrgRva hHTcNGwqBlUmeZKQtPifXyR59f3tXKD2nNAFQ+T0lUY87p+7r7usSjvKPZ73ROb7Gka0 UowXlSmrhlrF94CH5ohf7uGFjLxAA5zM8b2rQYSshpGV5lhu6EK0VTcTit48lvEVlS/M AyR0VNrdeKBGcfeN+AYfF3jxgx8pzqShEmV3pV5P+zjxlRifbLtP56puh2pl2haoPZCb 5hdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=sFLbWO4bOI5I9JoMGkKQ6ckt7pYNE6wIcP4cuGr2rxs=; b=6xCpKXfXHoR8J/Ie6c1Go3qGZaVatQAX1XDpRHi3lKa97YKQBeZugA+DuFVhQ6kkLt nqAPEBno1N7lC7ayeCYRcRp0T6SBq/VZ/Qi5+vDqwQBtW7PdIaIqy6wekqTS8xQmA7R/ 0n05NRwRBwVxViuDw/7ockrCav66VDz7xCa97h7B1bkEG30Ch3iplFINylFVlsEhUhvt rDWQgMk44rIghrq6KnW8hsZ6o3jFAxLhw/r4Drw6rpPPUM8Y/0K2ylqiBf/zMUMbb2o8 iMYFw7W25ZKfS1lkOSX8CSOWTYBSCRQzEhIyYH0zB/eQwVUg/dQw6fSoV93Up6pDVGHY YjMA== X-Gm-Message-State: AOAM530JpXsfr/uIMiZRko5hl2G7Jk4pH+MeIDwUFmXfSPdL44aIx7nN Co//5iUK6ZB7/iWOiPr3veEhhWT8ZDHlNA== X-Google-Smtp-Source: ABdhPJwTiTvkmcRFNfX2YNbZMhTDBXnt/PWSC+XeuI1UXlYstFyUaxR3Pc9jLIfNmo38Pu8RoqFIqFtyAXdDnw== X-Received: from dmatlack-heavy.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:19cd]) (user=dmatlack job=sendgmr) by 2002:a17:902:654d:b0:141:7df3:b94 with SMTP id d13-20020a170902654d00b001417df30b94mr3295949pln.60.1636589006192; Wed, 10 Nov 2021 16:03:26 -0800 (PST) Date: Thu, 11 Nov 2021 00:03:04 +0000 In-Reply-To: <20211111000310.1435032-1-dmatlack@google.com> Message-Id: <20211111000310.1435032-7-dmatlack@google.com> Mime-Version: 1.0 References: <20211111000310.1435032-1-dmatlack@google.com> X-Mailer: git-send-email 2.34.0.rc1.387.gb447b232ab-goog Subject: [PATCH v2 06/12] KVM: selftests: Capture per-vCPU GPA in perf_test_vcpu_args From: David Matlack To: Paolo Bonzini Cc: kvm@vger.kernel.org, Sean Christopherson , Ben Gardon , Andrew Jones , Jim Mattson , Yanan Wang , Peter Xu , Aaron Lewis , David Matlack Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Sean Christopherson Capture the per-vCPU GPA in perf_test_vcpu_args so that tests can get the GPA without having to calculate the GPA on their own. No functional change intended. Signed-off-by: Sean Christopherson Reviewed-by: Ben Gardon Signed-off-by: David Matlack --- tools/testing/selftests/kvm/include/perf_test_util.h | 1 + tools/testing/selftests/kvm/lib/perf_test_util.c | 9 ++++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/kvm/include/perf_test_util.h b/tools/testing/selftests/kvm/include/perf_test_util.h index df9f1a3a3ffb..20aec72fe7b8 100644 --- a/tools/testing/selftests/kvm/include/perf_test_util.h +++ b/tools/testing/selftests/kvm/include/perf_test_util.h @@ -18,6 +18,7 @@ #define PERF_TEST_MEM_SLOT_INDEX 1 struct perf_test_vcpu_args { + uint64_t gpa; uint64_t gva; uint64_t pages; diff --git a/tools/testing/selftests/kvm/lib/perf_test_util.c b/tools/testing/selftests/kvm/lib/perf_test_util.c index ccdc950c829e..d9c6bcb7964d 100644 --- a/tools/testing/selftests/kvm/lib/perf_test_util.c +++ b/tools/testing/selftests/kvm/lib/perf_test_util.c @@ -136,7 +136,6 @@ void perf_test_setup_vcpus(struct kvm_vm *vm, int vcpus, bool partition_vcpu_memory_access) { struct perf_test_args *pta = &perf_test_args; - vm_paddr_t vcpu_gpa; struct perf_test_vcpu_args *vcpu_args; int vcpu_id; @@ -149,19 +148,19 @@ void perf_test_setup_vcpus(struct kvm_vm *vm, int vcpus, (vcpu_id * vcpu_memory_bytes); vcpu_args->pages = vcpu_memory_bytes / pta->guest_page_size; - vcpu_gpa = guest_test_phys_mem + - (vcpu_id * vcpu_memory_bytes); + vcpu_args->gpa = guest_test_phys_mem + + (vcpu_id * vcpu_memory_bytes); } else { vcpu_args->gva = guest_test_virt_mem; vcpu_args->pages = (vcpus * vcpu_memory_bytes) / pta->guest_page_size; - vcpu_gpa = guest_test_phys_mem; + vcpu_args->gpa = guest_test_phys_mem; } vcpu_args_set(vm, vcpu_id, 1, vcpu_id); pr_debug("Added VCPU %d with test mem gpa [%lx, %lx)\n", - vcpu_id, vcpu_gpa, vcpu_gpa + + vcpu_id, vcpu_args->gpa, vcpu_args->gpa + (vcpu_args->pages * pta->guest_page_size)); } } From patchwork Thu Nov 11 00:03:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Matlack X-Patchwork-Id: 12613643 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8EED8C433FE for ; Thu, 11 Nov 2021 00:03:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6E7AD61241 for ; Thu, 11 Nov 2021 00:03:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234331AbhKKAGS (ORCPT ); Wed, 10 Nov 2021 19:06:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234287AbhKKAGQ (ORCPT ); Wed, 10 Nov 2021 19:06:16 -0500 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EEC8C061766 for ; Wed, 10 Nov 2021 16:03:28 -0800 (PST) Received: by mail-yb1-xb4a.google.com with SMTP id t24-20020a252d18000000b005c225ae9e16so6602743ybt.15 for ; Wed, 10 Nov 2021 16:03:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=BnDYr7XeHG59cPA98gYZELhabwdzUR4OfVOWYOyZ6EU=; b=sdOEnVAJx8GbSLGQSvAV1rJl6GRwRVQrZiW9VTo26tMd8jFVcv5Ol48U79d8/enJSq wdlAHGAxz3wLd9A7PVO2bdaiTh7HbW9ElMLBX1lByNluz3pb9UCBtZ4e7ySTRD+pJeB1 Sh4BV6Ni0bYmEwOU3kf/VUTZa6vGs9ECMjiRQb/SfFMfF5prrx+CqsBEuS1JWpiH90l5 fuGr+C7Zg+7kAXkZPKU7xMS/X/XrDaOUteC+9o3qzIJyR9aIXhfITOrVUF/vFy9x8hSn oFovH5y1oTuqfJrcp9Ud/EES+aQswnpFNzIT01zvdh0UhVkHdwiz59re5RdfvAaiEq2O xEAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=BnDYr7XeHG59cPA98gYZELhabwdzUR4OfVOWYOyZ6EU=; b=IpvwRuks6ITkutNxXNCp2SghptqMda2YCUaZbOz1Qchc+S7TXXDmVjtVsPlEINTZiV 45o3XEETd++bxn2YaU7B566wSuR1RczyNry0uELH4eMswDXrzgiwvY8jMGpzHxOTIMMR 2YYMQU9TpFjAMRl3OIZZL32JS/DglwNtVf/hY0IjoLQpeHI+9WXHiCUWqiLhmOuJBfop BeKnzxehkMSD1RbxvLmnMspQlG0NjJ3Qim4aSigypamLkViZAD3Gtbsi9T7mrLk81/L9 Jo18mGKBmjsnl2MLyXMveqQtamqBG2GdFhMx1Tzdml8fE7s7PqvGycyoRXZwwJhGf2Hh OLsw== X-Gm-Message-State: AOAM530kCPrhLh9dfB3ci050po7q8ddzWgWqSkjWEhcgo693EjhImRfC r/xxSUYWsh/t4+ybU1MUJMihSU4ySXIUcQ== X-Google-Smtp-Source: ABdhPJw4KmYhJehCaO58EiAB8UZRtWym1d/vti55KXrbtM6qhbk60HDJlXidasiZR+EiQ5ScjqBjjh3ahQusng== X-Received: from dmatlack-heavy.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:19cd]) (user=dmatlack job=sendgmr) by 2002:a25:748a:: with SMTP id p132mr3421484ybc.207.1636589007776; Wed, 10 Nov 2021 16:03:27 -0800 (PST) Date: Thu, 11 Nov 2021 00:03:05 +0000 In-Reply-To: <20211111000310.1435032-1-dmatlack@google.com> Message-Id: <20211111000310.1435032-8-dmatlack@google.com> Mime-Version: 1.0 References: <20211111000310.1435032-1-dmatlack@google.com> X-Mailer: git-send-email 2.34.0.rc1.387.gb447b232ab-goog Subject: [PATCH v2 07/12] KVM: selftests: Use perf util's per-vCPU GPA/pages in demand paging test From: David Matlack To: Paolo Bonzini Cc: kvm@vger.kernel.org, Sean Christopherson , Ben Gardon , Andrew Jones , Jim Mattson , Yanan Wang , Peter Xu , Aaron Lewis , David Matlack Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Sean Christopherson Grab the per-vCPU GPA and number of pages from perf_util in the demand paging test instead of duplicating perf_util's calculations. Note, this may or may not result in a functional change. It's not clear that the test's calculations are guaranteed to yield the same value as perf_util, e.g. if guest_percpu_mem_size != vcpu_args->pages. Signed-off-by: Sean Christopherson Reviewed-by: Ben Gardon Signed-off-by: David Matlack --- .../selftests/kvm/demand_paging_test.c | 21 +++++-------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/tools/testing/selftests/kvm/demand_paging_test.c b/tools/testing/selftests/kvm/demand_paging_test.c index 1510b21e6306..3c729a0a1ab1 100644 --- a/tools/testing/selftests/kvm/demand_paging_test.c +++ b/tools/testing/selftests/kvm/demand_paging_test.c @@ -322,26 +322,15 @@ static void run_test(enum vm_guest_mode mode, void *arg) TEST_ASSERT(pipefds, "Unable to allocate memory for pipefd"); for (vcpu_id = 0; vcpu_id < nr_vcpus; vcpu_id++) { - vm_paddr_t vcpu_gpa; + struct perf_test_vcpu_args *vcpu_args; void *vcpu_hva; void *vcpu_alias; - uint64_t vcpu_mem_size; - - if (p->partition_vcpu_memory_access) { - vcpu_gpa = guest_test_phys_mem + - (vcpu_id * guest_percpu_mem_size); - vcpu_mem_size = guest_percpu_mem_size; - } else { - vcpu_gpa = guest_test_phys_mem; - vcpu_mem_size = guest_percpu_mem_size * nr_vcpus; - } - PER_VCPU_DEBUG("Added VCPU %d with test mem gpa [%lx, %lx)\n", - vcpu_id, vcpu_gpa, vcpu_gpa + vcpu_mem_size); + vcpu_args = &perf_test_args.vcpu_args[vcpu_id]; /* Cache the host addresses of the region */ - vcpu_hva = addr_gpa2hva(vm, vcpu_gpa); - vcpu_alias = addr_gpa2alias(vm, vcpu_gpa); + vcpu_hva = addr_gpa2hva(vm, vcpu_args->gpa); + vcpu_alias = addr_gpa2alias(vm, vcpu_args->gpa); /* * Set up user fault fd to handle demand paging @@ -355,7 +344,7 @@ static void run_test(enum vm_guest_mode mode, void *arg) pipefds[vcpu_id * 2], p->uffd_mode, p->uffd_delay, &uffd_args[vcpu_id], vcpu_hva, vcpu_alias, - vcpu_mem_size); + vcpu_args->pages * perf_test_args.guest_page_size); } } From patchwork Thu Nov 11 00:03:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Matlack X-Patchwork-Id: 12613647 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 45641C4332F for ; Thu, 11 Nov 2021 00:03:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2C2886124D for ; Thu, 11 Nov 2021 00:03:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234347AbhKKAGT (ORCPT ); Wed, 10 Nov 2021 19:06:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234321AbhKKAGR (ORCPT ); Wed, 10 Nov 2021 19:06:17 -0500 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E7CDC061766 for ; Wed, 10 Nov 2021 16:03:29 -0800 (PST) Received: by mail-pg1-x54a.google.com with SMTP id h35-20020a63f923000000b002d5262fdfc4so2342361pgi.2 for ; Wed, 10 Nov 2021 16:03:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=lq+Ydb05ASTFOfpIegkfapvb1bR6QTHCEmkE3rw574Q=; b=KGIe8YCYy1RvGRhVtiuQgWOCZA4MTGxgCAfNEuwQHkxa2UG9RG3nV1KUFkREUHGZf7 lBtVkJWKlJwFj6Rz5UOwB3zNPt1tbphHV6jLZSyDGWfUP6BDjSZqln7Dnm+KkATfpkWv vXatnx0cbKRsWkmtDB6K1pdWWWWYzSVDBU54ZuCPSZXlF9sYprzcEpXSmiFkXbLl6UJM 0w2IgZdd2LevLAdN/N1QWiYGmwEkGJyq64XPmgRRVIO6QvZzl4uJ8pwL0gqaiIyhaNkV Z+IO6TDon5/vb+enHoX5qp+m0TwMiRU4YrV9LwiNtUYuLFFfdwlr/04iBu1xG75TZk1E K0+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=lq+Ydb05ASTFOfpIegkfapvb1bR6QTHCEmkE3rw574Q=; b=A4Nod6vuvh+m7up1r0V9KpyW8KONsRxz51sJ9VGH5wAxvi+ijPZ06Itz9VstuVqxZI Ck20LpDb2z0pk8lc7t9PdAr1aTMlOhI8/cf6lmnupUAju7IXT88So9u47fhSH59qrsx4 ueLm0g3UWEVQ2gRCh8O8Pmm78iHOH1NjW9N3VNSqS7+26AH1gaWlMkMB/sB8aJ81hclP iHPmN6TTX9azZ+cZMzZim5rBadIv0Q4r1wQa+5yHqCVsTziifeX9V9dxIbr/ml0CEhGp 0MBudOl4WNiezd7ciqr74gFIeHxg+Pjaf4S0oeN8KvC2o+GXhhxhJgOB4SZ5rGRur7OA L8vA== X-Gm-Message-State: AOAM5335jAqoEZcZ5Di+6xnFjA9hG0mt99LkZk8wVnvHdM0FiV1HYTPX HzyoFKYN4TmikGv34WVHWx9djwfpsSFAVw== X-Google-Smtp-Source: ABdhPJwuCOVEViwhvkIcBY9LKBt6z6Hutnz9K4/e6AYko7uQZDJixzhFLByvnza6IJ4OURip1Tq6lIKeDnSExw== X-Received: from dmatlack-heavy.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:19cd]) (user=dmatlack job=sendgmr) by 2002:a17:90a:db81:: with SMTP id h1mr22160549pjv.46.1636589009128; Wed, 10 Nov 2021 16:03:29 -0800 (PST) Date: Thu, 11 Nov 2021 00:03:06 +0000 In-Reply-To: <20211111000310.1435032-1-dmatlack@google.com> Message-Id: <20211111000310.1435032-9-dmatlack@google.com> Mime-Version: 1.0 References: <20211111000310.1435032-1-dmatlack@google.com> X-Mailer: git-send-email 2.34.0.rc1.387.gb447b232ab-goog Subject: [PATCH v2 08/12] KVM: selftests: Move per-VM GPA into perf_test_args From: David Matlack To: Paolo Bonzini Cc: kvm@vger.kernel.org, Sean Christopherson , Ben Gardon , Andrew Jones , Jim Mattson , Yanan Wang , Peter Xu , Aaron Lewis , David Matlack Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Sean Christopherson Move the per-VM GPA into perf_test_args instead of storing it as a separate global variable. It's not obvious that guest_test_phys_mem holds a GPA, nor that it's connected/coupled with per_vcpu->gpa. No functional change intended. Signed-off-by: Sean Christopherson Reviewed-by: Ben Gardon Signed-off-by: David Matlack --- .../selftests/kvm/include/perf_test_util.h | 8 +------ .../selftests/kvm/lib/perf_test_util.c | 21 +++++++------------ .../kvm/memslot_modification_stress_test.c | 2 +- 3 files changed, 10 insertions(+), 21 deletions(-) diff --git a/tools/testing/selftests/kvm/include/perf_test_util.h b/tools/testing/selftests/kvm/include/perf_test_util.h index 20aec72fe7b8..d7cde1ab2a85 100644 --- a/tools/testing/selftests/kvm/include/perf_test_util.h +++ b/tools/testing/selftests/kvm/include/perf_test_util.h @@ -29,6 +29,7 @@ struct perf_test_vcpu_args { struct perf_test_args { struct kvm_vm *vm; uint64_t host_page_size; + uint64_t gpa; uint64_t guest_page_size; int wr_fract; @@ -37,13 +38,6 @@ struct perf_test_args { extern struct perf_test_args perf_test_args; -/* - * Guest physical memory offset of the testing memory slot. - * This will be set to the topmost valid physical address minus - * the test memory size. - */ -extern uint64_t guest_test_phys_mem; - struct kvm_vm *perf_test_create_vm(enum vm_guest_mode mode, int vcpus, uint64_t vcpu_memory_bytes, int slots, enum vm_mem_backing_src_type backing_src); diff --git a/tools/testing/selftests/kvm/lib/perf_test_util.c b/tools/testing/selftests/kvm/lib/perf_test_util.c index d9c6bcb7964d..0fc2d834c1c7 100644 --- a/tools/testing/selftests/kvm/lib/perf_test_util.c +++ b/tools/testing/selftests/kvm/lib/perf_test_util.c @@ -10,8 +10,6 @@ struct perf_test_args perf_test_args; -uint64_t guest_test_phys_mem; - /* * Guest virtual memory offset of the testing memory slot. * Must not conflict with identity mapped test code. @@ -97,20 +95,18 @@ struct kvm_vm *perf_test_create_vm(enum vm_guest_mode mode, int vcpus, guest_num_pages, vm_get_max_gfn(vm), vcpus, vcpu_memory_bytes); - guest_test_phys_mem = (vm_get_max_gfn(vm) - guest_num_pages) * - pta->guest_page_size; - guest_test_phys_mem = align_down(guest_test_phys_mem, backing_src_pagesz); + pta->gpa = (vm_get_max_gfn(vm) - guest_num_pages) * pta->guest_page_size; + pta->gpa = align_down(pta->gpa, backing_src_pagesz); #ifdef __s390x__ /* Align to 1M (segment size) */ - guest_test_phys_mem = align_down(guest_test_phys_mem, 1 << 20); + pta->gpa = align_down(pta->gpa, 1 << 20); #endif - pr_info("guest physical test memory offset: 0x%lx\n", guest_test_phys_mem); + pr_info("guest physical test memory offset: 0x%lx\n", pta->gpa); /* Add extra memory slots for testing */ for (i = 0; i < slots; i++) { uint64_t region_pages = guest_num_pages / slots; - vm_paddr_t region_start = guest_test_phys_mem + - region_pages * pta->guest_page_size * i; + vm_paddr_t region_start = pta->gpa + region_pages * pta->guest_page_size * i; vm_userspace_mem_region_add(vm, backing_src, region_start, PERF_TEST_MEM_SLOT_INDEX + i, @@ -118,7 +114,7 @@ struct kvm_vm *perf_test_create_vm(enum vm_guest_mode mode, int vcpus, } /* Do mapping for the demand paging memory slot */ - virt_map(vm, guest_test_virt_mem, guest_test_phys_mem, guest_num_pages); + virt_map(vm, guest_test_virt_mem, pta->gpa, guest_num_pages); ucall_init(vm, NULL); @@ -148,13 +144,12 @@ void perf_test_setup_vcpus(struct kvm_vm *vm, int vcpus, (vcpu_id * vcpu_memory_bytes); vcpu_args->pages = vcpu_memory_bytes / pta->guest_page_size; - vcpu_args->gpa = guest_test_phys_mem + - (vcpu_id * vcpu_memory_bytes); + vcpu_args->gpa = pta->gpa + (vcpu_id * vcpu_memory_bytes); } else { vcpu_args->gva = guest_test_virt_mem; vcpu_args->pages = (vcpus * vcpu_memory_bytes) / pta->guest_page_size; - vcpu_args->gpa = guest_test_phys_mem; + vcpu_args->gpa = pta->gpa; } vcpu_args_set(vm, vcpu_id, 1, vcpu_id); diff --git a/tools/testing/selftests/kvm/memslot_modification_stress_test.c b/tools/testing/selftests/kvm/memslot_modification_stress_test.c index 4cfcafea9f5a..d105180d5e8c 100644 --- a/tools/testing/selftests/kvm/memslot_modification_stress_test.c +++ b/tools/testing/selftests/kvm/memslot_modification_stress_test.c @@ -80,7 +80,7 @@ static void add_remove_memslot(struct kvm_vm *vm, useconds_t delay, * Add the dummy memslot just below the perf_test_util memslot, which is * at the top of the guest physical address space. */ - gpa = guest_test_phys_mem - pages * vm_get_page_size(vm); + gpa = perf_test_args.gpa - pages * vm_get_page_size(vm); for (i = 0; i < nr_modifications; i++) { usleep(delay); From patchwork Thu Nov 11 00:03:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Matlack X-Patchwork-Id: 12613649 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5082CC433EF for ; Thu, 11 Nov 2021 00:03:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3921F61284 for ; Thu, 11 Nov 2021 00:03:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234332AbhKKAGU (ORCPT ); Wed, 10 Nov 2021 19:06:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234336AbhKKAGT (ORCPT ); Wed, 10 Nov 2021 19:06:19 -0500 Received: from mail-pg1-x549.google.com (mail-pg1-x549.google.com [IPv6:2607:f8b0:4864:20::549]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29377C061766 for ; Wed, 10 Nov 2021 16:03:31 -0800 (PST) Received: by mail-pg1-x549.google.com with SMTP id u6-20020a63f646000000b002dbccd46e61so2291596pgj.18 for ; Wed, 10 Nov 2021 16:03:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=XiTkYX7gs0cLKe9ierAcN63ncrzHniZEt0Nt4vaBoqs=; b=JBJkO23NlOtRou8jWV8NlOEgxzCIshAAQZq5bce81gfGX4Hpv540AszFP9S5VakCwy gDPDp018GQ8uwFuwmY2xmZ4sL6vuwkY4KxM2HuB73CnybL22gGJ8GBCEvJ7XywhnhT/1 ZqcUW+DmxC/LN1RvQXpHMFU73qUAjvHRpkDuCkmSg50A8o3r6anfoliN/xFw7ut2TRQ6 O+YrykxF3YW4sncE6DYm4ufmec6+2YzyfJpqD8uhL1C4PsR/7bPcYj4QyiuU7vYINHYu hAo+hyFRXoKhWjucow9qk2TPQ4Wes7pfiixn/zl1yBt5X+KDrnRmY9kSQJSMCwJWj0Be EviQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=XiTkYX7gs0cLKe9ierAcN63ncrzHniZEt0Nt4vaBoqs=; b=sfvAT6CFUQtUojcA0oTFF2Cf6naFYasrkJtkjbyxt6hUbFuwn9QATjAkBK+eoJ4QwP Nv9T5UZIv8XoenVqAi3Q/dvmC/Fes5S9FRw/uY8Ehd4lO0N/sTh/ehiKbX7zZau2hGZq 5XWKKql9LieUZHmgVO7ajxiLV2MnTG6dZ2iP3yLR+auwQNmVWWIL9nVy/SZDDl6BR4Xm X7SfGTBHDnjfVoIXLw2qElp6rRgdKYt28x/vDpyStaOLG7E16jX+mur0ik6a2Dc6S9ok CZrqhad+G8ldCv/+oVnDhUIyQR96OOfdzHsVf0wLorKQcQdsQgZHTE2JbyFt4c+bh1iH Z3Lg== X-Gm-Message-State: AOAM531u7X49+6jY12dziiqmu0EK2Yb2QTzK275GWkD3/BbTVAxA3pc+ KLbFx0OL71Q1kMi90+DYnGgtVBkD3NZw7A== X-Google-Smtp-Source: ABdhPJyMr0H+YuRUYMr4wmg60T2bvcMvrDXEp9td7Ksv7NbJyW8gwgowgEf6TyKo5Qgjk7XvbCop0wsBmgVp5A== X-Received: from dmatlack-heavy.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:19cd]) (user=dmatlack job=sendgmr) by 2002:a63:2a93:: with SMTP id q141mr1793040pgq.45.1636589010693; Wed, 10 Nov 2021 16:03:30 -0800 (PST) Date: Thu, 11 Nov 2021 00:03:07 +0000 In-Reply-To: <20211111000310.1435032-1-dmatlack@google.com> Message-Id: <20211111000310.1435032-10-dmatlack@google.com> Mime-Version: 1.0 References: <20211111000310.1435032-1-dmatlack@google.com> X-Mailer: git-send-email 2.34.0.rc1.387.gb447b232ab-goog Subject: [PATCH v2 09/12] KVM: selftests: Remove perf_test_args.host_page_size From: David Matlack To: Paolo Bonzini Cc: kvm@vger.kernel.org, Sean Christopherson , Ben Gardon , Andrew Jones , Jim Mattson , Yanan Wang , Peter Xu , Aaron Lewis , David Matlack Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Sean Christopherson Remove perf_test_args.host_page_size and instead use getpagesize() so that it's somewhat obvious that, for tests that care about the host page size, they care about the system page size, not the hardware page size, e.g. that the logic is unchanged if hugepages are in play. No functional change intended. Signed-off-by: Sean Christopherson Reviewed-by: Ben Gardon Signed-off-by: David Matlack --- tools/testing/selftests/kvm/include/perf_test_util.h | 1 - tools/testing/selftests/kvm/lib/perf_test_util.c | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/testing/selftests/kvm/include/perf_test_util.h b/tools/testing/selftests/kvm/include/perf_test_util.h index d7cde1ab2a85..9348580dc5be 100644 --- a/tools/testing/selftests/kvm/include/perf_test_util.h +++ b/tools/testing/selftests/kvm/include/perf_test_util.h @@ -28,7 +28,6 @@ struct perf_test_vcpu_args { struct perf_test_args { struct kvm_vm *vm; - uint64_t host_page_size; uint64_t gpa; uint64_t guest_page_size; int wr_fract; diff --git a/tools/testing/selftests/kvm/lib/perf_test_util.c b/tools/testing/selftests/kvm/lib/perf_test_util.c index 0fc2d834c1c7..a0aded8cfce3 100644 --- a/tools/testing/selftests/kvm/lib/perf_test_util.c +++ b/tools/testing/selftests/kvm/lib/perf_test_util.c @@ -60,7 +60,6 @@ struct kvm_vm *perf_test_create_vm(enum vm_guest_mode mode, int vcpus, pr_info("Testing guest mode: %s\n", vm_guest_mode_string(mode)); - pta->host_page_size = getpagesize(); /* * Snapshot the non-huge page size. This is used by the guest code to * access/dirty pages at the logging granularity. @@ -70,7 +69,7 @@ struct kvm_vm *perf_test_create_vm(enum vm_guest_mode mode, int vcpus, guest_num_pages = vm_adjust_num_guest_pages(mode, (vcpus * vcpu_memory_bytes) / pta->guest_page_size); - TEST_ASSERT(vcpu_memory_bytes % pta->host_page_size == 0, + TEST_ASSERT(vcpu_memory_bytes % getpagesize() == 0, "Guest memory size is not host page size aligned."); TEST_ASSERT(vcpu_memory_bytes % pta->guest_page_size == 0, "Guest memory size is not guest page size aligned."); From patchwork Thu Nov 11 00:03:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Matlack X-Patchwork-Id: 12613651 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4BC73C433EF for ; Thu, 11 Nov 2021 00:03:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3573561105 for ; Thu, 11 Nov 2021 00:03:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234346AbhKKAGX (ORCPT ); Wed, 10 Nov 2021 19:06:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234350AbhKKAGU (ORCPT ); Wed, 10 Nov 2021 19:06:20 -0500 Received: from mail-pl1-x64a.google.com (mail-pl1-x64a.google.com [IPv6:2607:f8b0:4864:20::64a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1F3AC061766 for ; Wed, 10 Nov 2021 16:03:32 -0800 (PST) Received: by mail-pl1-x64a.google.com with SMTP id u22-20020a170902a61600b00141ab5dd25dso2131203plq.5 for ; Wed, 10 Nov 2021 16:03:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=lMvpWUPWJPTO9CE1xh06Zz7pIPVSd/jSPrFlRpXLV78=; b=P6Szp+uGt8cjVKSc1jKri6+P9Ocp+G6101tjHladzRC8SeATPnb3LBwo4NgxNLq5U0 xyJXKn0IvnjJk3jJyJOdHFwr4gj6GRTMUuB02DGkhYGThOgGjDkxip5z8wLrEySSUL4u sGkhSSkIwLkuMkxqE8DGikkZaBgU9P3fEnmCXm/ILzwXKVQnd4Z8RIpuhoXiaPPIua5b ckkOpJ/Ilq0xx15kSxSsuu7Aj3Q5joufCFK6erKdEcDRVvNbf9WPc1eZ6lonkX5IDaWD Njye0+NDbPiyCfRhGejBvH0tJ/Gmeyya/P6nhk+8ZCVyTYI9MSMhz3WHlwgvAADsh4i8 ovKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=lMvpWUPWJPTO9CE1xh06Zz7pIPVSd/jSPrFlRpXLV78=; b=1aPSfmva8nWUfye8dXLFEIVj12ejtcn/+QDYJcB9yAlt3CJD8yPlctis7uPThaXinO HQSW3rNJ2rcSNReb97HhMbMmIMoxlmBH6IuFnAQn5KnEXzhU10u0Pc5tuovliDJPZAys SHwb3QK9ObDlYig5Ld1PPDYIR5xy2WTt3+PHUl7N/K8RuUQFWFFpRWF2TAP/hMX9TR30 +jb3GOcqv0GEp2XlYJHgeu6qLcbifdo8HC9RWx4oRAZpawEVoy5VGid0chLaCHP/D8aY 0OvKZfLmBbLfpAG8gy/XRX2PIpLTtvJIiAHq0Pu0j6PuGcjv0NVwrBtxZS6HGWPIBaso dgkQ== X-Gm-Message-State: AOAM530cFkNz9wGpP8/1Uo2pifS6lxQui7Yk+cjHdmJ+vhCO5it/NZ2e oJVP3j6wFuNCDA4VUrkZo4lyW5bQ1te80g== X-Google-Smtp-Source: ABdhPJw/AskE7qHLjkCoROJAnZzjRNrnq3OgfLJLgU7Tq67mKw6KK803jFjceOmbVedTpDBHo88TGwPf0/oanA== X-Received: from dmatlack-heavy.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:19cd]) (user=dmatlack job=sendgmr) by 2002:a05:6a00:21c6:b0:44c:937:fbf3 with SMTP id t6-20020a056a0021c600b0044c0937fbf3mr2949121pfj.2.1636589012300; Wed, 10 Nov 2021 16:03:32 -0800 (PST) Date: Thu, 11 Nov 2021 00:03:08 +0000 In-Reply-To: <20211111000310.1435032-1-dmatlack@google.com> Message-Id: <20211111000310.1435032-11-dmatlack@google.com> Mime-Version: 1.0 References: <20211111000310.1435032-1-dmatlack@google.com> X-Mailer: git-send-email 2.34.0.rc1.387.gb447b232ab-goog Subject: [PATCH v2 10/12] KVM: selftests: Create VM with adjusted number of guest pages for perf tests From: David Matlack To: Paolo Bonzini Cc: kvm@vger.kernel.org, Sean Christopherson , Ben Gardon , Andrew Jones , Jim Mattson , Yanan Wang , Peter Xu , Aaron Lewis , David Matlack Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Sean Christopherson Use the already computed guest_num_pages when creating the so called extra VM pages for a perf test, and add a comment explaining why the pages are allocated as extra pages. Signed-off-by: Sean Christopherson Reviewed-by: Ben Gardon Signed-off-by: David Matlack --- tools/testing/selftests/kvm/lib/perf_test_util.c | 8 ++++++-- 1 file changed, 6 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 a0aded8cfce3..b3154b5b0cfd 100644 --- a/tools/testing/selftests/kvm/lib/perf_test_util.c +++ b/tools/testing/selftests/kvm/lib/perf_test_util.c @@ -77,9 +77,13 @@ struct kvm_vm *perf_test_create_vm(enum vm_guest_mode mode, int vcpus, "Guest memory cannot be evenly divided into %d slots.", slots); + /* + * Pass guest_num_pages to populate the page tables for test memory. + * 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, vcpus, DEFAULT_GUEST_PHY_PAGES, - (vcpus * vcpu_memory_bytes) / pta->guest_page_size, - 0, guest_code, NULL); + guest_num_pages, 0, guest_code, NULL); pta->vm = vm; From patchwork Thu Nov 11 00:03:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Matlack X-Patchwork-Id: 12613653 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 89F02C433EF for ; Thu, 11 Nov 2021 00:03:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6D58361241 for ; Thu, 11 Nov 2021 00:03:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234357AbhKKAGZ (ORCPT ); Wed, 10 Nov 2021 19:06:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234334AbhKKAGW (ORCPT ); Wed, 10 Nov 2021 19:06:22 -0500 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 65C98C061208 for ; Wed, 10 Nov 2021 16:03:34 -0800 (PST) Received: by mail-pj1-x1049.google.com with SMTP id y18-20020a17090abd1200b001a4dcd1501cso1913247pjr.4 for ; Wed, 10 Nov 2021 16:03:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=oPOrXyFFJcoT+Z6YSOHN3QIBuNHlfGqSkus829P7wUs=; b=HmmNcD0/Ux+zJgM2j5LP7dO7EmXmk6eYphyXlBE3G+c1zU99DAeR+sAQb8oUnax8L+ 7xnSZ83lllU2uP8ZvkIovMs0TCAf89cO55ehEoTx8wG5oYlFKz6FBamG31Hs9FCv6P4Y op7xVq5I+Wln12exuyiReNUudTogX9x0wvWMMHXJOveMSk8kPvN9BIM8fqxraRaeHJj7 A5GMOZl5G0CQBINsWsVYjquErPdWCSvBsrUDDV5KDelstCqK+AwgcYnA8Wx7LXrEVW8P sSpwgzsjv0m7Zw4Ffs2rSJR3NvXpDOJ3GDESlgztTBibJDyFfCiAZh6yyxWgO5/idDrc w+bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=oPOrXyFFJcoT+Z6YSOHN3QIBuNHlfGqSkus829P7wUs=; b=iHSjBETS7yr/qFOuHCiJsqoJEANUN3+C0FoCzeHHGZ48hmlZfGu7hN7DpiAncnBa5u jN66yhsEwDkAZAL/Ex91rVdkzBK/6I1ZO0o30sJQE79m6DkwQVxbfgQUMHKABjo+pxOF +ev7MOAAKcasxU1QWkfoDnqCxZ/l3/OVL3l6tiEVJEBAmgPRxeeouxLPvKyKLWHCkeFf JmAzbpVoRE3fDusKK7F9NZcRUwqZzvon9I2R4fyyZPbEZzVnYH5uFbPnCCqQNsR4vFxz n2aaU1v1Wf1IfNHcoUUWwxtG2B5j+XZJi7J47y/2WHyxv5b2I5UbPJBbh8VHmh345xyk KpEw== X-Gm-Message-State: AOAM533eAHsNKHt9cxy1BSN9LAC5zpLWnSlolCwecpOny38VfV9ssvAN qzvLJcOwxKYQqJgUIRJMJr7UiwnarEqPGQ== X-Google-Smtp-Source: ABdhPJxBV31vclE73Z220pV0LyLT21CYMtHJcdMU4+LvkT5ouC22LkcXdK4DanPShvVJiNLnBdY72aTZj49AsA== X-Received: from dmatlack-heavy.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:19cd]) (user=dmatlack job=sendgmr) by 2002:a05:6a00:807:b0:49f:d6ab:590c with SMTP id m7-20020a056a00080700b0049fd6ab590cmr2979208pfk.32.1636589013916; Wed, 10 Nov 2021 16:03:33 -0800 (PST) Date: Thu, 11 Nov 2021 00:03:09 +0000 In-Reply-To: <20211111000310.1435032-1-dmatlack@google.com> Message-Id: <20211111000310.1435032-12-dmatlack@google.com> Mime-Version: 1.0 References: <20211111000310.1435032-1-dmatlack@google.com> X-Mailer: git-send-email 2.34.0.rc1.387.gb447b232ab-goog Subject: [PATCH v2 11/12] KVM: selftests: Fill per-vCPU struct during "perf_test" VM creation From: David Matlack To: Paolo Bonzini Cc: kvm@vger.kernel.org, Sean Christopherson , Ben Gardon , Andrew Jones , Jim Mattson , Yanan Wang , Peter Xu , Aaron Lewis , David Matlack Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Sean Christopherson Fill the per-vCPU args when creating the perf_test VM instead of having the caller do so. This helps ensure that any adjustments to the number of pages (and thus vcpu_memory_bytes) are reflected in the per-VM args. Automatically filling the per-vCPU args will also allow a future patch to do the sync to the guest during creation. Signed-off-by: Sean Christopherson [Updated access_tracking_perf_test as well.] Signed-off-by: David Matlack Reviewed-by: Ben Gardon --- .../selftests/kvm/access_tracking_perf_test.c | 5 +- .../selftests/kvm/demand_paging_test.c | 5 +- .../selftests/kvm/dirty_log_perf_test.c | 6 +- .../selftests/kvm/include/perf_test_util.h | 6 +- .../selftests/kvm/lib/perf_test_util.c | 71 ++++++++++--------- .../kvm/memslot_modification_stress_test.c | 6 +- 6 files changed, 45 insertions(+), 54 deletions(-) diff --git a/tools/testing/selftests/kvm/access_tracking_perf_test.c b/tools/testing/selftests/kvm/access_tracking_perf_test.c index 5d95113c7b7c..fdef6c906388 100644 --- a/tools/testing/selftests/kvm/access_tracking_perf_test.c +++ b/tools/testing/selftests/kvm/access_tracking_perf_test.c @@ -332,10 +332,7 @@ static void run_test(enum vm_guest_mode mode, void *arg) int vcpus = params->vcpus; vm = perf_test_create_vm(mode, vcpus, params->vcpu_memory_bytes, 1, - params->backing_src); - - perf_test_setup_vcpus(vm, vcpus, params->vcpu_memory_bytes, - !overlap_memory_access); + params->backing_src, !overlap_memory_access); vcpu_threads = create_vcpu_threads(vcpus); diff --git a/tools/testing/selftests/kvm/demand_paging_test.c b/tools/testing/selftests/kvm/demand_paging_test.c index 3c729a0a1ab1..0fee44f5e5ae 100644 --- a/tools/testing/selftests/kvm/demand_paging_test.c +++ b/tools/testing/selftests/kvm/demand_paging_test.c @@ -293,7 +293,7 @@ static void run_test(enum vm_guest_mode mode, void *arg) int r; vm = perf_test_create_vm(mode, nr_vcpus, guest_percpu_mem_size, 1, - p->src_type); + p->src_type, p->partition_vcpu_memory_access); perf_test_args.wr_fract = 1; @@ -307,9 +307,6 @@ static void run_test(enum vm_guest_mode mode, void *arg) vcpu_threads = malloc(nr_vcpus * sizeof(*vcpu_threads)); TEST_ASSERT(vcpu_threads, "Memory allocation failed"); - perf_test_setup_vcpus(vm, nr_vcpus, guest_percpu_mem_size, - p->partition_vcpu_memory_access); - if (p->uffd_mode) { uffd_handler_threads = malloc(nr_vcpus * sizeof(*uffd_handler_threads)); diff --git a/tools/testing/selftests/kvm/dirty_log_perf_test.c b/tools/testing/selftests/kvm/dirty_log_perf_test.c index 7ffab5bd5ce5..62f9cc2a3146 100644 --- a/tools/testing/selftests/kvm/dirty_log_perf_test.c +++ b/tools/testing/selftests/kvm/dirty_log_perf_test.c @@ -186,7 +186,8 @@ static void run_test(enum vm_guest_mode mode, void *arg) struct timespec clear_dirty_log_total = (struct timespec){0}; vm = perf_test_create_vm(mode, nr_vcpus, guest_percpu_mem_size, - p->slots, p->backing_src); + p->slots, p->backing_src, + p->partition_vcpu_memory_access); perf_test_args.wr_fract = p->wr_fract; @@ -206,9 +207,6 @@ static void run_test(enum vm_guest_mode mode, void *arg) vcpu_threads = malloc(nr_vcpus * sizeof(*vcpu_threads)); TEST_ASSERT(vcpu_threads, "Memory allocation failed"); - perf_test_setup_vcpus(vm, nr_vcpus, guest_percpu_mem_size, - p->partition_vcpu_memory_access); - sync_global_to_guest(vm, perf_test_args); /* Start the iterations */ diff --git a/tools/testing/selftests/kvm/include/perf_test_util.h b/tools/testing/selftests/kvm/include/perf_test_util.h index 9348580dc5be..91804be1cf53 100644 --- a/tools/testing/selftests/kvm/include/perf_test_util.h +++ b/tools/testing/selftests/kvm/include/perf_test_util.h @@ -39,10 +39,8 @@ extern struct perf_test_args perf_test_args; struct kvm_vm *perf_test_create_vm(enum vm_guest_mode mode, int vcpus, uint64_t vcpu_memory_bytes, int slots, - enum vm_mem_backing_src_type backing_src); + enum vm_mem_backing_src_type backing_src, + bool partition_vcpu_memory_access); void perf_test_destroy_vm(struct kvm_vm *vm); -void perf_test_setup_vcpus(struct kvm_vm *vm, int vcpus, - uint64_t vcpu_memory_bytes, - bool partition_vcpu_memory_access); #endif /* SELFTEST_KVM_PERF_TEST_UTIL_H */ diff --git a/tools/testing/selftests/kvm/lib/perf_test_util.c b/tools/testing/selftests/kvm/lib/perf_test_util.c index b3154b5b0cfd..13c8bc22f4e1 100644 --- a/tools/testing/selftests/kvm/lib/perf_test_util.c +++ b/tools/testing/selftests/kvm/lib/perf_test_util.c @@ -48,9 +48,43 @@ static void guest_code(uint32_t vcpu_id) } } +void perf_test_setup_vcpus(struct kvm_vm *vm, int vcpus, + uint64_t vcpu_memory_bytes, + bool partition_vcpu_memory_access) +{ + struct perf_test_args *pta = &perf_test_args; + struct perf_test_vcpu_args *vcpu_args; + int vcpu_id; + + for (vcpu_id = 0; vcpu_id < vcpus; vcpu_id++) { + vcpu_args = &pta->vcpu_args[vcpu_id]; + + vcpu_args->vcpu_id = vcpu_id; + if (partition_vcpu_memory_access) { + vcpu_args->gva = guest_test_virt_mem + + (vcpu_id * vcpu_memory_bytes); + vcpu_args->pages = vcpu_memory_bytes / + pta->guest_page_size; + vcpu_args->gpa = pta->gpa + (vcpu_id * vcpu_memory_bytes); + } else { + vcpu_args->gva = guest_test_virt_mem; + vcpu_args->pages = (vcpus * vcpu_memory_bytes) / + pta->guest_page_size; + vcpu_args->gpa = pta->gpa; + } + + vcpu_args_set(vm, vcpu_id, 1, vcpu_id); + + pr_debug("Added VCPU %d with test mem gpa [%lx, %lx)\n", + vcpu_id, vcpu_args->gpa, vcpu_args->gpa + + (vcpu_args->pages * pta->guest_page_size)); + } +} + struct kvm_vm *perf_test_create_vm(enum vm_guest_mode mode, int vcpus, uint64_t vcpu_memory_bytes, int slots, - enum vm_mem_backing_src_type backing_src) + enum vm_mem_backing_src_type backing_src, + bool partition_vcpu_memory_access) { struct perf_test_args *pta = &perf_test_args; struct kvm_vm *vm; @@ -119,6 +153,8 @@ struct kvm_vm *perf_test_create_vm(enum vm_guest_mode mode, int vcpus, /* Do mapping for the demand paging memory slot */ virt_map(vm, guest_test_virt_mem, pta->gpa, guest_num_pages); + perf_test_setup_vcpus(vm, vcpus, vcpu_memory_bytes, partition_vcpu_memory_access); + ucall_init(vm, NULL); return vm; @@ -129,36 +165,3 @@ void perf_test_destroy_vm(struct kvm_vm *vm) ucall_uninit(vm); kvm_vm_free(vm); } - -void perf_test_setup_vcpus(struct kvm_vm *vm, int vcpus, - uint64_t vcpu_memory_bytes, - bool partition_vcpu_memory_access) -{ - struct perf_test_args *pta = &perf_test_args; - struct perf_test_vcpu_args *vcpu_args; - int vcpu_id; - - for (vcpu_id = 0; vcpu_id < vcpus; vcpu_id++) { - vcpu_args = &pta->vcpu_args[vcpu_id]; - - vcpu_args->vcpu_id = vcpu_id; - if (partition_vcpu_memory_access) { - vcpu_args->gva = guest_test_virt_mem + - (vcpu_id * vcpu_memory_bytes); - vcpu_args->pages = vcpu_memory_bytes / - pta->guest_page_size; - vcpu_args->gpa = pta->gpa + (vcpu_id * vcpu_memory_bytes); - } else { - vcpu_args->gva = guest_test_virt_mem; - vcpu_args->pages = (vcpus * vcpu_memory_bytes) / - pta->guest_page_size; - vcpu_args->gpa = pta->gpa; - } - - vcpu_args_set(vm, vcpu_id, 1, vcpu_id); - - pr_debug("Added VCPU %d with test mem gpa [%lx, %lx)\n", - vcpu_id, vcpu_args->gpa, vcpu_args->gpa + - (vcpu_args->pages * pta->guest_page_size)); - } -} diff --git a/tools/testing/selftests/kvm/memslot_modification_stress_test.c b/tools/testing/selftests/kvm/memslot_modification_stress_test.c index d105180d5e8c..27af0bb8deb7 100644 --- a/tools/testing/selftests/kvm/memslot_modification_stress_test.c +++ b/tools/testing/selftests/kvm/memslot_modification_stress_test.c @@ -105,16 +105,14 @@ static void run_test(enum vm_guest_mode mode, void *arg) int vcpu_id; vm = perf_test_create_vm(mode, nr_vcpus, guest_percpu_mem_size, 1, - VM_MEM_SRC_ANONYMOUS); + VM_MEM_SRC_ANONYMOUS, + p->partition_vcpu_memory_access); perf_test_args.wr_fract = 1; vcpu_threads = malloc(nr_vcpus * sizeof(*vcpu_threads)); TEST_ASSERT(vcpu_threads, "Memory allocation failed"); - perf_test_setup_vcpus(vm, nr_vcpus, guest_percpu_mem_size, - p->partition_vcpu_memory_access); - /* Export the shared variables to the guest */ sync_global_to_guest(vm, perf_test_args); From patchwork Thu Nov 11 00:03:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Matlack X-Patchwork-Id: 12613655 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9AC3BC433FE for ; Thu, 11 Nov 2021 00:03:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 78C5861241 for ; Thu, 11 Nov 2021 00:03:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234377AbhKKAG0 (ORCPT ); Wed, 10 Nov 2021 19:06:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234356AbhKKAGX (ORCPT ); Wed, 10 Nov 2021 19:06:23 -0500 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBD02C0613F5 for ; Wed, 10 Nov 2021 16:03:35 -0800 (PST) Received: by mail-pg1-x54a.google.com with SMTP id r7-20020a63ce47000000b002a5cadd2f25so2318550pgi.9 for ; Wed, 10 Nov 2021 16:03:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=rvcyrFmDmaJFNRkxwJiSiKOCz4Rgltqo0FYJ1UfGbbo=; b=IvykEiR6ya4qykcVXSlBOINsv4jNaThsg1SqIWwQVedcUn6HENT49JhNN9kCQDxRIf kNkiXRiRfPlN3eduNFKTKnvbozM6DgGOzH9VhqDVyWTwtEBkDdqOxTw1xP0T6EFYK6yb yXv6xpEYFVD2CXhvUqEOCuO/pvi74dnFydd6t9wRpUkwj+Bmg1OSIIP14RIQNvxnkyeN x0EeRx8ywUVfskketCzZFM6HRbQ/7/Lpa2tHEeerZcxhJ+4kq8q6nCWGRsYg2tvx5fmT Gmota6llXZRqlwwERIuAVrCZLKgr0DhyWMgSHjor1BN+bkfOYlO1I6Uf9v5e0mFQXlmb gazQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=rvcyrFmDmaJFNRkxwJiSiKOCz4Rgltqo0FYJ1UfGbbo=; b=3vNLtmPQHJie37daTG3lub8OI7mQICV2f6HY19Sr13yvViFhsQrfvF7UHz/nsKTnmQ FYrEf5rvUhiwz8uUK5WPy78TyoErg0bChTdhkPlNpqFogRtJlpbYn3Vlfe1XiJ3mU0OW +MjAAlFshM/56mWKTX/mq+0NuUrSZ3x/0ojS3hOHMpbxLD3fSpzGQqsvb+MnFoM9zTuY AP3f1S0SAIBRHB3JMNvFKvyTb+PC2dolwcAbNvnhTPOMCNqQtWqT4vB6rAucw2va/YT3 noGliVrg18nFVI89WIprl2r3alSIKdkADGkXVxzlTt+PVcj5aAIbWVj/6MT8reGZB0AS J/fQ== X-Gm-Message-State: AOAM533BQ2Ix0qPV84HQ7IOf3hZS3EVs1apq6P+zgRl7IZ8DYD1yTM3A lTFQCOfNbrbkBzdAaNW0DDyU5TodNwz9CA== X-Google-Smtp-Source: ABdhPJwWRDHoQchmESuSFK9TkqSTCeJOMTzIIKw5aAiH+GAF5LN8UCWO3+fRvoy5cSvZIi91vtIrcffFv50xvg== X-Received: from dmatlack-heavy.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:19cd]) (user=dmatlack job=sendgmr) by 2002:a05:6a00:a23:b0:43d:e856:a3d4 with SMTP id p35-20020a056a000a2300b0043de856a3d4mr2966152pfh.17.1636589015292; Wed, 10 Nov 2021 16:03:35 -0800 (PST) Date: Thu, 11 Nov 2021 00:03:10 +0000 In-Reply-To: <20211111000310.1435032-1-dmatlack@google.com> Message-Id: <20211111000310.1435032-13-dmatlack@google.com> Mime-Version: 1.0 References: <20211111000310.1435032-1-dmatlack@google.com> X-Mailer: git-send-email 2.34.0.rc1.387.gb447b232ab-goog Subject: [PATCH v2 12/12] KVM: selftests: Sync perf_test_args to guest during VM creation From: David Matlack To: Paolo Bonzini Cc: kvm@vger.kernel.org, Sean Christopherson , Ben Gardon , Andrew Jones , Jim Mattson , Yanan Wang , Peter Xu , Aaron Lewis , David Matlack Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Sean Christopherson Copy perf_test_args to the guest during VM creation instead of relying on the caller to do so at their leisure. Ideally, tests wouldn't even be able to modify perf_test_args, i.e. they would have no motivation to do the sync, but enforcing that is arguably a net negative for readability. No functional change intended. Signed-off-by: Sean Christopherson [Set wr_fract=1 by default and add helper to override it since the new access_tracking_perf_test needs to set it dynamically.] Signed-off-by: David Matlack Reviewed-by: Ben Gardon --- .../selftests/kvm/access_tracking_perf_test.c | 3 +-- tools/testing/selftests/kvm/demand_paging_test.c | 5 ----- tools/testing/selftests/kvm/dirty_log_perf_test.c | 4 +--- tools/testing/selftests/kvm/include/perf_test_util.h | 2 ++ tools/testing/selftests/kvm/lib/perf_test_util.c | 12 ++++++++++++ .../selftests/kvm/memslot_modification_stress_test.c | 5 ----- 6 files changed, 16 insertions(+), 15 deletions(-) diff --git a/tools/testing/selftests/kvm/access_tracking_perf_test.c b/tools/testing/selftests/kvm/access_tracking_perf_test.c index fdef6c906388..5364a2ed7c68 100644 --- a/tools/testing/selftests/kvm/access_tracking_perf_test.c +++ b/tools/testing/selftests/kvm/access_tracking_perf_test.c @@ -277,8 +277,7 @@ static void run_iteration(struct kvm_vm *vm, int vcpus, const char *description) static void access_memory(struct kvm_vm *vm, int vcpus, enum access_type access, const char *description) { - perf_test_args.wr_fract = (access == ACCESS_READ) ? INT_MAX : 1; - sync_global_to_guest(vm, perf_test_args); + perf_test_set_wr_fract(vm, (access == ACCESS_READ) ? INT_MAX : 1); iteration_work = ITERATION_ACCESS_MEMORY; run_iteration(vm, vcpus, description); } diff --git a/tools/testing/selftests/kvm/demand_paging_test.c b/tools/testing/selftests/kvm/demand_paging_test.c index 0fee44f5e5ae..26f8fd8a57ec 100644 --- a/tools/testing/selftests/kvm/demand_paging_test.c +++ b/tools/testing/selftests/kvm/demand_paging_test.c @@ -295,8 +295,6 @@ static void run_test(enum vm_guest_mode mode, void *arg) vm = perf_test_create_vm(mode, nr_vcpus, guest_percpu_mem_size, 1, p->src_type, p->partition_vcpu_memory_access); - perf_test_args.wr_fract = 1; - demand_paging_size = get_backing_src_pagesz(p->src_type); guest_data_prototype = malloc(demand_paging_size); @@ -345,9 +343,6 @@ static void run_test(enum vm_guest_mode mode, void *arg) } } - /* Export the shared variables to the guest */ - sync_global_to_guest(vm, perf_test_args); - pr_info("Finished creating vCPUs and starting uffd threads\n"); clock_gettime(CLOCK_MONOTONIC, &start); diff --git a/tools/testing/selftests/kvm/dirty_log_perf_test.c b/tools/testing/selftests/kvm/dirty_log_perf_test.c index 62f9cc2a3146..583b4d95aa98 100644 --- a/tools/testing/selftests/kvm/dirty_log_perf_test.c +++ b/tools/testing/selftests/kvm/dirty_log_perf_test.c @@ -189,7 +189,7 @@ static void run_test(enum vm_guest_mode mode, void *arg) p->slots, p->backing_src, p->partition_vcpu_memory_access); - perf_test_args.wr_fract = p->wr_fract; + perf_test_set_wr_fract(vm, p->wr_fract); guest_num_pages = (nr_vcpus * guest_percpu_mem_size) >> vm_get_page_shift(vm); guest_num_pages = vm_adjust_num_guest_pages(mode, guest_num_pages); @@ -207,8 +207,6 @@ static void run_test(enum vm_guest_mode mode, void *arg) vcpu_threads = malloc(nr_vcpus * sizeof(*vcpu_threads)); TEST_ASSERT(vcpu_threads, "Memory allocation failed"); - sync_global_to_guest(vm, perf_test_args); - /* Start the iterations */ iteration = 0; host_quit = false; diff --git a/tools/testing/selftests/kvm/include/perf_test_util.h b/tools/testing/selftests/kvm/include/perf_test_util.h index 91804be1cf53..74e3622b3a6e 100644 --- a/tools/testing/selftests/kvm/include/perf_test_util.h +++ b/tools/testing/selftests/kvm/include/perf_test_util.h @@ -43,4 +43,6 @@ struct kvm_vm *perf_test_create_vm(enum vm_guest_mode mode, int vcpus, bool partition_vcpu_memory_access); void perf_test_destroy_vm(struct kvm_vm *vm); +void perf_test_set_wr_fract(struct kvm_vm *vm, int wr_fract); + #endif /* SELFTEST_KVM_PERF_TEST_UTIL_H */ diff --git a/tools/testing/selftests/kvm/lib/perf_test_util.c b/tools/testing/selftests/kvm/lib/perf_test_util.c index 13c8bc22f4e1..77f9eb5667c9 100644 --- a/tools/testing/selftests/kvm/lib/perf_test_util.c +++ b/tools/testing/selftests/kvm/lib/perf_test_util.c @@ -94,6 +94,9 @@ struct kvm_vm *perf_test_create_vm(enum vm_guest_mode mode, int vcpus, pr_info("Testing guest mode: %s\n", vm_guest_mode_string(mode)); + /* By default vCPUs will write to memory. */ + pta->wr_fract = 1; + /* * Snapshot the non-huge page size. This is used by the guest code to * access/dirty pages at the logging granularity. @@ -157,6 +160,9 @@ struct kvm_vm *perf_test_create_vm(enum vm_guest_mode mode, int vcpus, ucall_init(vm, NULL); + /* Export the shared variables to the guest. */ + sync_global_to_guest(vm, perf_test_args); + return vm; } @@ -165,3 +171,9 @@ void perf_test_destroy_vm(struct kvm_vm *vm) ucall_uninit(vm); kvm_vm_free(vm); } + +void perf_test_set_wr_fract(struct kvm_vm *vm, int wr_fract) +{ + perf_test_args.wr_fract = wr_fract; + sync_global_to_guest(vm, perf_test_args); +} diff --git a/tools/testing/selftests/kvm/memslot_modification_stress_test.c b/tools/testing/selftests/kvm/memslot_modification_stress_test.c index 27af0bb8deb7..df431d0da1ee 100644 --- a/tools/testing/selftests/kvm/memslot_modification_stress_test.c +++ b/tools/testing/selftests/kvm/memslot_modification_stress_test.c @@ -108,14 +108,9 @@ static void run_test(enum vm_guest_mode mode, void *arg) VM_MEM_SRC_ANONYMOUS, p->partition_vcpu_memory_access); - perf_test_args.wr_fract = 1; - vcpu_threads = malloc(nr_vcpus * sizeof(*vcpu_threads)); TEST_ASSERT(vcpu_threads, "Memory allocation failed"); - /* Export the shared variables to the guest */ - sync_global_to_guest(vm, perf_test_args); - pr_info("Finished creating vCPUs\n"); for (vcpu_id = 0; vcpu_id < nr_vcpus; vcpu_id++)