perf_test_util.h 1.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
// SPDX-License-Identifier: GPL-2.0
/*
 * tools/testing/selftests/kvm/include/perf_test_util.h
 *
 * Copyright (C) 2020, Google LLC.
 */

#ifndef SELFTEST_KVM_PERF_TEST_UTIL_H
#define SELFTEST_KVM_PERF_TEST_UTIL_H

11 12
#include <pthread.h>

13 14 15 16 17
#include "kvm_util.h"

/* Default guest test virtual memory offset */
#define DEFAULT_GUEST_TEST_MEM		0xc0000000

18 19
#define DEFAULT_PER_VCPU_MEM_SIZE	(1 << 30) /* 1G */

20
#define PERF_TEST_MEM_SLOT_INDEX	1
21

22
struct perf_test_vcpu_args {
23
	uint64_t gpa;
24 25 26 27 28 29 30 31 32
	uint64_t gva;
	uint64_t pages;

	/* Only used by the host userspace part of the vCPU thread */
	int vcpu_id;
};

struct perf_test_args {
	struct kvm_vm *vm;
33
	uint64_t gpa;
34
	uint64_t guest_page_size;
35
	int wr_fract;
36

37
	struct perf_test_vcpu_args vcpu_args[KVM_MAX_VCPUS];
38 39
};

40
extern struct perf_test_args perf_test_args;
41

42
struct kvm_vm *perf_test_create_vm(enum vm_guest_mode mode, int vcpus,
43
				   uint64_t vcpu_memory_bytes, int slots,
44 45
				   enum vm_mem_backing_src_type backing_src,
				   bool partition_vcpu_memory_access);
46
void perf_test_destroy_vm(struct kvm_vm *vm);
47

48 49
void perf_test_set_wr_fract(struct kvm_vm *vm, int wr_fract);

50 51 52
void perf_test_start_vcpu_threads(int vcpus, void (*vcpu_fn)(struct perf_test_vcpu_args *));
void perf_test_join_vcpu_threads(int vcpus);

53
#endif /* SELFTEST_KVM_PERF_TEST_UTIL_H */