This source file includes following definitions.
- in_swap_cache
- find_in_swap_cache
- delete_from_swap_cache
1 #ifndef _LINUX_SWAP_H
2 #define _LINUX_SWAP_H
3
4 #define SWAP_FLAG_PREFER 0x8000
5 #define SWAP_FLAG_PRIO_MASK 0x7fff
6 #define SWAP_FLAG_PRIO_SHIFT 0
7
8 #define MAX_SWAPFILES 8
9
10 #ifdef __KERNEL__
11
12 #define SWP_USED 1
13 #define SWP_WRITEOK 3
14
15 #define SWAP_CLUSTER_MAX 32
16
17 struct swap_info_struct {
18 unsigned int flags;
19 kdev_t swap_device;
20 struct inode * swap_file;
21 unsigned char * swap_map;
22 unsigned char * swap_lockmap;
23 int lowest_bit;
24 int highest_bit;
25 int cluster_next;
26 int cluster_nr;
27 int prio;
28 int pages;
29 unsigned long max;
30 int next;
31 };
32
33 extern int nr_swap_pages;
34 extern int nr_free_pages;
35 extern int nr_async_pages;
36 extern int min_free_pages;
37 extern int free_pages_low;
38 extern int free_pages_high;
39
40
41 struct task_struct;
42 struct vm_area_struct;
43 struct sysinfo;
44
45
46 extern int shm_swap (int, unsigned long);
47
48
49 extern int try_to_free_page(int, unsigned long, int);
50
51
52 extern void rw_swap_page(int, unsigned long, char *, int);
53 #define read_swap_page(nr,buf) \
54 rw_swap_page(READ,(nr),(buf),1)
55 #define write_swap_page(nr,buf) \
56 rw_swap_page(WRITE,(nr),(buf),1)
57
58
59 extern void swap_in(struct task_struct *, struct vm_area_struct *,
60 pte_t *, unsigned long, int);
61
62
63
64 extern void show_swap_cache_info(void);
65 extern int add_to_swap_cache(unsigned long, unsigned long);
66 extern unsigned long init_swap_cache(unsigned long, unsigned long);
67 extern void swap_duplicate(unsigned long);
68
69
70 extern int nr_swapfiles;
71 extern struct swap_info_struct swap_info[];
72 void si_swapinfo(struct sysinfo *);
73 unsigned long get_swap_page(void);
74 extern void swap_free(unsigned long);
75
76
77
78
79
80
81 #define SHM_SWP_TYPE 0x40
82
83
84
85
86
87 #define SWAP_CACHE_INFO
88
89 extern unsigned long * swap_cache;
90
91 #ifdef SWAP_CACHE_INFO
92 extern unsigned long swap_cache_add_total;
93 extern unsigned long swap_cache_add_success;
94 extern unsigned long swap_cache_del_total;
95 extern unsigned long swap_cache_del_success;
96 extern unsigned long swap_cache_find_total;
97 extern unsigned long swap_cache_find_success;
98 #endif
99
100 extern inline unsigned long in_swap_cache(unsigned long addr)
101 {
102 return swap_cache[MAP_NR(addr)];
103 }
104
105 extern inline long find_in_swap_cache (unsigned long addr)
106 {
107 unsigned long entry;
108
109 #ifdef SWAP_CACHE_INFO
110 swap_cache_find_total++;
111 #endif
112 entry = xchg(swap_cache + MAP_NR(addr), 0);
113 #ifdef SWAP_CACHE_INFO
114 if (entry)
115 swap_cache_find_success++;
116 #endif
117 return entry;
118 }
119
120 extern inline int delete_from_swap_cache(unsigned long addr)
121 {
122 unsigned long entry;
123
124 #ifdef SWAP_CACHE_INFO
125 swap_cache_del_total++;
126 #endif
127 entry= xchg(swap_cache + MAP_NR(addr), 0);
128 if (entry) {
129 #ifdef SWAP_CACHE_INFO
130 swap_cache_del_success++;
131 #endif
132 swap_free(entry);
133 return 1;
134 }
135 return 0;
136 }
137
138
139 #endif
140
141 #endif