linux-old/mm/swap.c
<<
>>
Prefs
   1/*
   2 *  linux/mm/swap.c
   3 *
   4 *  Copyright (C) 1991, 1992, 1993, 1994  Linus Torvalds
   5 */
   6
   7/*
   8 * This file should contain most things doing the swapping from/to disk.
   9 * Started 18.12.91
  10 *
  11 * Swap aging added 23.2.95, Stephen Tweedie.
  12 */
  13
  14#include <linux/mm.h>
  15#include <linux/sched.h>
  16#include <linux/head.h>
  17#include <linux/kernel.h>
  18#include <linux/kernel_stat.h>
  19#include <linux/errno.h>
  20#include <linux/string.h>
  21#include <linux/stat.h>
  22#include <linux/swap.h>
  23#include <linux/fs.h>
  24#include <linux/swapctl.h>
  25#include <linux/pagemap.h>
  26#include <linux/init.h>
  27
  28#include <asm/dma.h>
  29#include <asm/system.h> /* for cli()/sti() */
  30#include <asm/uaccess.h> /* for copy_to/from_user */
  31#include <asm/bitops.h>
  32#include <asm/pgtable.h>
  33
  34/*
  35 * We identify three levels of free memory.  We never let free mem
  36 * fall below the min_free_pages except for atomic allocations.  We
  37 * start background swapping if we fall below free_pages_high free
  38 * pages, and we begin intensive swapping below free_pages_low.
  39 *
  40 * Keep these three variables contiguous for sysctl(2).  
  41 */
  42int min_free_pages = 48;
  43int free_pages_low = 72;
  44int free_pages_high = 96;
  45
  46/* We track the number of pages currently being asynchronously swapped
  47   out, so that we don't try to swap TOO many pages out at once */
  48atomic_t nr_async_pages = ATOMIC_INIT(0);
  49
  50/*
  51 * Constants for the page aging mechanism: the maximum age (actually,
  52 * the maximum "youthfulness"); the quanta by which pages rejuvenate
  53 * and age; and the initial age for new pages. 
  54 */
  55
  56swap_control_t swap_control = {
  57        20, 3, 1, 3,            /* Page aging */
  58        10, 2, 2, 4,            /* Buffer aging */
  59        32, 4,                  /* Aging cluster */
  60        8192, 8192,             /* Pageout and bufferout weights */
  61        -200,                   /* Buffer grace */
  62        1, 1,                   /* Buffs/pages to free */
  63        RCL_ROUND_ROBIN         /* Balancing policy */
  64};
  65
  66swapstat_t swapstats = {0};
  67
  68/* General swap control */
  69
  70/* Parse the kernel command line "swap=" option at load time: */
  71__initfunc(void swap_setup(char *str, int *ints))
  72{
  73        int * swap_vars[8] = {
  74                &MAX_PAGE_AGE,
  75                &PAGE_ADVANCE,
  76                &PAGE_DECLINE,
  77                &PAGE_INITIAL_AGE,
  78                &AGE_CLUSTER_FRACT,
  79                &AGE_CLUSTER_MIN,
  80                &PAGEOUT_WEIGHT,
  81                &BUFFEROUT_WEIGHT
  82        };
  83        int i;
  84        for (i=0; i < ints[0] && i < 8; i++) {
  85                if (ints[i+1])
  86                        *(swap_vars[i]) = ints[i+1];
  87        }
  88}
  89
  90/* Parse the kernel command line "buff=" option at load time: */
  91__initfunc(void buff_setup(char *str, int *ints))
  92{
  93        int * buff_vars[6] = {
  94                &MAX_BUFF_AGE,
  95                &BUFF_ADVANCE,
  96                &BUFF_DECLINE,
  97                &BUFF_INITIAL_AGE,
  98                &BUFFEROUT_WEIGHT,
  99                &BUFFERMEM_GRACE
 100        };
 101        int i;
 102        for (i=0; i < ints[0] && i < 6; i++) {
 103                if (ints[i+1])
 104                        *(buff_vars[i]) = ints[i+1];
 105        }
 106}
 107
 108
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.