-
Notifications
You must be signed in to change notification settings - Fork 0
Bring back swapped out pages into memory.
License
clickyotomy/de-swap
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
de-swap ------- Bring back swapped out pages into memory. The program works by performing a read operation (which forces a "swap-in") on a region of memory that has been paged out to swap. In most cases, it is unnecessary to run this, because the kernel knows what it's doing. However, if there is a really good reason to (quicky) force "swapped-out" pages of a specific process back into memory, `de-swap' is faster compared to running `swapoff', because it tries to "swap-in" everything. Before running the program (requires superuser privileges), it is probably a good idea verify that there is enough memory. If there isn't enough "free" memory to swap into, `oom-kill' will likely be triggered. Note that the "swapped-in" pages will not be cleared from the swap space because after the pages have been brought back into memory they are "SwapCached" [2], to avoid extra I/O (if) when they have to be paged out again. The regions of memory that have been swapped out can be fetched by parsing "/proc/<PID>/smaps" for a process. The process's virtual address space (its memory) [2] can then be accessed via by reading its "/proc/<PID>/mem" file. By "seek()"-ing to an offset obtained by parsing "/proc<PID>/smaps" (the "paged-out-to-swap" regions), and making a "read()" operation will bring them back to memory. For more information, the answers and comments in this [3] thread are quite helpful. "Deactivating a Swap Area (11.9)" [4], describes how the swap area is freed in good detail. BUILD To generate the binary, run: make GOOS="linux" [GOARCH="<arch>"] USAGE de-swap -p <pid> [-n -j <threads> -r <bytes> -v[v]] ARGUMENTS -p PID of the process to swap-in -n no-op mode; turned off by default -j number of parallel operations; runs as a single thread if unspecified -r split memory regions with large swap areas into smaller regions for better throughput during reads; disabled if set to 0, and if enabled it must be > 0 and in exponents of 2; defaults to 64 kB if unspecified -v[v] output verbosity; off by default REFERENCE [1]: https://www.kernel.org/doc/Documentation/sysctl/vm.txt [2]: https://www.kernel.org/doc/Documentation/filesystems/proc.txt [3]: https://unix.stackexchange.com/questions/45673 [4]: https://www.kernel.org/doc/gorman/html/understand/understand014.html
About
Bring back swapped out pages into memory.