Virtual Memory Pre-Paging for Linux

This documents prefetching of virtual memory pages for the Linux OS.

Pre-fetching of pages is a flexible version of asynchronous I/O. An application passes a list of address/extent tuples that specify virtual memory regions to that will be accessed in the near future. The kernel makes a best-effort attempt to bring those pages into physical memory. This has several beneficial effects:

Traditional Unix asynchronous I/O is implemented with an asynchronous read system call which initiates the I/O operation and returns immediately. The process is sent a signal when the operation has completed. Much the same effect can be achieved for reading files by using mmap() and initiating pre-paging for the regions of interest. Drawbacks of this approach are:

API: the programming interface

An application indicates the list of pages to be resolved by making a call to the operating system. The standard Linux C library does not have a wrapper for this system call, so the syscall() interface must be used instead.

The system call arguments are:

#include <unistd.h>
#include <types.h>
#define PREPAGE_MAGIC 42
struct prepage_tuple {
 caddr_t addr;
 size_t extent;
} prepage_list[NR_ELEMENTS];
int retval;
...
 prepage_list[1].addr = 0;
 prepage_list[1].extent = 0;
 retval = syscall(165, PREPAGE_MAGIC, prepage_list);n

Using the Pre-page System Call

This new system call is implemented as a loadable module for the Linux kernel. While this implementation method results in some duplicated code, it greatly simplifies adding this functionality to an already configured system.

To use the module download the C source code and compile it using the compile-command at the bottom of the file. If source file transfers are corrupted by your web browser you may want to use the FTP path to this file, prepage.c instead.

Load the module into the kernel using insmod prepage.o. For system security reasons you must be 'root' to do this. If the module loads successfully, the system call is now available.


Author:Donald Becker, becker@cesdis.gsfc.nasa.gov.
Contact: Phil Merkey, merk@cesdis.gsfc.nasa.gov.
CESDIS.