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/* How many pages do we try to swap or page in/out together? */ 28int page_cluster; 29 30pager_daemon_t pager_daemon = { 31 512, /* base number for calculating the number of tries */ 32 SWAP_CLUSTER_MAX, /* minimum number of tries */ 33 8, /* do swap I/O in clusters of this size */ 34}; 35 36/* 37 * Move an inactive page to the active list. 38 */ 39static inline void activate_page_nolock(struct page * page) 40{ 41 if (PageLRU(page) && !PageActive(page)) { 42 del_page_from_inactive_list(page); 43 add_page_to_active_list(page); 44 KERNEL_STAT_INC(pgactivate); 45 } 46} 47 48void activate_page(struct page * page) 49{ 50 spin_lock(&pagemap_lru_lock); 51 activate_page_nolock(page); 52 spin_unlock(&pagemap_lru_lock); 53} 54 55/** 56 * lru_cache_add: add a page to the page lists 57 * @page: the page to add 58 */ 59void lru_cache_add(struct page * page) 60{ 61 if (!TestSetPageLRU(page)) { 62 spin_lock(&pagemap_lru_lock); 63 add_page_to_inactive_list(page); 64 spin_unlock(&pagemap_lru_lock); 65 } 66} 67 68/** 69 * __lru_cache_del: remove a page from the page lists 70 * @page: the page to add 71 * 72 * This function is for when the caller already holds 73 * the pagemap_lru_lock. 74 */ 75void __lru_cache_del(struct page * page) 76{ 77 if (TestClearPageLRU(page)) { 78 if (PageActive(page)) { 79 del_page_from_active_list(page); 80 } else { 81 del_page_from_inactive_list(page); 82 } 83 } 84} 85 86/** 87 * lru_cache_del: remove a page from the page lists 88 * @page: the page to remove 89 */ 90void lru_cache_del(struct page * page) 91{ 92 spin_lock(&pagemap_lru_lock); 93 __lru_cache_del(page); 94 spin_unlock(&pagemap_lru_lock); 95} 96 97/* 98 * Perform any setup for the swap system 99 */ 100void __init swap_setup(void) 101{ 102 unsigned long megs = num_physpages >> (20 - PAGE_SHIFT); 103 104 /* Use a smaller cluster for small-memory machines */ 105 if (megs < 16) 106 page_cluster = 2; 107 else 108 page_cluster = 3; 109 /* 110 * Right now other parts of the system means that we 111 * _really_ don't want to cluster much more 112 */ 113} 114

