- Revert TCP delayed ACK fix, and fix correctly.
[davej-history.git] / include / linux / swapctl.h
blobcc169d2dab85e4e5871913da9842721a83a2fa62
1 #ifndef _LINUX_SWAPCTL_H
2 #define _LINUX_SWAPCTL_H
4 #include <asm/page.h>
5 #include <linux/fs.h>
7 /* Swap tuning control */
9 typedefstruct swap_control_v6
11 unsigned int sc_max_page_age;
12 unsigned int sc_page_advance;
13 unsigned int sc_page_decline;
14 unsigned int sc_page_initial_age;
15 unsigned int sc_age_cluster_fract;
16 unsigned int sc_age_cluster_min;
17 unsigned int sc_pageout_weight;
18 unsigned int sc_bufferout_weight;
19 } swap_control_v6;
20 typedefstruct swap_control_v6 swap_control_t;
21 extern swap_control_t swap_control;
23 typedefstruct swapstat_v1
25 unsigned int wakeups;
26 unsigned int pages_reclaimed;
27 unsigned int pages_shm;
28 unsigned int pages_mmap;
29 unsigned int pages_swap;
30 } swapstat_v1;
31 typedef swapstat_v1 swapstat_t;
32 extern swapstat_t swapstats;
34 typedefstruct buffer_mem_v1
36 unsigned int min_percent;
37 unsigned int borrow_percent;
38 unsigned int max_percent;
39 } buffer_mem_v1;
40 typedef buffer_mem_v1 buffer_mem_t;
41 extern buffer_mem_t buffer_mem;
43 typedefstruct freepages_v1
45 unsigned int min;
46 unsigned int low;
47 unsigned int high;
48 } freepages_v1;
49 typedef freepages_v1 freepages_t;
50 extern freepages_t freepages;
52 #define SC_VERSION 1
53 #define SC_MAX_VERSION 1
55 #ifdef __KERNEL__
57 /* Define the maximum (least urgent) priority for the page reclaim code */
58 #define RCL_MAXPRI 6
59 /* We use an extra priority in the swap accounting code to represent
60 failure to free a resource at any priority */
61 #define RCL_FAILURE (RCL_MAXPRI + 1)
63 #define AGE_CLUSTER_FRACT (swap_control.sc_age_cluster_fract)
64 #define AGE_CLUSTER_MIN (swap_control.sc_age_cluster_min)
65 #define PAGEOUT_WEIGHT (swap_control.sc_pageout_weight)
66 #define BUFFEROUT_WEIGHT (swap_control.sc_bufferout_weight)
68 /* Page aging (see mm/swap.c) */
70 #define MAX_PAGE_AGE (swap_control.sc_max_page_age)
71 #define PAGE_ADVANCE (swap_control.sc_page_advance)
72 #define PAGE_DECLINE (swap_control.sc_page_decline)
73 #define PAGE_INITIAL_AGE (swap_control.sc_page_initial_age)
75 /* Given a resource of N units (pages or buffers etc), we only try to
76 * age and reclaim AGE_CLUSTER_FRACT per 1024 resources each time we
77 * scan the resource list. */
78 staticinlineintAGE_CLUSTER_SIZE(int resources)
80 unsigned int n = (resources * AGE_CLUSTER_FRACT) >>10;
81 if(n < AGE_CLUSTER_MIN)
82 return AGE_CLUSTER_MIN;
83 else
84 return n;
87 staticinlinevoidtouch_page(struct page *page)
89 if(page->age < (MAX_PAGE_AGE - PAGE_ADVANCE))
90 page->age += PAGE_ADVANCE;
91 else
92 page->age = MAX_PAGE_AGE;
95 staticinlinevoidage_page(struct page *page)
97 if(page->age > PAGE_DECLINE)
98 page->age -= PAGE_DECLINE;
99 else
100 page->age =0;
103 staticinlineintage_of(unsigned long addr)
105 return mem_map[MAP_NR(addr)].age;
108 staticinlinevoidset_page_new(unsigned long addr)
110 mem_map[MAP_NR(addr)].age = PAGE_INITIAL_AGE;
113 #endif/* __KERNEL */
115 #endif/* _LINUX_SWAPCTL_H */
close