Commit 9e965bb7 authored by Ben Gardon's avatar Ben Gardon Committed by Paolo Bonzini
Browse files

KVM: selftests: Add backing src parameter to dirty_log_perf_test



Add a parameter to control the backing memory type for
dirty_log_perf_test so that the test can be run with hugepages.

To: linux-kselftest@vger.kernel.org
CC: Peter Xu <peterx@redhat.com>
CC: Andrew Jones <drjones@redhat.com>
CC: Thomas Huth <thuth@redhat.com>
Signed-off-by: default avatarBen Gardon <bgardon@google.com>
Message-Id: <20210202185734.1680553-28-bgardon@google.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent f73a3446
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -266,7 +266,8 @@ static void run_test(enum vm_guest_mode mode, void *arg)
	int vcpu_id;
	int r;

	vm = perf_test_create_vm(mode, nr_vcpus, guest_percpu_mem_size);
	vm = perf_test_create_vm(mode, nr_vcpus, guest_percpu_mem_size,
				 VM_MEM_SRC_ANONYMOUS);

	perf_test_args.wr_fract = 1;

+11 −3
Original line number Diff line number Diff line
@@ -93,6 +93,7 @@ struct test_params {
	uint64_t phys_offset;
	int wr_fract;
	bool partition_vcpu_memory_access;
	enum vm_mem_backing_src_type backing_src;
};

static void run_test(enum vm_guest_mode mode, void *arg)
@@ -112,7 +113,8 @@ static void run_test(enum vm_guest_mode mode, void *arg)
	struct kvm_enable_cap cap = {};
	struct timespec clear_dirty_log_total = (struct timespec){0};

	vm = perf_test_create_vm(mode, nr_vcpus, guest_percpu_mem_size);
	vm = perf_test_create_vm(mode, nr_vcpus, guest_percpu_mem_size,
				 p->backing_src);

	perf_test_args.wr_fract = p->wr_fract;

@@ -242,7 +244,7 @@ static void help(char *name)
{
	puts("");
	printf("usage: %s [-h] [-i iterations] [-p offset] "
	       "[-m mode] [-b vcpu bytes] [-v vcpus] [-o]\n", name);
	       "[-m mode] [-b vcpu bytes] [-v vcpus] [-o] [-s mem type]\n", name);
	puts("");
	printf(" -i: specify iteration counts (default: %"PRIu64")\n",
	       TEST_HOST_LOOP_N);
@@ -259,6 +261,9 @@ static void help(char *name)
	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");
	printf(" -s: specify the type of memory that should be used to\n"
	       "     back the guest data region.\n\n");
	backing_src_help();
	puts("");
	exit(0);
}
@@ -270,6 +275,7 @@ int main(int argc, char *argv[])
		.iterations = TEST_HOST_LOOP_N,
		.wr_fract = 1,
		.partition_vcpu_memory_access = true,
		.backing_src = VM_MEM_SRC_ANONYMOUS,
	};
	int opt;

@@ -280,7 +286,7 @@ int main(int argc, char *argv[])

	guest_modes_append_default();

	while ((opt = getopt(argc, argv, "hi:p:m:b:f:v:o")) != -1) {
	while ((opt = getopt(argc, argv, "hi:p:m:b:f:v:os:")) != -1) {
		switch (opt) {
		case 'i':
			p.iterations = atoi(optarg);
@@ -306,6 +312,8 @@ int main(int argc, char *argv[])
			break;
		case 'o':
			p.partition_vcpu_memory_access = false;
		case 's':
			p.backing_src = parse_backing_src_type(optarg);
			break;
		case 'h':
		default:
+0 −6
Original line number Diff line number Diff line
@@ -79,12 +79,6 @@ struct vm_guest_mode_params {
};
extern const struct vm_guest_mode_params vm_guest_mode_params[];

enum vm_mem_backing_src_type {
	VM_MEM_SRC_ANONYMOUS,
	VM_MEM_SRC_ANONYMOUS_THP,
	VM_MEM_SRC_ANONYMOUS_HUGETLB,
};

int kvm_check_cap(long cap);
int vm_enable_cap(struct kvm_vm *vm, struct kvm_enable_cap *cap);
int vcpu_enable_cap(struct kvm_vm *vm, uint32_t vcpu_id,
+2 −1
Original line number Diff line number Diff line
@@ -44,7 +44,8 @@ extern struct perf_test_args perf_test_args;
extern uint64_t guest_test_phys_mem;

struct kvm_vm *perf_test_create_vm(enum vm_guest_mode mode, int vcpus,
				uint64_t vcpu_memory_bytes);
				   uint64_t vcpu_memory_bytes,
				   enum vm_mem_backing_src_type backing_src);
void perf_test_destroy_vm(struct kvm_vm *vm);
void perf_test_setup_vcpus(struct kvm_vm *vm, int vcpus,
			   uint64_t vcpu_memory_bytes,
+14 −0
Original line number Diff line number Diff line
@@ -67,4 +67,18 @@ struct timespec timespec_sub(struct timespec ts1, struct timespec ts2);
struct timespec timespec_elapsed(struct timespec start);
struct timespec timespec_div(struct timespec ts, int divisor);

enum vm_mem_backing_src_type {
	VM_MEM_SRC_ANONYMOUS,
	VM_MEM_SRC_ANONYMOUS_THP,
	VM_MEM_SRC_ANONYMOUS_HUGETLB,
};

struct vm_mem_backing_src_alias {
	const char *name;
	enum vm_mem_backing_src_type type;
};

void backing_src_help(void);
enum vm_mem_backing_src_type parse_backing_src_type(const char *type_name);

#endif /* SELFTEST_KVM_TEST_UTIL_H */
Loading