tools/testing/selftests/kvm/include/test_util.h
Source file repositories/reference/linux-study-clean/tools/testing/selftests/kvm/include/test_util.h
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/kvm/include/test_util.h- Extension
.h- Size
- 6726 bytes
- Lines
- 244
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
setjmp.hsignal.hstdlib.hstdarg.hstdbool.hstdio.hstring.hinttypes.herrno.hunistd.hfcntl.hkselftest.hlinux/mman.hlinux/types.h
Detected Declarations
struct guest_random_statestruct vm_mem_backing_src_aliasenum vm_mem_backing_src_typefunction Copyrightfunction __guest_random_boolfunction guest_random_boolfunction guest_random_u64function memoryfunction backing_src_can_be_hugefunction align_upfunction align_downfunction atoi_positivefunction atoi_non_negative
Annotated Snippet
struct guest_random_state {
u32 seed;
};
extern u32 guest_random_seed;
extern struct guest_random_state guest_rng;
struct guest_random_state new_guest_random_state(u32 seed);
u32 guest_random_u32(struct guest_random_state *state);
static inline bool __guest_random_bool(struct guest_random_state *state,
u8 percent)
{
return (guest_random_u32(state) % 100) < percent;
}
static inline bool guest_random_bool(struct guest_random_state *state)
{
return __guest_random_bool(state, 50);
}
static inline u64 guest_random_u64(struct guest_random_state *state)
{
return ((u64)guest_random_u32(state) << 32) | guest_random_u32(state);
}
enum vm_mem_backing_src_type {
VM_MEM_SRC_ANONYMOUS,
VM_MEM_SRC_ANONYMOUS_THP,
VM_MEM_SRC_ANONYMOUS_HUGETLB,
VM_MEM_SRC_ANONYMOUS_HUGETLB_16KB,
VM_MEM_SRC_ANONYMOUS_HUGETLB_64KB,
VM_MEM_SRC_ANONYMOUS_HUGETLB_512KB,
VM_MEM_SRC_ANONYMOUS_HUGETLB_1MB,
VM_MEM_SRC_ANONYMOUS_HUGETLB_2MB,
VM_MEM_SRC_ANONYMOUS_HUGETLB_8MB,
VM_MEM_SRC_ANONYMOUS_HUGETLB_16MB,
VM_MEM_SRC_ANONYMOUS_HUGETLB_32MB,
VM_MEM_SRC_ANONYMOUS_HUGETLB_256MB,
VM_MEM_SRC_ANONYMOUS_HUGETLB_512MB,
VM_MEM_SRC_ANONYMOUS_HUGETLB_1GB,
VM_MEM_SRC_ANONYMOUS_HUGETLB_2GB,
VM_MEM_SRC_ANONYMOUS_HUGETLB_16GB,
VM_MEM_SRC_SHMEM,
VM_MEM_SRC_SHARED_HUGETLB,
NUM_SRC_TYPES,
};
#define DEFAULT_VM_MEM_SRC VM_MEM_SRC_ANONYMOUS
struct vm_mem_backing_src_alias {
const char *name;
u32 flag;
};
#define MIN_RUN_DELAY_NS 200000UL
bool thp_configured(void);
size_t get_trans_hugepagesz(void);
size_t get_def_hugetlb_pagesz(void);
const struct vm_mem_backing_src_alias *vm_mem_backing_src_alias(u32 i);
size_t get_backing_src_pagesz(u32 i);
bool is_backing_src_hugetlb(u32 i);
void backing_src_help(const char *flag);
enum vm_mem_backing_src_type parse_backing_src_type(const char *type_name);
long get_run_delay(void);
bool is_numa_balancing_enabled(void);
/*
* Whether or not the given source type is shared memory (as opposed to
* anonymous).
*/
static inline bool backing_src_is_shared(enum vm_mem_backing_src_type t)
{
return vm_mem_backing_src_alias(t)->flag & MAP_SHARED;
}
static inline bool backing_src_can_be_huge(enum vm_mem_backing_src_type t)
{
return t != VM_MEM_SRC_ANONYMOUS && t != VM_MEM_SRC_SHMEM;
}
/* Aligns x up to the next multiple of size. Size must be a power of 2. */
static inline u64 align_up(u64 x, u64 size)
{
u64 mask = size - 1;
TEST_ASSERT(size != 0 && !(size & (size - 1)),
"size not a power of 2: %lu", size);
return ((x + mask) & ~mask);
Annotation
- Immediate include surface: `setjmp.h`, `signal.h`, `stdlib.h`, `stdarg.h`, `stdbool.h`, `stdio.h`, `string.h`, `inttypes.h`.
- Detected declarations: `struct guest_random_state`, `struct vm_mem_backing_src_alias`, `enum vm_mem_backing_src_type`, `function Copyright`, `function __guest_random_bool`, `function guest_random_bool`, `function guest_random_u64`, `function memory`, `function backing_src_can_be_huge`, `function align_up`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.