1/* 2 * linux/mm/swap.c 3 * 4 * Copyright (C) 1991, 1992, 1993, 1994 Linus Torvalds 5 */ 6 7/* 8 * This file contains the default values for the opereation of the 9 * Linux VM subsystem. Fine-tuning documentation can be found in 10 * linux/Documentation/sysctl/vm.txt. 11 * Started 18.12.91 12 * Swap aging added 23.2.95, Stephen Tweedie. 13 * Buffermem limits added 12.3.98, Rik van Riel. 14 */ 15 16#include <linux/mm.h> 17#include <linux/kernel_stat.h> 18#include <linux/swap.h> 19#include <linux/swapctl.h> 20#include <linux/pagemap.h> 21#include <linux/init.h> 22 23#include <asm/dma.h> 24#include <asm/uaccess.h> /* for copy_to/from_user */ 25#include <asm/pgtable.h> 26 27/* 28 * We identify three levels of free memory. We never let free mem 29 * fall below the freepages.min except for atomic allocations. We 30 * start background swapping if we fall below freepages.high free 31 * pages, and we begin intensive swapping below freepages.low. 32 * 33 * These values are there to keep GCC from complaining. Actual 34 * initialization is done in mm/page_alloc.c or arch/sparc(64)/mm/init.c. 35 */ 36freepages_t freepages = { 37 48, /* freepages.min */ 38 96, /* freepages.low */ 39 144 /* freepages.high */ 40}; 41 42/* How many pages do we try to swap or page in/out together? */ 43int page_cluster = 4; /* Default value modified in swap_setup() */ 44 45/* We track the number of pages currently being asynchronously swapped 46 out, so that we don't try to swap TOO many pages out at once */ 47atomic_t nr_async_pages = ATOMIC_INIT(0); 48 49buffer_mem_t buffer_mem = { 50 2, /* minimum percent buffer */ 51 10, /* borrow percent buffer */ 52 60 /* maximum percent buffer */ 53}; 54 55buffer_mem_t page_cache = { 56 2, /* minimum percent page cache */ 57 15, /* borrow percent page cache */ 58 75 /* maximum */ 59}; 60 61pager_daemon_t pager_daemon = { 62 512, /* base number for calculating the number of tries */ 63 SWAP_CLUSTER_MAX, /* minimum number of tries */ 64 SWAP_CLUSTER_MAX, /* do swap I/O in clusters of this size */ 65}; 66 67/* 68 * Perform any setup for the swap system 69 */ 70 71void __init swap_setup(void) 72{ 73 /* Use a smaller cluster for memory <16MB or <32MB */ 74 if (num_physpages < ((16 * 1024 * 1024) >> PAGE_SHIFT)) 75 page_cluster = 2; 76 else if (num_physpages < ((32 * 1024 * 1024) >> PAGE_SHIFT)) 77 page_cluster = 3; 78 else 79 page_cluster = 4; 80} 81

