From patchwork Tue Sep 10 23:43:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ackerley Tng X-Patchwork-Id: 13799493 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 2E035EE01F2 for ; Tue, 10 Sep 2024 23:45:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 35E288D00DF; Tue, 10 Sep 2024 19:45:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 30B4F8D00DB; Tue, 10 Sep 2024 19:45:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 137068D00DF; Tue, 10 Sep 2024 19:45:10 -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 DB93C8D00DB for ; Tue, 10 Sep 2024 19:45:09 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 7C16B140B1C for ; Tue, 10 Sep 2024 23:45:09 +0000 (UTC) X-FDA: 82550461938.01.797A5E9 Received: from mail-pf1-f201.google.com (mail-pf1-f201.google.com [209.85.210.201]) by imf17.hostedemail.com (Postfix) with ESMTP id 9D0D640009 for ; Tue, 10 Sep 2024 23:45:07 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=LH1EojmL; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf17.hostedemail.com: domain of 3AtrgZgsKCHcVXfZmgZtoibbjjbgZ.Xjhgdips-hhfqVXf.jmb@flex--ackerleytng.bounces.google.com designates 209.85.210.201 as permitted sender) smtp.mailfrom=3AtrgZgsKCHcVXfZmgZtoibbjjbgZ.Xjhgdips-hhfqVXf.jmb@flex--ackerleytng.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1726011880; a=rsa-sha256; cv=none; b=befOOhgNwWory5/Thi4vOZU88xUthDGkGgcXVg8y0loF/GcUhjJGDbZPYXePwJMhV5nAJv T6CgQecBEiuQQbgH99dRw+AklvBcsAu4WHP/zgdyG5vUCzvn59a70w90IJK/1vS05Ynugl +Q0wOSZ4ly6NjPoeHSqSLQRmh8QI/Gw= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=LH1EojmL; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf17.hostedemail.com: domain of 3AtrgZgsKCHcVXfZmgZtoibbjjbgZ.Xjhgdips-hhfqVXf.jmb@flex--ackerleytng.bounces.google.com designates 209.85.210.201 as permitted sender) smtp.mailfrom=3AtrgZgsKCHcVXfZmgZtoibbjjbgZ.Xjhgdips-hhfqVXf.jmb@flex--ackerleytng.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1726011880; 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=WNwyUtrg2ydCG7OEuuYFt3GviKLhR33B3wmqNjEPlY0=; b=lQr2rdvrixDWxa7uvEY+417r3aDeXWdrxnIRePAIBwpy4fm+CPd+D5tObc7i8F2ePN6oWl SncirgF4u1MVJYDKY6F3m1C1ZSJMDnK42I4jipuRhGJYWJnmw2/kd7OUy42ZHszsSBeV7q 81yoWJ4ERV/t/Fx3buCZSJaYSyrbrxs= Received: by mail-pf1-f201.google.com with SMTP id d2e1a72fcca58-717dfdd7c72so7071968b3a.0 for ; Tue, 10 Sep 2024 16:45:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726011906; x=1726616706; 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=WNwyUtrg2ydCG7OEuuYFt3GviKLhR33B3wmqNjEPlY0=; b=LH1EojmLW+lsmwnmzuQGxgDoMDi1ZW21tyKZMGSt4D5X3NnEUdKJNS28sNbxZ3rXVS Yj5TK9BMYLYjkF3S/RYiV67i+t0U3i7dmnom3J/bRhLfJ5RBO+9uNUI59+8rwp8r3Dig xwTCaV4sso/BgKRvRTWHeP41Glg789xlZFxXE9Rul5AlQR2chHz4RUyZ5Eafey0T2qiu clvhzBEQM0114wPHkpKty2MV/n45DFgJb+VuQnBNvEXEEfqruQeblPm96Qdad7eqTRm0 YlkCDLYrR4+7ggbNB6R7XyjQ84Rw4xnNZ+AcWmcV41WVIFWAV2dbl/mcHTVrdeiOgRQn Rr5w== 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=BzWzfYX3eEadcq70BUqTdulcSFoiCMUDz4+gXE5k7ErAoHmfGSEx8AbI6B/LwQeomK WZLo1zFtUBi5TI3N4+UJIh45hRjdNxYA3KOo9mx+DAU3SNKuPUyw5Mcei6qfewNCzfhT bXDYWoA6I0KNhja2T/aQgMKOIbd9Zja/JVyzxE6ZOJRlUQ4ns8rgQZsQM1HM/DrKuMxf qX8tkB7ptx0mvrC+5B9DCPLviQnu4OWcSS0rTZg+aw0RiZqJiHbTlbJr+JY840yChJWr 9SGjE1CfpHjxNeV9ACjl5SuWa/1Qy+PBl+YFdwOJkqWmESDkrqdT4/GAjyIZ61H5JCA6 mwqQ== X-Forwarded-Encrypted: i=1; AJvYcCVheCPLCmPmzgcqF4IAZVJqiDnNaYey3VrCFRfvz5R3etCxJJccE+ixFvZOSZtVxrUt8xCh+hpZUQ==@kvack.org X-Gm-Message-State: AOJu0YzJ1LWknkyDrnnrIy7xMCPPad1pYvt5NTenl48JPKGoejTw3SY6 DkTq8/Qc0lAprYMDJJPi8RTsO8oVycv6qW54HM8+q92Wr9Q/aiSPeQWEQvEnlbi1tyoi9+fHlB+ GA3DXtGL4lalukZusDM71ZA== 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: 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 X-Rspam-User: X-Rspamd-Queue-Id: 9D0D640009 X-Rspamd-Server: rspam01 X-Stat-Signature: in67tdfmp7yfpa7mesqspqotqm7c6rka X-HE-Tag: 1726011907-692334 X-HE-Meta: U2FsdGVkX1+YoBPRzDjegWgOZqIKhqmcNtPNVKt841uXMFr9BcfBeVFZe/yvkepzh0Z1kL5UgO2GY77phf518HeMmDZ8NecIP4DZCCfPnMtQ6PNoJGra3B+UovWxdF5zoehDPyscDAoggWrvOiaXgGg61uwTbHFqlrM2fQKtpWg2r8llWgAHDNCSl+8QiWeBqOFho3jOq0NJANxUDQSKFFsnN47hoj9ChovUgBX2dZF5WRd2ICDLDEvuBjaGFSlvMMP0HCz5iQ2Fx0Cyqkz/+RpoJvb0CrMh+GEsj4hRnwzByTsN9t0ZAQOBHpPX9l+MF0ZECvwoqQ/pSJNb2c3M9XBrbCWZwNRuLefk8vz6V1sr/x7p1aUMBKUO+K04EoZdzufEOqN5DLyX3DLDhnBK4WY+FRmmjPc6x6JTGGXG7j2taxJRp4PYeZQwwsxGeAa42Gq1IVxp6WWZB8Q9mUq6ANT5Zu/HW21vRamjaG4VHgN4TFAlcvAaEZQWywScDxitrXq5+S8ZwIO1YH/7B1ufC4YTVpquN8LC+1OTJgi9lbDcynIo9FIMEbnPTEAsrOEHhFz7m3CUgNoWH7EhMZdCxKsQZZ4irz/42HpEBmhHUHsx1QquqlPeLXxboJ2hOCd/EROrDHXu8u+nYf+hK8aHP9ep7JeAbQ1waJTG3A5CHfQcIbyG01P1H8emfpcND8e48Qoj4SrjtDmGbHFujBsLog75y+vxVUblGr8Y+EYRhGkyMcKM/Pk7nZgBiAk6SFeMyYbGSLQ1C9Mkqg1tfn3J4U+KRuw1NpOPq/UXdLclNpKNxVnoG75jeJC38lDHH/VMwRO6qKIjaaYNujhvOb+qTCXVs9H0e99DBsar4SY8CxgrXWLQKYKCJnnsiAuslYIriIJPAwkWsbmX2W1ZH40VIdA801yaELVnVqKauct/F+U9Aym2OoR/9eWhxnWS7J9YUBVzYArZD4stoSC8kEP 6xW979mw i1LWCHIWjxgbMTPJQAZHWdCB6gYqs4eOaq8A4ILkqH50hOkam7KBEhK9eMSEY8LHIrMM0wjmH/2/tMCA7eIya51e6M2RyRcg38pVOcgQ1BiYCX7SflgbmZrsFm3qKrsWH0QMZMveyxSxsTIBVe17E1ghCQ3qZHZm0bqHgo17//bq+ZQr1JmU01S4sGeLud6hAAYMU3g+CsEkKlXQVRjyJ6sstzMrq0AEWyEHmQLw7ZQ7QxOqfisqgghwk7FIiUBuT8dFxNUt/OtHcxqq1KScA0MQrKv9kq8BPxnSCAjZbUq36zKgdHOM7s5yFewyvcUJfmXHBs3RpLzLmqKftzIkWwKf7D1GS+feOAS3eeZeASFc8ZoD9QrlmkCPSeEADsPxinqFnC8nMUFYZ0Dg9HZFIx41CwbC6I3WmcL5dqaPBAqsLurlHozWYxQzl8SgIo426mSvAY6I4BGxdgSR037Br7nIBNwGnpa9Byb3v1kwWp/K33S3BXr+dFeoGrZfYILnL86yhj+VkQUldbbI/cxZi9RgsKYwz36SYFF+LzYsgThufFnw7Ed2HpZz6ygfaJUpzHrLiWcoiLxHQ4Qw4uWXZv3uzteEXSFUvq6+UOGD7IktS1YeYqCkbo1WgQSgC5dO762/e4p/QnzNUTO8lqx3DmZwKVQP3zHAvB6wwpw2S8JpK6f+2WU9c6GPOoMVXMfXphId7h67EUaw/+L0= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000059, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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_conversions_test.sh diff --git a/tools/testing/selftests/kvm/x86_64/private_mem_conversions_test.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=4 +num_memslots_to_test=$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_size) 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=$(( 1024 * num_vcpus_to_test )) +required_num_1g_hugepages=$(( 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/null || echo 0)" -ge "$required_num_2m_hugepages" ] && hugepage_2mb_enabled=1 +[ "$(cat /sys/kernel/mm/hugepages/hugepages-1048576kB/nr_hugepages 2>/dev/null || echo 0)" -ge "$required_num_1g_hugepages" ] && hugepage_1gb_enabled=1 + +case $(get_default_hugepage_size_in_kB) in + 2048) + hugepage_default_enabled=$hugepage_2mb_enabled + ;; + 1048576) + hugepage_default_enabled=$hugepage_1gb_enabled + ;; + *) + hugepage_default_enabled=0 + ;; +esac + +backing_src_types=( anonymous ) +backing_src_types+=( anonymous_thp ) +[ -n "$hugepage_default_enabled" ] && \ + backing_src_types+=( anonymous_hugetlb ) || echo "skipping anonymous_hugetlb backing source type" +[ -n "$hugepage_2mb_enabled" ] && \ + backing_src_types+=( anonymous_hugetlb_2mb ) || echo "skipping anonymous_hugetlb_2mb backing source type" +[ -n "$hugepage_1gb_enabled" ] && \ + backing_src_types+=( anonymous_hugetlb_1gb ) || echo "skipping anonymous_hugetlb_1gb backing source type" +backing_src_types+=( shmem ) +[ -n "$hugepage_default_enabled" ] && \ + backing_src_types+=( shared_hugetlb ) || echo "skipping shared_hugetlb backing source type" + +private_mem_backing_src_types=( private_mem_guest_mem ) +[ -n "$hugepage_default_enabled" ] && \ + private_mem_backing_src_types+=( private_mem_hugetlb ) || echo "skipping private_mem_hugetlb backing source type" +[ -n "$hugepage_2mb_enabled" ] && \ + private_mem_backing_src_types+=( private_mem_hugetlb_2mb ) || echo "skipping private_mem_hugetlb_2mb backing source type" +[ -n "$hugepage_1gb_enabled" ] && \ + private_mem_backing_src_types+=( private_mem_hugetlb_1gb ) || echo "skipping private_mem_hugetlb_1gb backing source type" + +set +e + +TEST_EXECUTABLE="$(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_vcpus_to_test + $TEST_EXECUTABLE -s "$src_type" -p "$private_mem_src_type" -n $num_vcpus_to_test -m $num_memslots_to_test + + { set +x; } 2>/dev/null + + echo + + done + + done +) +RET=$? + +exit $RET