Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
mariux64
/
linux
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
2
Pull requests
0
Actions
Projects
0
Wiki
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security
Insights
Files
d8a866c
Documentation
LICENSES
arch
block
certs
crypto
drivers
fs
include
init
io_uring
ipc
kernel
lib
mm
net
rust
samples
scripts
security
sound
tools
accounting
arch
bootconfig
bpf
build
certs
cgroup
counter
crypto
debugging
firewire
firmware
gpio
hv
iio
include
kvm
laptop
leds
lib
memory-model
mm
net
objtool
pcmcia
perf
power
rcu
sched_ext
scripts
sound
spi
testing
crypto
cxl
fault-injection
ktest
kunit
memblock
nvdimm
radix-tree
scatterlist
selftests
acct
alsa
amd-pstate
arm64
bpf
breakpoints
cachestat
capabilities
cgroup
clone3
connector
core
coredump
cpu-hotplug
cpufreq
damon
devices
dma
dmabuf-heaps
drivers
dt
efivarfs
exec
fchmodat2
filelock
filesystems
firmware
fpu
ftrace
futex
gpio
hid
ia64
intel_pstate
iommu
ipc
ir
kcmp
kexec
kmod
kselftest
kvm
landlock
lib
livepatch
lkdtm
locking
lsm
media_tests
membarrier
memfd
memory-hotplug
mincore
mm
page_frag
.gitignore
Makefile
charge_reserved_hugetlb.sh
check_config.sh
compaction_test.c
config
cow.c
droppable.c
guard-regions.c
gup_longterm.c
gup_test.c
hmm-tests.c
hugepage-mmap.c
hugepage-mremap.c
hugepage-shm.c
hugepage-vmemmap.c
hugetlb-madvise.c
hugetlb-read-hwpoison.c
hugetlb-soft-offline.c
hugetlb_dio.c
hugetlb_fault_after_madv.c
hugetlb_madv_vs_map.c
hugetlb_reparenting_test.sh
khugepaged.c
ksm_functional_tests.c
ksm_tests.c
madv_populate.c
map_fixed_noreplace.c
map_hugetlb.c
map_populate.c
mdwe_test.c
memfd_secret.c
migration.c
mkdirty.c
mlock-random-test.c
mlock2-tests.c
mlock2.h
mrelease_test.c
mremap_dontunmap.c
mremap_test.c
mseal_helpers.h
mseal_test.c
on-fault-limit.c
pagemap_ioctl.c
pkey-arm64.h
pkey-helpers.h
pkey-powerpc.h
pkey-x86.h
pkey_sighandler_tests.c
pkey_util.c
protection_keys.c
run_vmtests.sh
settings
soft-dirty.c
split_huge_page_test.c
test_hmm.sh
test_page_frag.sh
test_vmalloc.sh
thp_settings.c
thp_settings.h
thuge-gen.c
transhuge-stress.c
uffd-common.c
uffd-common.h
uffd-stress.c
uffd-unit-tests.c
uffd-wp-mremap.c
va_high_addr_switch.c
va_high_addr_switch.sh
virtual_address_range.c
vm_util.c
vm_util.h
write_hugetlb_memory.sh
write_to_hugetlbfs.c
module
mount
mount_setattr
move_mount_set_group
mqueue
nci
net
nolibc
ntb
openat2
pci_endpoint
pcie_bwctrl
perf_events
pid_namespace
pidfd
power_supply
powerpc
prctl
proc
pstore
ptp
ptrace
rcutorture
resctrl
ring-buffer
riscv
rlimits
rseq
rtc
rust
safesetid
sched
sched_ext
seccomp
sgx
signal
size
sparc64
splice
static_keys
sync
syscall_user_dispatch
sysctl
tc-testing
tdx
thermal
timens
timers
tmpfs
tpm2
tty
turbostat
uevent
user_events
vDSO
watchdog
wireguard
x86
zram
.gitignore
Makefile
gen_kselftest_tar.sh
kselftest.h
kselftest_deps.sh
kselftest_harness.h
kselftest_install.sh
kselftest_module.h
lib.mk
run_kselftest.sh
shared
vma
vsock
thermal
time
tracing
usb
verification
virtio
wmi
workqueue
writeback
Makefile
usr
virt
.clang-format
.clippy.toml
.cocciconfig
.editorconfig
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap
.rustfmt.toml
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS
Makefile
README
Breadcrumbs
linux
/
tools
/
testing
/
selftests
/
mm
/
vm_util.h
Copy path
Blame
Blame
Latest commit
History
History
84 lines (75 loc) · 3.03 KB
Breadcrumbs
linux
/
tools
/
testing
/
selftests
/
mm
/
vm_util.h
Top
File metadata and controls
Code
Blame
84 lines (75 loc) · 3.03 KB
Raw
/* SPDX-License-Identifier: GPL-2.0 */ #include <stdint.h> #include <stdbool.h> #include <sys/mman.h> #include <err.h> #include <strings.h> /* ffsl() */ #include <unistd.h> /* _SC_PAGESIZE */ #include "../kselftest.h" #define BIT_ULL(nr) (1ULL << (nr)) #define PM_SOFT_DIRTY BIT_ULL(55) #define PM_MMAP_EXCLUSIVE BIT_ULL(56) #define PM_UFFD_WP BIT_ULL(57) #define PM_GUARD_REGION BIT_ULL(58) #define PM_FILE BIT_ULL(61) #define PM_SWAP BIT_ULL(62) #define PM_PRESENT BIT_ULL(63) extern unsigned int __page_size; extern unsigned int __page_shift; static inline unsigned int psize(void) { if (!__page_size) __page_size = sysconf(_SC_PAGESIZE); return __page_size; } static inline unsigned int pshift(void) { if (!__page_shift) __page_shift = (ffsl(psize()) - 1); return __page_shift; } /* * Plan 9 FS has bugs (at least on QEMU) where certain operations fail with * ENOENT on unlinked files. See * https://gitlab.com/qemu-project/qemu/-/issues/103 for some info about such * bugs. There are rumours of NFS implementations with similar bugs. * * Ideally, tests should just detect filesystems known to have such issues and * bail early. But 9pfs has the additional "feature" that it causes fstatfs to * pass through the f_type field from the host filesystem. To avoid having to * scrape /proc/mounts or some other hackery, tests can call this function when * it seems such a bug might have been encountered. */ static inline void skip_test_dodgy_fs(const char *op_name) { ksft_test_result_skip("%s failed with ENOENT. Filesystem might be buggy (9pfs?)\n", op_name); } uint64_t pagemap_get_entry(int fd, char *start); bool pagemap_is_softdirty(int fd, char *start); bool pagemap_is_swapped(int fd, char *start); bool pagemap_is_populated(int fd, char *start); unsigned long pagemap_get_pfn(int fd, char *start); void clear_softdirty(void); bool check_for_pattern(FILE *fp, const char *pattern, char *buf, size_t len); uint64_t read_pmd_pagesize(void); unsigned long rss_anon(void); bool check_huge_anon(void *addr, int nr_hpages, uint64_t hpage_size); bool check_huge_file(void *addr, int nr_hpages, uint64_t hpage_size); bool check_huge_shmem(void *addr, int nr_hpages, uint64_t hpage_size); int64_t allocate_transhuge(void *ptr, int pagemap_fd); unsigned long default_huge_page_size(void); int detect_hugetlb_page_sizes(size_t sizes[], int max); int uffd_register(int uffd, void *addr, uint64_t len, bool miss, bool wp, bool minor); int uffd_unregister(int uffd, void *addr, uint64_t len); int uffd_register_with_ioctls(int uffd, void *addr, uint64_t len, bool miss, bool wp, bool minor, uint64_t *ioctls); unsigned long get_free_hugepages(void); bool check_vmflag_io(void *addr); /* * On ppc64 this will only work with radix 2M hugepage size */ #define HPAGE_SHIFT 21 #define HPAGE_SIZE (1 << HPAGE_SHIFT) #define PAGEMAP_PRESENT(ent) (((ent) & (1ull << 63)) != 0) #define PAGEMAP_PFN(ent) ((ent) & ((1ull << 55) - 1))
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
You can’t perform that action at this time.