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 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 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 __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 lru_cache_del(struct page * page)
92 spin_lock(&pagemap_lru_lock);
93 __lru_cache_del(page);
94 spin_unlock(&pagemap_lru_lock);
98 * Perform any setup for the swap system
100 void __init swap_setup(void)
102 unsigned long megs = num_physpages >> (20 - PAGE_SHIFT);
104 /* Use a smaller cluster for small-memory machines */
110 * Right now other parts of the system means that we
111 * _really_ don't want to cluster much more