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, int);
47
48
49 extern int try_to_free_page(int, int, 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 extern void swap_after_unlock_page (unsigned long entry);
58
59
60 extern void swap_in(struct task_struct *, struct vm_area_struct *,
61 pte_t *, unsigned long, int);
62
63
64
65 extern void show_swap_cache_info(void);
66 extern int add_to_swap_cache(unsigned long, unsigned long);
67 extern unsigned long init_swap_cache(unsigned long, unsigned long);
68 extern void swap_duplicate(unsigned long);
69
70
71 extern int nr_swapfiles;
72 extern struct swap_info_struct swap_info[];
73 void si_swapinfo(struct sysinfo *);
74 unsigned long get_swap_page(void);
75 extern void swap_free(unsigned long);
76
77
78
79
80
81
82 #define SHM_SWP_TYPE 0x40
83
84
85
86
87
88 #define SWAP_CACHE_INFO
89
90 extern unsigned long * swap_cache;
91
92 #ifdef SWAP_CACHE_INFO
93 extern unsigned long swap_cache_add_total;
94 extern unsigned long swap_cache_add_success;
95 extern unsigned long swap_cache_del_total;
96 extern unsigned long swap_cache_del_success;
97 extern unsigned long swap_cache_find_total;
98 extern unsigned long swap_cache_find_success;
99 #endif
100
101 extern inline unsigned long in_swap_cache(unsigned long index)
102 {
103 return swap_cache[index];
104 }
105
106 extern inline long find_in_swap_cache(unsigned long index)
107 {
108 unsigned long entry;
109
110 #ifdef SWAP_CACHE_INFO
111 swap_cache_find_total++;
112 #endif
113 entry = xchg(swap_cache + index, 0);
114 #ifdef SWAP_CACHE_INFO
115 if (entry)
116 swap_cache_find_success++;
117 #endif
118 return entry;
119 }
120
121 extern inline int delete_from_swap_cache(unsigned long index)
122 {
123 unsigned long entry;
124
125 #ifdef SWAP_CACHE_INFO
126 swap_cache_del_total++;
127 #endif
128 entry = xchg(swap_cache + index, 0);
129 if (entry) {
130 #ifdef SWAP_CACHE_INFO
131 swap_cache_del_success++;
132 #endif
133 swap_free(entry);
134 return 1;
135 }
136 return 0;
137 }
138
139
140 #endif
141
142 #endif