~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/kvm/include/memstress.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 /*
  3  * tools/testing/selftests/kvm/include/memstress.h
  4  *
  5  * Copyright (C) 2020, Google LLC.
  6  */
  7 
  8 #ifndef SELFTEST_KVM_MEMSTRESS_H
  9 #define SELFTEST_KVM_MEMSTRESS_H
 10 
 11 #include <pthread.h>
 12 
 13 #include "kvm_util.h"
 14 
 15 /* Default guest test virtual memory offset */
 16 #define DEFAULT_GUEST_TEST_MEM          0xc0000000
 17 
 18 #define DEFAULT_PER_VCPU_MEM_SIZE       (1 << 30) /* 1G */
 19 
 20 #define MEMSTRESS_MEM_SLOT_INDEX        1
 21 
 22 struct memstress_vcpu_args {
 23         uint64_t gpa;
 24         uint64_t gva;
 25         uint64_t pages;
 26 
 27         /* Only used by the host userspace part of the vCPU thread */
 28         struct kvm_vcpu *vcpu;
 29         int vcpu_idx;
 30 };
 31 
 32 struct memstress_args {
 33         struct kvm_vm *vm;
 34         /* The starting address and size of the guest test region. */
 35         uint64_t gpa;
 36         uint64_t size;
 37         uint64_t guest_page_size;
 38         uint32_t random_seed;
 39         uint32_t write_percent;
 40 
 41         /* Run vCPUs in L2 instead of L1, if the architecture supports it. */
 42         bool nested;
 43         /* Randomize which pages are accessed by the guest. */
 44         bool random_access;
 45         /* True if all vCPUs are pinned to pCPUs */
 46         bool pin_vcpus;
 47         /* The vCPU=>pCPU pinning map. Only valid if pin_vcpus is true. */
 48         uint32_t vcpu_to_pcpu[KVM_MAX_VCPUS];
 49 
 50         /* Test is done, stop running vCPUs. */
 51         bool stop_vcpus;
 52 
 53         struct memstress_vcpu_args vcpu_args[KVM_MAX_VCPUS];
 54 };
 55 
 56 extern struct memstress_args memstress_args;
 57 
 58 struct kvm_vm *memstress_create_vm(enum vm_guest_mode mode, int nr_vcpus,
 59                                    uint64_t vcpu_memory_bytes, int slots,
 60                                    enum vm_mem_backing_src_type backing_src,
 61                                    bool partition_vcpu_memory_access);
 62 void memstress_destroy_vm(struct kvm_vm *vm);
 63 
 64 void memstress_set_write_percent(struct kvm_vm *vm, uint32_t write_percent);
 65 void memstress_set_random_access(struct kvm_vm *vm, bool random_access);
 66 
 67 void memstress_start_vcpu_threads(int vcpus, void (*vcpu_fn)(struct memstress_vcpu_args *));
 68 void memstress_join_vcpu_threads(int vcpus);
 69 void memstress_guest_code(uint32_t vcpu_id);
 70 
 71 uint64_t memstress_nested_pages(int nr_vcpus);
 72 void memstress_setup_nested(struct kvm_vm *vm, int nr_vcpus, struct kvm_vcpu *vcpus[]);
 73 
 74 void memstress_enable_dirty_logging(struct kvm_vm *vm, int slots);
 75 void memstress_disable_dirty_logging(struct kvm_vm *vm, int slots);
 76 void memstress_get_dirty_log(struct kvm_vm *vm, unsigned long *bitmaps[], int slots);
 77 void memstress_clear_dirty_log(struct kvm_vm *vm, unsigned long *bitmaps[],
 78                                int slots, uint64_t pages_per_slot);
 79 unsigned long **memstress_alloc_bitmaps(int slots, uint64_t pages_per_slot);
 80 void memstress_free_bitmaps(unsigned long *bitmaps[], int slots);
 81 
 82 #endif /* SELFTEST_KVM_MEMSTRESS_H */
 83 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php