From patchwork Thu Mar 16 00:30:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ackerley Tng X-Patchwork-Id: 13176857 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A04E7C7618B for ; Thu, 16 Mar 2023 00:31:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B17F66B0088; Wed, 15 Mar 2023 20:31:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AC9026B0089; Wed, 15 Mar 2023 20:31:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 91A256B008A; Wed, 15 Mar 2023 20:31:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 808FB6B0088 for ; Wed, 15 Mar 2023 20:31:28 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 5330EABA6E for ; Thu, 16 Mar 2023 00:31:28 +0000 (UTC) X-FDA: 80572882656.08.86962CF Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) by imf20.hostedemail.com (Postfix) with ESMTP id 73A031C001A for ; Thu, 16 Mar 2023 00:31:26 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=swpVj1Sm; spf=pass (imf20.hostedemail.com: domain of 3XWMSZAsKCJQy082F92MHB44CC492.0CA96BIL-AA8Jy08.CF4@flex--ackerleytng.bounces.google.com designates 209.85.214.202 as permitted sender) smtp.mailfrom=3XWMSZAsKCJQy082F92MHB44CC492.0CA96BIL-AA8Jy08.CF4@flex--ackerleytng.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1678926686; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=36lklAKITNKcvpGi9bBaV0pg92rnpur43Kuea+YFpfM=; b=r4L7V/HDWt0W8VZ39CY79tq07FG6l7CBmN3rDj3vG3r5rE0/CkyrYDOf69oCGt4VWVwyng V+TTpoUVY2FBEfmOTlxFOdsduBY9EecznPiiPKnbLgvZt29C6YJ6ggUOCpQs6uS+lZyXOS 1qtyfLhIpNWhYH4gm9s7h6/zFMXaKWA= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=swpVj1Sm; spf=pass (imf20.hostedemail.com: domain of 3XWMSZAsKCJQy082F92MHB44CC492.0CA96BIL-AA8Jy08.CF4@flex--ackerleytng.bounces.google.com designates 209.85.214.202 as permitted sender) smtp.mailfrom=3XWMSZAsKCJQy082F92MHB44CC492.0CA96BIL-AA8Jy08.CF4@flex--ackerleytng.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1678926686; a=rsa-sha256; cv=none; b=JL9C3+2I9OidoIr9Ju+LtWrv66q9FByGXfAtIiYg1oFXNWg0uiacRmd750Rx5Sne3Mv+4J UyKb99BKKjWTpG0PR51UG2CH5TDQY/05szIz4zHnervlfUCqf4OTZloSjeLQAMRIW43Mb7 /0bCsXaheC3Ne12iy3vzy19vT0apK08= Received: by mail-pl1-f202.google.com with SMTP id u11-20020a170902e80b00b001a043e84bdfso6192921plg.23 for ; Wed, 15 Mar 2023 17:31:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1678926685; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=36lklAKITNKcvpGi9bBaV0pg92rnpur43Kuea+YFpfM=; b=swpVj1SmNmgvWlTTZKcMha4lkIplKfRmILDkyWfcGRLXWLuIlK2d6RzDWw2bYkkCHP soiW4nXc7/hBbAleU8BqoI0AbG96N9laDULGWA+oYmBxb9+GZWi0B0T26gJnbwIFOCwo 5kpRG9JizdS1Y6EbQlta+wo8Fhd+ryKKJGTqSzbsLYaWB10pCI4jhMlJ9DGRJ4DSAtGk 3aahsJCHmb9Uk47t1vgWw/SYjxk2SvIyeXgaVgaNp1TPH4oC+vl3KgGYbWyD1TlOcBi1 gvD1hR4NtBHZOvW4SAlG3B1IpFX0JT8Zq0hcF2742mhE+c1PzdSmxBYs2Pwk5wn4zjuL RaVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678926685; 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=36lklAKITNKcvpGi9bBaV0pg92rnpur43Kuea+YFpfM=; b=EWpO/HeBQHyzOb8cXSKqbLUynUmglc7qopF/hIfIOYSnRGZD82zWoDyezwNy1BVuNk KEkLV4CTzJcHoNpuJIUBpf8/nYEKrbMxe274xNumeoIAv9ub/0ztTma5w+KFBtUmNHcC OVknANBdnOv8JAYNYLOXB9RZOeMef4rmhp3gHYcotKxCX64M6q4U9z84PItmt1s6kPZ2 A+ndBsBVpvNiL4+2JMx4WcFUl/t2IZhfUB5LGgNCDuvKQpx3HOk0rBqScx4xNp2dYc6s pji/E1622S8oC62Sg5aDthm6F0qodRkmKC/oeVx7OKkuHSU73c5SjpC8bGrCBF7rxi4B sAJQ== X-Gm-Message-State: AO0yUKUfpMOziZW8Em6aPIwve6ety7om50VOWMOMH03L2IjKtHqmzSX6 /NPAt5oDwLHdhjOMgMwLQ4vCWhAxqhGrXZKbwg== X-Google-Smtp-Source: AK7set9HhZ92PQ2OitTC4KZtYEJK0EXqsjjwLnoPjbnEyW7GD+pO7NNEnen5rh0nKaexCpnSy3z8RFk0Cysc1DaScg== X-Received: from ackerleytng-cloudtop.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:1f5f]) (user=ackerleytng job=sendgmr) by 2002:a17:902:d50d:b0:1a0:5402:b17f with SMTP id b13-20020a170902d50d00b001a05402b17fmr634600plg.6.1678926685342; Wed, 15 Mar 2023 17:31:25 -0700 (PDT) Date: Thu, 16 Mar 2023 00:30:59 +0000 In-Reply-To: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.40.0.rc2.332.ga46443480c-goog Message-ID: Subject: [RFC PATCH 06/10] KVM: selftests: Default private_mem_conversions_test to use 1 memslot for test data From: Ackerley Tng To: kvm@vger.kernel.org, linux-api@vger.kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, qemu-devel@nongnu.org Cc: aarcange@redhat.com, ak@linux.intel.com, akpm@linux-foundation.org, arnd@arndb.de, bfields@fieldses.org, bp@alien8.de, chao.p.peng@linux.intel.com, corbet@lwn.net, dave.hansen@intel.com, david@redhat.com, ddutile@redhat.com, dhildenb@redhat.com, hpa@zytor.com, hughd@google.com, jlayton@kernel.org, jmattson@google.com, joro@8bytes.org, jun.nakajima@intel.com, kirill.shutemov@linux.intel.com, linmiaohe@huawei.com, luto@kernel.org, mail@maciej.szmigiero.name, mhocko@suse.com, michael.roth@amd.com, mingo@redhat.com, naoya.horiguchi@nec.com, pbonzini@redhat.com, qperret@google.com, rppt@kernel.org, seanjc@google.com, shuah@kernel.org, steven.price@arm.com, tabba@google.com, tglx@linutronix.de, vannapurve@google.com, vbabka@suse.cz, vkuznets@redhat.com, wanpengli@tencent.com, wei.w.wang@intel.com, x86@kernel.org, yu.c.zhang@linux.intel.com, Ackerley Tng X-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KOo28nO0AudttlbtDCu0dR6urYWcGHtPbc/5NJv3c b+wPwtGe eQ+EGU+ZFtMWJ+l2wfZ+9X80EY2zPx/uMeo7gjfpXa6Jxc9h/FbRu2n8jNXhEqGLE5+QTOOwcI/SjhuBXo+pocuHhuXFA39dCLyUTivBd4+/MEg37UyCiJVZ8VeIVyDpS377oTBN7Ex3jKZst3CpFWKV0mJdMUcHsatFcBPMvAVzOSRerFDqRI9Fe4eq9Ghjuo+HBC97v7VYKVefVFcyeLqH/0m3bOPMIysCZEIECp5Gb1w1CLn2f4VvwR5tKI0bpoKo19pmL819p/RpSOkOvF+Q/SlzTZO8uBdDWVDuJ/sq87JsGnABMGOY+idPgC9+tH6zLd6o1Dng0liBtpYu8I4eA7or4z9jvEZlKNVhzJoYX5OGCT6ux7Y8zuzIFyKraQ5o5PCEAfS/EEC2vsYu3pBNRjPT/Px31damPuX6sy6UCyt3s6RwutYlAwwdsZiH97fRQJYmP6OSkUQP2RQV9SwOabdv+stpbVx12+HLZ94IA4az0iO3DRqSKW/PZ2k/Z1K/i2fJ7/DLp0XxrdyDWjaGlYruAoYRp2/S9OL1ZGXr1FYjmRLdgrND95bzem5dBiBDpMh6wqhhGyv2MihGEyR0Io7+EucUoBy2BsW2aRn+0kCavkfk5OeulAjSE6BraMcudXOKcrnDdQMGZ1L46Id2BU8DsW9yHtWmKbOyNNR+6mRJAMyGI49/EUTzUVb69xI8G1vkqW1+8Vyk= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Default the private/shared memory conversion tests to use a single memslot, while executing on multiple vCPUs in parallel, to stress-test the restrictedmem subsystem. Also add a flag to allow multiple memslots to be used. Signed-off-by: Ackerley Tng --- .../kvm/x86_64/private_mem_conversions_test.c | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/kvm/x86_64/private_mem_conversions_test.c b/tools/testing/selftests/kvm/x86_64/private_mem_conversions_test.c index 14aa90e9a89b..afaf8d0e52e6 100644 --- a/tools/testing/selftests/kvm/x86_64/private_mem_conversions_test.c +++ b/tools/testing/selftests/kvm/x86_64/private_mem_conversions_test.c @@ -335,7 +335,8 @@ static void add_memslot_for_vcpu( } static void test_mem_conversions(enum vm_mem_backing_src_type src_type, - uint8_t nr_vcpus, uint32_t iterations) + uint8_t nr_vcpus, uint32_t iterations, + bool use_multiple_memslots) { struct kvm_vcpu *vcpus[KVM_MAX_VCPUS]; pthread_t threads[KVM_MAX_VCPUS]; @@ -355,6 +356,16 @@ static void test_mem_conversions(enum vm_mem_backing_src_type src_type, vm_enable_cap(vm, KVM_CAP_EXIT_HYPERCALL, (1 << KVM_HC_MAP_GPA_RANGE)); npages_for_all_vcpus = DATA_SIZE / vm->page_size * nr_vcpus; + + if (use_multiple_memslots) { + for (i = 0; i < nr_vcpus; i++) + add_memslot_for_vcpu(vm, src_type, i); + } else { + vm_userspace_mem_region_add( + vm, src_type, DATA_GPA_BASE, DATA_SLOT_BASE, + npages_for_all_vcpus, KVM_MEM_PRIVATE); + } + virt_map(vm, DATA_GPA_BASE, DATA_GPA_BASE, npages_for_all_vcpus); for (i = 0; i < nr_vcpus; i++) @@ -371,13 +382,16 @@ static void test_mem_conversions(enum vm_mem_backing_src_type src_type, for (i = 0; i < nr_vcpus; i++) pthread_join(threads[i], NULL); - test_invalidation_code_unbound(vm, nr_vcpus, DATA_SIZE); + if (!use_multiple_memslots) + test_invalidation_code_unbound(vm, 1, DATA_SIZE * nr_vcpus); + else + test_invalidation_code_unbound(vm, nr_vcpus, DATA_SIZE); } static void usage(const char *command) { puts(""); - printf("usage: %s [-h] [-s mem-type] [-n number-of-vcpus] [-i number-of-iterations]\n", + printf("usage: %s [-h] [-m] [-s mem-type] [-n number-of-vcpus] [-i number-of-iterations]\n", command); puts(""); backing_src_help("-s"); @@ -388,6 +402,8 @@ static void usage(const char *command) puts(" -i: specify the number iterations of memory conversion"); puts(" tests to run. (default: 10)"); puts(""); + puts(" -m: use multiple memslots (default: use 1 memslot)"); + puts(""); } int main(int argc, char *argv[]) @@ -395,12 +411,13 @@ int main(int argc, char *argv[]) enum vm_mem_backing_src_type src_type = DEFAULT_VM_MEM_SRC; uint8_t nr_vcpus = 2; uint32_t iterations = 10; + bool use_multiple_memslots = false; int opt; TEST_REQUIRE(kvm_has_cap(KVM_CAP_EXIT_HYPERCALL)); TEST_REQUIRE(kvm_check_cap(KVM_CAP_VM_TYPES) & BIT(KVM_X86_PROTECTED_VM)); - while ((opt = getopt(argc, argv, "hs:n:i:")) != -1) { + while ((opt = getopt(argc, argv, "mhs:n:i:")) != -1) { switch (opt) { case 'n': nr_vcpus = atoi_positive("nr_vcpus", optarg); @@ -411,6 +428,9 @@ int main(int argc, char *argv[]) case 's': src_type = parse_backing_src_type(optarg); break; + case 'm': + use_multiple_memslots = true; + break; case 'h': default: usage(argv[0]); @@ -418,6 +438,6 @@ int main(int argc, char *argv[]) } } - test_mem_conversions(src_type, nr_vcpus, iterations); + test_mem_conversions(src_type, nr_vcpus, iterations, use_multiple_memslots); return 0; }