kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Axel Rasmussen <axelrasmussen@google.com>
To: Aaron Lewis <aaronlewis@google.com>,
	Alexander Graf <graf@amazon.com>,
	Andrew Jones <drjones@redhat.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Ben Gardon <bgardon@google.com>,
	Emanuele Giuseppe Esposito <eesposit@redhat.com>,
	Eric Auger <eric.auger@redhat.com>,
	Jacob Xu <jacobhxu@google.com>,
	Makarand Sonare <makarandsonare@google.com>,
	Oliver Upton <oupton@google.com>,
	Paolo Bonzini <pbonzini@redhat.com>, Peter Xu <peterx@redhat.com>,
	Shuah Khan <shuah@kernel.org>,
	Yanan Wang <wangyanan55@huawei.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org,
	Axel Rasmussen <axelrasmussen@google.com>
Subject: [PATCH v2 05/10] KVM: selftests: allow different backing source types
Date: Wed, 19 May 2021 13:03:34 -0700	[thread overview]
Message-ID: <20210519200339.829146-6-axelrasmussen@google.com> (raw)
In-Reply-To: <20210519200339.829146-1-axelrasmussen@google.com>

Add an argument which lets us specify a different backing memory type
for the test. The default is just to use anonymous, matching existing
behavior.

This is in preparation for testing UFFD minor faults. For that, we'll
need to use a new backing memory type which is setup with MAP_SHARED.

Signed-off-by: Axel Rasmussen <axelrasmussen@google.com>
---
 tools/testing/selftests/kvm/demand_paging_test.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/kvm/demand_paging_test.c b/tools/testing/selftests/kvm/demand_paging_test.c
index 94cf047358d5..01890a7b0155 100644
--- a/tools/testing/selftests/kvm/demand_paging_test.c
+++ b/tools/testing/selftests/kvm/demand_paging_test.c
@@ -241,6 +241,7 @@ static void setup_demand_paging(struct kvm_vm *vm,
 struct test_params {
 	bool use_uffd;
 	useconds_t uffd_delay;
+	enum vm_mem_backing_src_type src_type;
 	bool partition_vcpu_memory_access;
 };
 
@@ -258,11 +259,11 @@ 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,
-				 VM_MEM_SRC_ANONYMOUS);
+				 p->src_type);
 
 	perf_test_args.wr_fract = 1;
 
-	demand_paging_size = get_backing_src_pagesz(VM_MEM_SRC_ANONYMOUS);
+	demand_paging_size = get_backing_src_pagesz(p->src_type);
 
 	guest_data_prototype = malloc(demand_paging_size);
 	TEST_ASSERT(guest_data_prototype,
@@ -378,7 +379,7 @@ static void help(char *name)
 {
 	puts("");
 	printf("usage: %s [-h] [-m mode] [-u] [-d uffd_delay_usec]\n"
-	       "          [-b memory] [-v vcpus] [-o]\n", name);
+	       "          [-b memory] [-t type] [-v vcpus] [-o]\n", name);
 	guest_modes_help();
 	printf(" -u: use User Fault FD to handle vCPU page\n"
 	       "     faults.\n");
@@ -388,6 +389,8 @@ static void help(char *name)
 	printf(" -b: specify the size of the memory region which should be\n"
 	       "     demand paged by each vCPU. e.g. 10M or 3G.\n"
 	       "     Default: 1G\n");
+	printf(" -t: The type of backing memory to use. Default: anonymous\n");
+	backing_src_help();
 	printf(" -v: specify the number of vCPUs to run.\n");
 	printf(" -o: Overlap guest memory accesses instead of partitioning\n"
 	       "     them into a separate region of memory for each vCPU.\n");
@@ -399,13 +402,14 @@ int main(int argc, char *argv[])
 {
 	int max_vcpus = kvm_check_cap(KVM_CAP_MAX_VCPUS);
 	struct test_params p = {
+		.src_type = VM_MEM_SRC_ANONYMOUS,
 		.partition_vcpu_memory_access = true,
 	};
 	int opt;
 
 	guest_modes_append_default();
 
-	while ((opt = getopt(argc, argv, "hm:ud:b:v:o")) != -1) {
+	while ((opt = getopt(argc, argv, "hm:ud:b:t:v:o")) != -1) {
 		switch (opt) {
 		case 'm':
 			guest_modes_cmdline(optarg);
@@ -420,6 +424,9 @@ int main(int argc, char *argv[])
 		case 'b':
 			guest_percpu_mem_size = parse_size(optarg);
 			break;
+		case 't':
+			p.src_type = parse_backing_src_type(optarg);
+			break;
 		case 'v':
 			nr_vcpus = atoi(optarg);
 			TEST_ASSERT(nr_vcpus > 0 && nr_vcpus <= max_vcpus,
-- 
2.31.1.751.gd2f1c929bd-goog


  parent reply	other threads:[~2021-05-19 20:04 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-19 20:03 [PATCH v2 00/10] KVM: selftests: exercise userfaultfd minor faults Axel Rasmussen
2021-05-19 20:03 ` [PATCH v2 01/10] KVM: selftests: trivial comment/logging fixes Axel Rasmussen
2021-05-19 21:41   ` Ben Gardon
2021-05-19 20:03 ` [PATCH v2 02/10] KVM: selftests: simplify setup_demand_paging error handling Axel Rasmussen
2021-05-19 21:45   ` Ben Gardon
2021-05-19 22:14     ` Axel Rasmussen
2021-05-19 22:23       ` Ben Gardon
2021-05-24 13:25       ` Paolo Bonzini
2021-05-19 20:03 ` [PATCH v2 03/10] KVM: selftests: print a message when skipping KVM tests Axel Rasmussen
2021-05-19 21:49   ` Ben Gardon
2021-05-24 13:23     ` Paolo Bonzini
2021-05-19 20:03 ` [PATCH v2 04/10] KVM: selftests: compute correct demand paging size Axel Rasmussen
2021-05-19 21:51   ` Ben Gardon
2021-05-19 20:03 ` Axel Rasmussen [this message]
2021-05-19 21:53   ` [PATCH v2 05/10] KVM: selftests: allow different backing source types Ben Gardon
2021-05-19 20:03 ` [PATCH v2 06/10] KVM: selftests: refactor vm_mem_backing_src_type flags Axel Rasmussen
2021-05-19 22:02   ` Ben Gardon
2021-05-19 22:16     ` Axel Rasmussen
2021-05-19 22:25       ` Ben Gardon
2021-05-19 20:03 ` [PATCH v2 07/10] KVM: selftests: add shmem backing source type Axel Rasmussen
2021-05-19 22:03   ` Ben Gardon
2021-05-19 20:03 ` [PATCH v2 08/10] KVM: selftests: create alias mappings when using shared memory Axel Rasmussen
2021-05-25 23:49   ` David Matlack
2021-05-26 17:22     ` Axel Rasmussen
2021-05-26 18:31       ` Paolo Bonzini
2021-05-19 20:03 ` [PATCH v2 09/10] KVM: selftests: allow using UFFD minor faults for demand paging Axel Rasmussen
2021-05-19 22:20   ` Ben Gardon
2021-05-19 22:34     ` Axel Rasmussen
2021-05-24 13:36     ` Paolo Bonzini
2021-05-19 20:03 ` [PATCH v2 10/10] KVM: selftests: add shared hugetlbfs backing source type Axel Rasmussen
2021-05-19 22:22   ` Ben Gardon
2021-05-24 13:38 ` [PATCH v2 00/10] KVM: selftests: exercise userfaultfd minor faults Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210519200339.829146-6-axelrasmussen@google.com \
    --to=axelrasmussen@google.com \
    --cc=aaronlewis@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=bgardon@google.com \
    --cc=drjones@redhat.com \
    --cc=eesposit@redhat.com \
    --cc=eric.auger@redhat.com \
    --cc=graf@amazon.com \
    --cc=jacobhxu@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=makarandsonare@google.com \
    --cc=oupton@google.com \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=shuah@kernel.org \
    --cc=wangyanan55@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).