From nobody Sat Nov 30 10:37:50 2024 Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0DA6F1BE24B for ; Tue, 10 Sep 2024 23:45:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726011908; cv=none; b=LeQl9t85Qn4Q1JjAPwMOmgNu/if4eJCPKftBUkQ86hAU7Gh/gHrHS4VaNrnk3nCW63Pc+8KIQqKZjKu3PlKbYgyLGL4RsbtTEs93B/0NDafipnCLak89u/5yDGY1CNB6Fy9jPX6FKgm0X1nQtch+d9tTUiqfQSwdr8YW4mgnzyA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726011908; c=relaxed/simple; bh=XiY3BKQF2LguGns0tGK1hRv3k4qaW06a47f+QLg/xl8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=XwUm2gPWF8QHWWoovnKBNzBtxVbVN74jYoBmy9gOpCfhlQUK7X57Ma7siwmsMCzv//IESt+4WfNkfo7OidMwZ/4Do2zpC2tVlYer/N54qGEzyb7QdRgzsATFWcX3p7hxcSf3s+dR2w6WnX7z/59SjAo/NQ/P1+NGd1ufCIFoiYE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--ackerleytng.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=GPrF7ut9; arc=none smtp.client-ip=209.85.210.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--ackerleytng.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="GPrF7ut9" Received: by mail-pf1-f202.google.com with SMTP id d2e1a72fcca58-717dfdd7c72so7071969b3a.0 for ; Tue, 10 Sep 2024 16:45:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726011906; x=1726616706; darn=vger.kernel.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=WNwyUtrg2ydCG7OEuuYFt3GviKLhR33B3wmqNjEPlY0=; b=GPrF7ut9yZpPR4ISa4MMHpXUP/tg2Qk5c2Yp1SvNZW2V0nZ81Ql436VsbZQwMPFvOX Edwz51Cgs2fGmaN69ASSuae2/16qtajVpnU1ijwojUmZgPhOsuEXbuD0fi332ITaU57y CdctyCvRWHV1KGbpQEwpKt0zC0sABM6eRk9y+YEXcqXMpbHn1VCkjR6mupHbZAY/biCq mEWfL404K4u9t9c/aqHbw626QQPdW6LSLhH2Auerl2DnOkcPzyphyhZHF/vxt+h1MqnM 6ahIf4Vd49oUlt6/Ui2kqHkvztH0wgEigvb/WwPfVm3P5+pcAinKptA/eBx9VpmGIm3n hPuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726011906; x=1726616706; 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=WNwyUtrg2ydCG7OEuuYFt3GviKLhR33B3wmqNjEPlY0=; b=fjycabXTaQJmUmQdgRDT7yE35PWLxo7cIv2v9vaL3fLEiZtO/4WdJO+GI+sh+HWZvd 3THvRwYzRZN7HYh54RI4WLJ8/ibPQ8cPEtHkoAdX6jzt2lX5RnZorVz+cqKAcpOT2Gao weKt7YAhhCqLMNBYifQRd2bVQh8V3nQgoSgLkQxlMRQnNm5GOI0tsd79a8SHmwqGmQkh 7EdLY8GGnxxWYtmLRuLG3UrKIM2ULS1GDLybA/MCR98KGxSxvYOuyCYgfMh/mKCSz/Jk zU7bmLPCXwb5Qjo0Na8YFO6JdJHV1Pm2L1E90/Kb3bpnnV8XGOrIBYXmKhXomZjcnt7t YKMQ== X-Forwarded-Encrypted: i=1; AJvYcCU8ipN2GUaNGsd38MvIPpLrqLj0UiDirsoROLCjEzqZ+PU2G9fzdy9X0ErnQI7HJhHlmUNLz4hPeZBfBks=@vger.kernel.org X-Gm-Message-State: AOJu0Yw+fSf7lXfVj98df/xEj2QwDvF7q1GSUouAKkp6vhxOazrNLgzW tIoJFMDwIYIPa+p2EEheUTRaQ123F+GEsr6gQpMfDsEuqpUy7FtMq2+f0+LMAfwnxgVbLSEfsUJ 5Kob8j44oX2Nk6FzMVI0wuQ== X-Google-Smtp-Source: AGHT+IEcZ/ghxITnGvgKkAKwRaOU4W9SdtHb2nrXhbk+ACBlgEJVwXnXXaBkRqqDbpe8CxVzylPUbg24aRXjUe363A== X-Received: from ackerleytng-ctop.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:13f8]) (user=ackerleytng job=sendgmr) by 2002:a05:6a00:81c6:b0:718:d8af:4551 with SMTP id d2e1a72fcca58-718d8af4650mr30583b3a.1.1726011906107; Tue, 10 Sep 2024 16:45:06 -0700 (PDT) Date: Tue, 10 Sep 2024 23:43:51 +0000 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.46.0.598.g6f2099f65c-goog Message-ID: <6bfe8c9baabc6ad89ccc2c4481db2b4983cbfd8b.1726009989.git.ackerleytng@google.com> Subject: [RFC PATCH 20/39] KVM: selftests: Add private_mem_conversions_test.sh 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add private_mem_conversions_test.sh to automate testing of different combinations of private_mem_conversions_test. Signed-off-by: Ackerley Tng --- .../x86_64/private_mem_conversions_test.sh | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100755 tools/testing/selftests/kvm/x86_64/private_mem_conversi= ons_test.sh diff --git a/tools/testing/selftests/kvm/x86_64/private_mem_conversions_tes= t.sh b/tools/testing/selftests/kvm/x86_64/private_mem_conversions_test.sh new file mode 100755 index 000000000000..fb6705fef466 --- /dev/null +++ b/tools/testing/selftests/kvm/x86_64/private_mem_conversions_test.sh @@ -0,0 +1,88 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0-only */ +# +# Wrapper script which runs different test setups of +# private_mem_conversions_test. +# +# tools/testing/selftests/kvm/private_mem_conversions_test.sh +# Copyright (C) 2023, Google LLC. + +set -e + +num_vcpus_to_test=3D4 +num_memslots_to_test=3D$num_vcpus_to_test + +get_default_hugepage_size_in_kB() { + grep "Hugepagesize:" /proc/meminfo | grep -o '[[:digit:]]\+' +} + +# Required pages are based on the test setup (see computation for memfd_si= ze) in +# test_mem_conversions() in private_mem_migrate_tests.c) + +# These static requirements are set to the maximum required for +# num_vcpus_to_test, over all the hugetlb-related tests +required_num_2m_hugepages=3D$(( 1024 * num_vcpus_to_test )) +required_num_1g_hugepages=3D$(( 2 * num_vcpus_to_test )) + +# The other hugetlb sizes are not supported on x86_64 +[ "$(cat /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages 2>/dev/nul= l || echo 0)" -ge "$required_num_2m_hugepages" ] && hugepage_2mb_enabled=3D1 +[ "$(cat /sys/kernel/mm/hugepages/hugepages-1048576kB/nr_hugepages 2>/dev/= null || echo 0)" -ge "$required_num_1g_hugepages" ] && hugepage_1gb_enabled= =3D1 + +case $(get_default_hugepage_size_in_kB) in + 2048) + hugepage_default_enabled=3D$hugepage_2mb_enabled + ;; + 1048576) + hugepage_default_enabled=3D$hugepage_1gb_enabled + ;; + *) + hugepage_default_enabled=3D0 + ;; +esac + +backing_src_types=3D( anonymous ) +backing_src_types+=3D( anonymous_thp ) +[ -n "$hugepage_default_enabled" ] && \ + backing_src_types+=3D( anonymous_hugetlb ) || echo "skipping anonymous= _hugetlb backing source type" +[ -n "$hugepage_2mb_enabled" ] && \ + backing_src_types+=3D( anonymous_hugetlb_2mb ) || echo "skipping anony= mous_hugetlb_2mb backing source type" +[ -n "$hugepage_1gb_enabled" ] && \ + backing_src_types+=3D( anonymous_hugetlb_1gb ) || echo "skipping anony= mous_hugetlb_1gb backing source type" +backing_src_types+=3D( shmem ) +[ -n "$hugepage_default_enabled" ] && \ + backing_src_types+=3D( shared_hugetlb ) || echo "skipping shared_hugetlb= backing source type" + +private_mem_backing_src_types=3D( private_mem_guest_mem ) +[ -n "$hugepage_default_enabled" ] && \ + private_mem_backing_src_types+=3D( private_mem_hugetlb ) || echo "skip= ping private_mem_hugetlb backing source type" +[ -n "$hugepage_2mb_enabled" ] && \ + private_mem_backing_src_types+=3D( private_mem_hugetlb_2mb ) || echo "= skipping private_mem_hugetlb_2mb backing source type" +[ -n "$hugepage_1gb_enabled" ] && \ + private_mem_backing_src_types+=3D( private_mem_hugetlb_1gb ) || echo "= skipping private_mem_hugetlb_1gb backing source type" + +set +e + +TEST_EXECUTABLE=3D"$(dirname "$0")/private_mem_conversions_test" + +( + set -e + + for src_type in "${backing_src_types[@]}"; do + + for private_mem_src_type in "${private_mem_backing_src_types[@]}"; do + set -x + + $TEST_EXECUTABLE -s "$src_type" -p "$private_mem_src_type" -n $num_vcpu= s_to_test + $TEST_EXECUTABLE -s "$src_type" -p "$private_mem_src_type" -n $num_vcpu= s_to_test -m $num_memslots_to_test + + { set +x; } 2>/dev/null + + echo + + done + + done +) +RET=3D$? + +exit $RET --=20 2.46.0.598.g6f2099f65c-goog