4 * Copyright (C) 1991, 1992, 1993, 1994 Linus Torvalds
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.
12 * Swap aging added 23.2.95, Stephen Tweedie.
13 * Buffermem limits added 12.3.98, Rik van Riel.
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>
24 #include <asm/uaccess.h> /* for copy_to/from_user */
25 #include <asm/pgtable.h>
27 /* How many pages do we try to swap or page in/out together? */
30 pager_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 */
37 * Move an inactive page to the active list.
39 static inline void activate_page_nolock(struct page * page)
41 if (PageLRU(page) && !PageActive(page)) {
42 del_page_from_inactive_list(page);
43 add_page_to_active_list(page);
47 void fastcall activate_page(struct page * page)
49 spin_lock(&pagemap_lru_lock);
50 activate_page_nolock(page);
51 spin_unlock(&pagemap_lru_lock);
55 * lru_cache_add: add a page to the page lists
56 * @page: the page to add
58 void fastcall lru_cache_add(struct page * page)
61 spin_lock(&pagemap_lru_lock);
62 if (!TestSetPageLRU(page))
63 add_page_to_inactive_list(page);
64 spin_unlock(&pagemap_lru_lock);
69 * __lru_cache_del: remove a page from the page lists
70 * @page: the page to add
72 * This function is for when the caller already holds
73 * the pagemap_lru_lock.
75 void fastcall __lru_cache_del(struct page * page)
77 if (TestClearPageLRU(page)) {
78 if (PageActive(page)) {
79 del_page_from_active_list(page);
81 del_page_from_inactive_list(page);
87 * lru_cache_del: remove a page from the page lists
88 * @page: the page to remove
90 void fastcall lru_cache_del(struct page * page)
92 spin_lock(&pagemap_lru_lock);
93 __lru_cache_del(page);
94 spin_unlock(&pagemap_lru_lock);
98 * delta_nr_active_pages: alter the number of active pages.
100 * @page: the page which is being activated/deactivated
101 * @delta: +1 for activation, -1 for deactivation
103 * Called under pagecache_lock
105 void delta_nr_active_pages(struct page *page, long delta)
108 zone_t *classzone, *overflow;
110 classzone = page_zone(page);
111 pgdat = classzone->zone_pgdat;
112 overflow = pgdat->node_zones + pgdat->nr_zones;
114 while (classzone < overflow) {
115 classzone->nr_active_pages += delta;
118 nr_active_pages += delta;
122 * delta_nr_inactive_pages: alter the number of inactive pages.
124 * @page: the page which is being deactivated/activated
125 * @delta: +1 for deactivation, -1 for activation
127 * Called under pagecache_lock
129 void delta_nr_inactive_pages(struct page *page, long delta)
132 zone_t *classzone, *overflow;
134 classzone = page_zone(page);
135 pgdat = classzone->zone_pgdat;
136 overflow = pgdat->node_zones + pgdat->nr_zones;
138 while (classzone < overflow) {
139 classzone->nr_inactive_pages += delta;
142 nr_inactive_pages += delta;
146 * delta_nr_cache_pages: alter the number of pages in the pagecache
148 * @page: the page which is being added/removed
149 * @delta: +1 for addition, -1 for removal
151 * Called under pagecache_lock
153 void delta_nr_cache_pages(struct page *page, long delta)
156 zone_t *classzone, *overflow;
158 classzone = page_zone(page);
159 pgdat = classzone->zone_pgdat;
160 overflow = pgdat->node_zones + pgdat->nr_zones;
162 while (classzone < overflow) {
163 classzone->nr_cache_pages += delta;
166 page_cache_size += delta;
170 * Perform any setup for the swap system
172 void __init swap_setup(void)
174 unsigned long megs = num_physpages >> (20 - PAGE_SHIFT);
176 /* Use a smaller cluster for small-memory machines */
182 * Right now other parts of the system means that we
183 * _really_ don't want to cluster much more