root/mm/swap.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. swap_setup
  2. buff_setup

   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 
  27 #include <asm/dma.h>
  28 #include <asm/system.h> /* for cli()/sti() */
  29 #include <asm/segment.h> /* for memcpy_to/fromfs */
  30 #include <asm/bitops.h>
  31 #include <asm/pgtable.h>
  32 
  33 /*
  34  * We identify three levels of free memory.  We never let free mem
  35  * fall below the min_free_pages except for atomic allocations.  We
  36  * start background swapping if we fall below free_pages_high free
  37  * pages, and we begin intensive swapping below free_pages_low.
  38  *
  39  * Keep these three variables contiguous for sysctl(2).  
  40  */
  41 int min_free_pages = 20;
  42 int free_pages_low = 30;
  43 int free_pages_high = 40;
  44 
  45 /*
  46  * Constants for the page aging mechanism: the maximum age (actually,
  47  * the maximum "youthfulness"); the quanta by which pages rejuvinate
  48  * and age; and the initial age for new pages. 
  49  */
  50 
  51 swap_control_t swap_control = {
  52         20, 3, 1, 3,            /* Page aging */
  53         10, 2, 2, 4,            /* Buffer aging */
  54         32, 4,                  /* Aging cluster */
  55         8192, 8192,             /* Pageout and bufferout weights */
  56         -200,                   /* Buffer grace */
  57         1, 1,                   /* Buffs/pages to free */
  58         RCL_ROUND_ROBIN         /* Balancing policy */
  59 };
  60 
  61 /* General swap control */
  62 
  63 /* Parse the kernel command line "swap=" option at load time: */
  64 void swap_setup(char *str, int *ints)
     /* [previous][next][first][last][top][bottom][index][help] */
  65 {
  66         int * swap_vars[8] = {
  67                 &MAX_PAGE_AGE,
  68                 &PAGE_ADVANCE,
  69                 &PAGE_DECLINE,
  70                 &PAGE_INITIAL_AGE,
  71                 &AGE_CLUSTER_FRACT,
  72                 &AGE_CLUSTER_MIN,
  73                 &PAGEOUT_WEIGHT,
  74                 &BUFFEROUT_WEIGHT
  75         };
  76         int i;
  77         for (i=0; i < ints[0] && i < 8; i++) {
  78                 if (ints[i+1])
  79                         *(swap_vars[i]) = ints[i+1];
  80         }
  81 }
  82 
  83 /* Parse the kernel command line "buff=" option at load time: */
  84 void buff_setup(char *str, int *ints)
     /* [previous][next][first][last][top][bottom][index][help] */
  85 {
  86         int * buff_vars[6] = {
  87                 &MAX_BUFF_AGE,
  88                 &BUFF_ADVANCE,
  89                 &BUFF_DECLINE,
  90                 &BUFF_INITIAL_AGE,
  91                 &BUFFEROUT_WEIGHT,
  92                 &BUFFERMEM_GRACE
  93         };
  94         int i;
  95         for (i=0; i < ints[0] && i < 6; i++) {
  96                 if (ints[i+1])
  97                         *(buff_vars[i]) = ints[i+1];
  98         }
  99 }
 100 

/* [previous][next][first][last][top][bottom][index][help] */