Is it possible to generate major page faults in the linux kernel at will? Can a program be written such that it is guaranteed to cause a major page fault on it's execution. 
Generate major page faults
kernel;memory;virtual memory
To produce major page faults you need to force reads from disk. The following code maps the file given on the command-line, telling the kernel it doesn't need it; if the file is large enough (pick a large file in /usr/bin), you'll always get major page faults:#include <fcntl.h>#include <stdio.h>#include <sys/mman.h>#include <sys/stat.h>int main(int argc, char ** argv) {  int fd = open(argv[1], O_RDONLY);  struct stat stats;  fstat(fd, &stats);  posix_fadvise(fd, 0, stats.st_size, POSIX_FADV_DONTNEED);  char * map = (char *) mmap(NULL, stats.st_size, PROT_READ, MAP_SHARED, fd, 0);  if (map == MAP_FAILED) {    perror(Failed to mmap);    return 1;  }  int result = 0;  int i;  for (i = 0; i < stats.st_size; i++) {    result += map[i];  }  munmap(map, stats.st_size);  return result;}There isn't much in the way of error handling, this is just to demonstrate the idea. On my system,gcc majorfault.c -o majorfault && /usr/bin/time -v ./majorfault /usr/bin/git-annexalways produces 154 major page faults.