This source file includes following definitions.
- AGE_CLUSTER_SIZE
- touch_page
- age_page
- age_of
- set_page_new
1 #ifndef _LINUX_SWAPCTL_H
2 #define _LINUX_SWAPCTL_H
3
4 #include <asm/page.h>
5 #include <linux/fs.h>
6
7
8
9
10 enum RCL_POLICY {RCL_ROUND_ROBIN, RCL_BUFF_FIRST, RCL_PERSIST};
11
12 typedef struct swap_control_v5
13 {
14 int sc_max_page_age;
15 int sc_page_advance;
16 int sc_page_decline;
17 int sc_page_initial_age;
18 int sc_max_buff_age;
19 int sc_buff_advance;
20 int sc_buff_decline;
21 int sc_buff_initial_age;
22 int sc_age_cluster_fract;
23 int sc_age_cluster_min;
24 int sc_pageout_weight;
25 int sc_bufferout_weight;
26 int sc_buffer_grace;
27 int sc_nr_buffs_to_free;
28 int sc_nr_pages_to_free;
29 enum RCL_POLICY sc_policy;
30 } swap_control_v5;
31 typedef struct swap_control_v5 swap_control_t;
32 extern swap_control_t swap_control;
33
34 typedef struct kswapd_control_v1
35 {
36 int maxpages;
37 int pages_buff;
38 int pages_shm;
39 int pages_mmap;
40 int pages_swap;
41 } kswapd_control_v1;
42 typedef kswapd_control_v1 kswapd_control_t;
43 extern kswapd_control_t kswapd_ctl;
44
45 typedef struct swapstat_v1
46 {
47 int wakeups;
48 int pages_reclaimed;
49 int pages_shm;
50 int pages_mmap;
51 int pages_swap;
52 } swapstat_v1;
53 typedef swapstat_v1 swapstat_t;
54 extern swapstat_t swapstats;
55
56 extern int min_free_pages, free_pages_low, free_pages_high;
57
58 #define SC_VERSION 1
59 #define SC_MAX_VERSION 1
60
61 #ifdef __KERNEL__
62
63
64 #define RCL_MAXPRI 6
65
66
67 #define RCL_FAILURE (RCL_MAXPRI + 1)
68
69 #define RCL_POLICY (swap_control.sc_policy)
70 #define AGE_CLUSTER_FRACT (swap_control.sc_age_cluster_fract)
71 #define AGE_CLUSTER_MIN (swap_control.sc_age_cluster_min)
72 #define PAGEOUT_WEIGHT (swap_control.sc_pageout_weight)
73 #define BUFFEROUT_WEIGHT (swap_control.sc_bufferout_weight)
74
75 #define NR_BUFFS_TO_FREE (swap_control.sc_nr_buffs_to_free)
76 #define NR_PAGES_TO_FREE (swap_control.sc_nr_pages_to_free)
77
78 #define BUFFERMEM_GRACE (swap_control.sc_buffer_grace)
79
80
81
82 #define MAX_PAGE_AGE (swap_control.sc_max_page_age)
83 #define PAGE_ADVANCE (swap_control.sc_page_advance)
84 #define PAGE_DECLINE (swap_control.sc_page_decline)
85 #define PAGE_INITIAL_AGE (swap_control.sc_page_initial_age)
86
87 #define MAX_BUFF_AGE (swap_control.sc_max_buff_age)
88 #define BUFF_ADVANCE (swap_control.sc_buff_advance)
89 #define BUFF_DECLINE (swap_control.sc_buff_decline)
90 #define BUFF_INITIAL_AGE (swap_control.sc_buff_initial_age)
91
92
93
94
95 static inline int AGE_CLUSTER_SIZE(int resources)
96 {
97 int n = (resources * AGE_CLUSTER_FRACT) >> 10;
98 if (n < AGE_CLUSTER_MIN)
99 return AGE_CLUSTER_MIN;
100 else
101 return n;
102 }
103
104 static inline void touch_page(struct page *page)
105 {
106 if (page->age < (MAX_PAGE_AGE - PAGE_ADVANCE))
107 page->age += PAGE_ADVANCE;
108 else
109 page->age = MAX_PAGE_AGE;
110 }
111
112 static inline void age_page(struct page *page)
113 {
114 if (page->age > PAGE_DECLINE)
115 page->age -= PAGE_DECLINE;
116 else
117 page->age = 0;
118 }
119
120 static inline int age_of(unsigned long addr)
121 {
122 return mem_map[MAP_NR(addr)].age;
123 }
124
125 static inline void set_page_new(unsigned long addr)
126 {
127 mem_map[MAP_NR(addr)].age = PAGE_INITIAL_AGE;
128 }
129
130 #endif
131
132 #endif