From patchwork Tue Sep 10 23:43:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ackerley Tng X-Patchwork-Id: 13799492 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 26500EE01F2 for ; Tue, 10 Sep 2024 23:45:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7EF238D00DE; Tue, 10 Sep 2024 19:45:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7A0128D00DB; Tue, 10 Sep 2024 19:45:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5CA9F8D00DE; Tue, 10 Sep 2024 19:45:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 3891F8D00DB for ; Tue, 10 Sep 2024 19:45:08 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id E4B1E1C4D26 for ; Tue, 10 Sep 2024 23:45:07 +0000 (UTC) X-FDA: 82550461854.23.7B5ED89 Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) by imf27.hostedemail.com (Postfix) with ESMTP id 0D0FC4000A for ; Tue, 10 Sep 2024 23:45:05 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=azY92Ktd; spf=pass (imf27.hostedemail.com: domain of 3ANrgZgsKCHUTVdXkeXrmgZZhhZeX.Vhfebgnq-ffdoTVd.hkZ@flex--ackerleytng.bounces.google.com designates 209.85.215.202 as permitted sender) smtp.mailfrom=3ANrgZgsKCHUTVdXkeXrmgZZhhZeX.Vhfebgnq-ffdoTVd.hkZ@flex--ackerleytng.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1726011853; a=rsa-sha256; cv=none; b=FO4fCzFNzsx1ZLRBKfYcXrm8JOiejYlZ9wj6fH4C3yGt8czLaXqfV3M3c92I9a5Wy2YB61 IAqsCtc+hE0g7pzClezZNkHHg2W9C9D5t3AsR983zldyubctyWsG0p3oNXH6eNaLpqTZIZ t0RkTmNWAJiunAvm2wNDpIgCiBDuqw0= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=azY92Ktd; spf=pass (imf27.hostedemail.com: domain of 3ANrgZgsKCHUTVdXkeXrmgZZhhZeX.Vhfebgnq-ffdoTVd.hkZ@flex--ackerleytng.bounces.google.com designates 209.85.215.202 as permitted sender) smtp.mailfrom=3ANrgZgsKCHUTVdXkeXrmgZZhhZeX.Vhfebgnq-ffdoTVd.hkZ@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=1726011853; 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=JNe/WmHLeg6VKg7h5W2f+s+eqgKPFc2fIX3V6u3knDI=; b=MBkB52wz+4k4kQWT6fdLcELrJ+2GBTk/jCKxIKElypXe7Bp1j93Q+vj6eH7gZpX/LdWrZx 0X/fcxhjIj9a0UNOFu/JutbprBotzlTeNTUEudjJsrRVj3hlxHJy+/Wm/ZmezAemASxkp2 t6XvaY4gkNxtLbKAEh0szeuY0cpgmGg= Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-7db0c10238eso151565a12.1 for ; Tue, 10 Sep 2024 16:45:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726011905; x=1726616705; darn=kvack.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=JNe/WmHLeg6VKg7h5W2f+s+eqgKPFc2fIX3V6u3knDI=; b=azY92KtdI42cdyODdwOOcFPeaQCZzvVWkyEZ+sYdjt44bwRZpRJNHrneFT+DNosHTc ITE1t9plBeP/fJzbbWogvpGO/ah/7ZRD/hAw3+cA+Zu9fF2dmcZb+7PMvx3LuHai6iZF G9y+C6w3EgzbDkINc9nA5zbFZGm3TDh57f/pbQ5ufGTpX2ZGI1VW+zmmebEWM20tVmty bvjWS0Z2XDCcvqiGaepv5U3kPgc+tfM61iSoEdqN61zdiSfeZ5QN2B53LV1Riz9BnngK 6OFwbgRtaQW+GSn9JqAUJQ5nx4Yp8grwNiGARefY3KlZDJmpTIFYD0PhhAkbV9iNm5xX PVMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726011905; x=1726616705; 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=JNe/WmHLeg6VKg7h5W2f+s+eqgKPFc2fIX3V6u3knDI=; b=UhQ/N/Oc3H4A/UDhbpwabY1UPZN1rGq8NG4PwwzUkfrwHpsCxDxxEchH6mU0AtIsSl HAe2r2GuqSK1ksOVgBXi0g2XKb4k+9fU5srYpJ2PHHGTDUxrF3Ar5JwMXndu3akuy2Mr LR15E3RtvHWd56oOopoGLUG2hvepGZq1RsWtO7qeX2sM8nPOHvvz6hD/3e7xMR0VmtdT wjH1AF9sAqRbu4/h1Ft90z+NIaMr9ebxf1Hat1bMtpfVlMuXA0TeSfIvaKI6uCXwovCe vbHjTf1VTWv7QupSAMcGpH8HirmEqN3aOtLjHnWUjgjDgkQ2FeNI24lDLvvTYz5Te5yF Mj+w== X-Forwarded-Encrypted: i=1; AJvYcCUlcFWBf6aqbrzheMp3TlbBccWdIzSdtEKeBFOuyQ3ZNWAyWboWzkjEmaRTscYU5cB5w+pzcBu4nw==@kvack.org X-Gm-Message-State: AOJu0YzYWollojQvFWFBX+D9IrBzWI8hyaVHz6Xiqb2G2WkV5xqpK7yD mJ8xHQT3zEj6H8Mz17zbUdIVZDqAkhCsrRBWBDlAnspxiiCLh+CZa5nLt4YODvp2YTjpEw0f/VL FwxClP8/J/o5pLiExdixYeA== X-Google-Smtp-Source: AGHT+IEf/I6TXDj4AnDTGwL9SBffiRIBIsWvgKs+GwMaxvWB3wQdGWq/Gxc5GyUB8zA1nCQX52oCQ5i2eL9ajayvXg== X-Received: from ackerleytng-ctop.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:13f8]) (user=ackerleytng job=sendgmr) by 2002:a63:2506:0:b0:7c9:58ed:7139 with SMTP id 41be03b00d2f7-7db084ae38emr8766a12.2.1726011904575; Tue, 10 Sep 2024 16:45:04 -0700 (PDT) Date: Tue, 10 Sep 2024 23:43:50 +0000 In-Reply-To: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.46.0.598.g6f2099f65c-goog Message-ID: <41d7d714cfa7cec3e7089a184918da39e93008ee.1726009989.git.ackerleytng@google.com> Subject: [RFC PATCH 19/39] KVM: selftests: Update test for various private memory backing source types From: Ackerley Tng To: tabba@google.com, quic_eberman@quicinc.com, roypat@amazon.co.uk, jgg@nvidia.com, peterx@redhat.com, david@redhat.com, rientjes@google.com, fvdl@google.com, jthoughton@google.com, seanjc@google.com, pbonzini@redhat.com, zhiquan1.li@intel.com, fan.du@intel.com, jun.miao@intel.com, isaku.yamahata@intel.com, muchun.song@linux.dev, mike.kravetz@oracle.com Cc: erdemaktas@google.com, vannapurve@google.com, ackerleytng@google.com, qperret@google.com, jhubbard@nvidia.com, willy@infradead.org, shuah@kernel.org, brauner@kernel.org, bfoster@redhat.com, kent.overstreet@linux.dev, pvorel@suse.cz, rppt@kernel.org, richard.weiyang@gmail.com, anup@brainfault.org, haibo1.xu@intel.com, ajones@ventanamicro.com, vkuznets@redhat.com, maciej.wieczor-retman@intel.com, pgonda@google.com, oliver.upton@linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-fsdevel@kvack.org X-Stat-Signature: 7fuwungdtcitosskzwh9573pyx1njz7k X-Rspamd-Queue-Id: 0D0FC4000A X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1726011905-560798 X-HE-Meta: U2FsdGVkX1/c/RkEjE9H0hF6xBRBtAGBt8wjMBGE6/DuSq2jYDhkch0gSoCdi3Mc8sd/Q0sJc4Vc4pWUuKs5N6z2HkiiJ6ueQpcGw1cbpl7E1z8DBGwm0vl8l+S/A/N57NzuyOIZWT2l5nfmofubbhCv3ojudsxdnln/SdNg4eO+W5RGvswuDMX5lEhhuxbADyWnKU8hIrSJU2Rohh33A/7OfBlKE4vLikcGrIz1IfcoIZ3WrPPWmlyNi4xMCKPYiG9eIsSJEr11vanMIu6sEcBDRLH5s/dLWv2X+MmqkxORHRN7bgCsTNM9MKsKKUWTdWicb5nmc7gL4Ye0h1tlScgKS+uD3Fl95F7MbwopGLh/PL1FiBoUBVep9hpMvlOASMtOcGzDrv8rUzZYYYPqVg81tBexO7ln+59dDOTeWe91KB7/RcqtLkR4S5lHHMgsextwCATuoyFruUmvoYCc3a/ndA2MqyaBm6FEPeYkLVd9Na+9oQd2MWMLf1MGlBME0+YieVDy5FG5EjA5/YtKTggPnEtF9VCZZEX+VWpdPMRCeN5+bfrPHD0qxYU+r9tB2196YuPEkAwJrCODN9fXXfZgaiFRpUC3YXf+hl0M1Lp19a6rrbYGVzmzUPmiOqXW/fFXd93K1T43VwQWayX7oJsG/zgkAy3/w4gYkwZr29oTutTsRablkcCXPTQteCA6q1a36zWLYM7e3w/kNkAVl/vPv7AnKy2NnRvQ1sE+IBSdmkaoeyE2QS6DSu+z611L5BdS44JoWjEv1cYq4Fx7GW9FODOE5wXKV8MQNfG/i3Cr8SW/l8Ki2dlOTG2CTm+HAFt+H+P02y25Zpcc4AxdQnQ5+YVBIdL9rcc+E5cf+bJZTrQK5g9W6gXQ/twl+5sgZtV9Q5gn6i0vLY0WMGEt5DK6OxrFFqqLOd0UXuL697HWiwWis6xmmLhXuP6BY9jxkbSdG8FAcmkhuJvzzZQ RKcXP77M xgEbrpslXb1r30/Wb4Kj2wQuVanBYdIti+EC9ncmiaH58pJT840JR7TYQgCxQc+OsyZCjXxaiPR3FRwSxCPbJN6WM+5btwiZqNZfw/E7a8TlGrseBVoc/PxFEVHPPBie0KfR2KMmOnQyHGQ6TR10Qy1byFyGS7r41O2w4EF0YJYNHRJEn2/dqMukln/EIAU4AeEXrazlkH4hl+m5Y1gUPV6SW2Z+U/9zLjqtN29hnCkZsBkKLIu2aQxNTH4jrQr9a8gg1ObUzcXnNZexL0EcHFahQ6WE5JUMKzRMn7chkXh0Mmeneqc9KgSnXBAVaaCG7wub4czPndw3Q3sJ6JBF7TjlrEuhUGxGBuBpE06TA8MyS2clwCYv0fuHZ+g/7R5Ra8TJGwXN73BSyWyJLhoeMKupPzdnzILKV+RDkRxNtmi/NBn9hXisxyukoTIwsImVYd5L3+a5GQ41uJLqepz5dqopT2Xs5yrrxP+vhdM/dYDPF9c7Cx2YwfnNcLovMNZui1MTi/f8UDXe+CZ4fUsltw+nzYG4z8eMD6Wdk9i8iSUSxjVOVJK5pUHdqDa6ZXMIYpNM2mAViwnNpBYueR0S2GVpZAQurHmgnIFcfI1/Shrjgca9ycAFYGbTABPatREojIYK6k6W2qZgltL93O7Uuj+7lsg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000006, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Update private_mem_conversions_test for various private memory backing source types. Signed-off-by: Ackerley Tng --- .../kvm/x86_64/private_mem_conversions_test.c | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 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 82a8d88b5338..71f480c19f92 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 @@ -366,14 +366,20 @@ static void *__test_mem_conversions(void *__vcpu) } } -static void test_mem_conversions(enum vm_mem_backing_src_type src_type, uint32_t nr_vcpus, - uint32_t nr_memslots) +static void +test_mem_conversions(enum vm_mem_backing_src_type src_type, + enum vm_private_mem_backing_src_type private_mem_src_type, + uint32_t nr_vcpus, + uint32_t nr_memslots) { /* * Allocate enough memory so that each vCPU's chunk of memory can be * naturally aligned with respect to the size of the backing store. */ - const size_t alignment = max_t(size_t, SZ_2M, get_backing_src_pagesz(src_type)); + const size_t alignment = max_t(size_t, SZ_2M, + max_t(size_t, + get_private_mem_backing_src_pagesz(private_mem_src_type), + get_backing_src_pagesz(src_type))); const size_t per_cpu_size = align_up(PER_CPU_DATA_SIZE, alignment); const size_t memfd_size = per_cpu_size * nr_vcpus; const size_t slot_size = memfd_size / nr_memslots; @@ -394,7 +400,9 @@ static void test_mem_conversions(enum vm_mem_backing_src_type src_type, uint32_t vm_enable_cap(vm, KVM_CAP_EXIT_HYPERCALL, (1 << KVM_HC_MAP_GPA_RANGE)); - memfd = vm_create_guest_memfd(vm, memfd_size, 0); + memfd = vm_create_guest_memfd( + vm, memfd_size, + vm_private_mem_backing_src_alias(private_mem_src_type)->flag); for (i = 0; i < nr_memslots; i++) vm_mem_add(vm, src_type, BASE_DATA_GPA + slot_size * i, @@ -440,10 +448,12 @@ static void test_mem_conversions(enum vm_mem_backing_src_type src_type, uint32_t static void usage(const char *cmd) { puts(""); - printf("usage: %s [-h] [-m nr_memslots] [-s mem_type] [-n nr_vcpus]\n", cmd); + printf("usage: %s [-h] [-m nr_memslots] [-s mem_type] [-p private_mem_type] [-n nr_vcpus]\n", cmd); puts(""); backing_src_help("-s"); puts(""); + private_mem_backing_src_help("-p"); + puts(""); puts(" -n: specify the number of vcpus (default: 1)"); puts(""); puts(" -m: specify the number of memslots (default: 1)"); @@ -453,17 +463,21 @@ static void usage(const char *cmd) int main(int argc, char *argv[]) { enum vm_mem_backing_src_type src_type = DEFAULT_VM_MEM_SRC; + enum vm_private_mem_backing_src_type private_mem_src_type = DEFAULT_VM_PRIVATE_MEM_SRC; uint32_t nr_memslots = 1; uint32_t nr_vcpus = 1; int opt; TEST_REQUIRE(kvm_check_cap(KVM_CAP_VM_TYPES) & BIT(KVM_X86_SW_PROTECTED_VM)); - while ((opt = getopt(argc, argv, "hm:s:n:")) != -1) { + while ((opt = getopt(argc, argv, "hm:s:p:n:")) != -1) { switch (opt) { case 's': src_type = parse_backing_src_type(optarg); break; + case 'p': + private_mem_src_type = parse_private_mem_backing_src_type(optarg); + break; case 'n': nr_vcpus = atoi_positive("nr_vcpus", optarg); break; @@ -477,7 +491,7 @@ int main(int argc, char *argv[]) } } - test_mem_conversions(src_type, nr_vcpus, nr_memslots); + test_mem_conversions(src_type, private_mem_src_type, nr_vcpus, nr_memslots); return 0; }