VMTOUCH(8) | System Manager's Manual | VMTOUCH(8) |
vmtouch - the Virtual Memory Toucher
vmtouch [OPTIONS] ... FILES OR DIRECTORIES ...
Portable file system cache diagnostics and control.
vmtouch opens every file provided on the command line and maps it into virtual memory with mmap(2). The mappings are opened read-only. It recursively crawls any directories and does the same to all files it finds within them.
With no options, vmtouch will not read from (touch) any memory pages. It will only use mincore(2) to determine how many pages of each file are actually resident in memory. Before exiting, it will print a summary of the total pages encountered and how many were resident.
Note: Although each page is guaranteed to have been brought into memory, the page might be evicted from memory by the time the vmtouch command completes.
Note: Even if the eviction is successful, pages may be paged back into memory by the time the vmtouch command completes.
Note: This option is not portable to all systems. See PORTABILITY below.
Note: While the vmtouch process is holding memory locks, any processes that access the locked pages will not cause non-resident page faults or address-translation faults although they may still cause TLB misses.
Note: Because vmtouch holds file descriptors open it may reach the "RLIMIT_NOFILE" process file descriptor limit. In this case it will try to increase the descriptor limit which will only work if the process is run with root privileges. Similarly, root privileges are required to exceed the "RLIMIT_MEMLOCK" limit. Even with root privileges, "-l" is limited by both the system file descriptor limit and the system limit on "wired memory".
The page residency summaries depend on mincore(2) which first appeared in 4.4BSD but is not present on all unix systems.
The "-l" and "-L" locking options depends on mlock(2) or mlockall(2), both of which are specified by POSIX.1b-1993, Real-Time Extensions.
The "-e" page eviction option is the least portable. On Linux it uses posix_fadvise(2) with "POSIX_FADV_DONTNEED" advice to inform the kernel that the file should be evicted from the file system cache. posix_fadvise(2) is specified by POSIX.1-2003 TC1. On FreeBSD, the pages are invalidated with msync(2)'s "MS_INVALIDATE" flag. msync(2) is specified by POSIX.1b-1993, Real-Time Extensions, although this call is not required to remove pages from the file system cache. Some systems like OpenBSD 4.3 don't have posix_fadvise(2), don't evict the pages on an msync(2)/"MS_INVALIDATE", and don't evict the pages with madvise(2)/"MADV_DONTNEED" so "-e" isn't supported on those systems yet. Using "-e" on systems that don't yet support it is a fatal error.
All vmtouch features have been confirmed to work on the following systems:
Systems that support everything except eviction:
CPUs that have been tested:
We would like to support as many systems as possible so please send us any success reports, failure reports or patches. Thanks!
Shane Seymour did the HP-UX port and says that either 32-bit or 64-bit binaries can be compiled (just use "+DD64" for 64-bit). However, mincore(2) was added to HP-UX 11.31 via patches and at least the following patches need to be installed: PHKL_38651, PHKL_38708, PHKL_38686, PHKL_38688, and PHCO_38658 (or patches that supersede those ones).
Not all the following manual pages may exist in every unix dialect to which vmtouch has been ported.
vmstat(8), touch(1), mmap(2), mincore(2), mlock(2), mlockall(2), msync(2), madvise(2), posix_fadvise(2)
Written by Doug Hoyte <doug@hcsw.org>
2021-01-11 |