143
144
SWP_USED = (1 << 0), /* is slot in swap_info[] used? */
144
145
SWP_WRITEOK = (1 << 1), /* ok to write to this swap? */
145
SWP_DISCARDABLE = (1 << 2), /* blkdev supports discard */
146
SWP_DISCARDABLE = (1 << 2), /* swapon+blkdev support discard */
146
147
SWP_DISCARDING = (1 << 3), /* now discarding a free cluster */
147
148
SWP_SOLIDSTATE = (1 << 4), /* blkdev seeks are cheap */
149
SWP_CONTINUED = (1 << 5), /* swap_map has count continuation */
150
SWP_BLKDEV = (1 << 6), /* its a block device */
148
151
/* add others here before... */
149
152
SWP_SCANNING = (1 << 8), /* refcount in scan_swap_map */
152
155
#define SWAP_CLUSTER_MAX 32
154
#define SWAP_MAP_MAX 0x7ffe
155
#define SWAP_MAP_BAD 0x7fff
156
#define SWAP_HAS_CACHE 0x8000 /* There is a swap cache of entry. */
157
#define SWAP_COUNT_MASK (~SWAP_HAS_CACHE)
156
#define COMPACT_CLUSTER_MAX SWAP_CLUSTER_MAX
158
#define SWAP_MAP_MAX 0x3e /* Max duplication count, in first swap_map */
159
#define SWAP_MAP_BAD 0x3f /* Note pageblock is bad, in first swap_map */
160
#define SWAP_HAS_CACHE 0x40 /* Flag page is cached, in first swap_map */
161
#define SWAP_CONT_MAX 0x7f /* Max count, in each swap_map continuation */
162
#define COUNT_CONTINUED 0x80 /* See swap_map continuation for full count */
163
#define SWAP_MAP_SHMEM 0xbf /* Owned by shmem/tmpfs, in first swap_map */
159
166
* The in-memory structure used to track swap areas.
161
168
struct swap_info_struct {
163
int prio; /* swap priority */
164
int next; /* next entry on swap list */
165
struct file *swap_file;
166
struct block_device *bdev;
167
struct list_head extent_list;
168
struct swap_extent *curr_swap_extent;
169
unsigned short *swap_map;
170
unsigned int lowest_bit;
171
unsigned int highest_bit;
169
unsigned long flags; /* SWP_USED etc: see above */
170
signed short prio; /* swap priority of this type */
171
signed char type; /* strange name for an index */
172
signed char next; /* next type on the swap list */
173
unsigned int max; /* extent of the swap_map */
174
unsigned char *swap_map; /* vmalloc'ed array of usage counts */
175
unsigned int lowest_bit; /* index of first free in swap_map */
176
unsigned int highest_bit; /* index of last free in swap_map */
177
unsigned int pages; /* total of usable pages of swap */
178
unsigned int inuse_pages; /* number of those currently in use */
179
unsigned int cluster_next; /* likely index for next allocation */
180
unsigned int cluster_nr; /* countdown to next cluster search */
172
181
unsigned int lowest_alloc; /* while preparing discard cluster */
173
182
unsigned int highest_alloc; /* while preparing discard cluster */
174
unsigned int cluster_next;
175
unsigned int cluster_nr;
178
unsigned int inuse_pages;
179
unsigned int old_block_size;
183
struct swap_extent *curr_swap_extent;
184
struct swap_extent first_swap_extent;
185
struct block_device *bdev; /* swap device or bdev of swap file */
186
struct file *swap_file; /* seldom referenced */
187
unsigned int old_block_size; /* seldom referenced */
182
190
struct swap_list_t {
200
208
/* linux/mm/swap.c */
201
209
extern void __lru_cache_add(struct page *, enum lru_list lru);
202
210
extern void lru_cache_add_lru(struct page *, enum lru_list lru);
211
extern void lru_add_page_tail(struct zone* zone,
212
struct page *page, struct page *page_tail);
203
213
extern void activate_page(struct page *);
204
214
extern void mark_page_accessed(struct page *);
205
215
extern void lru_add_drain(void);
218
228
__lru_cache_add(page, LRU_INACTIVE_ANON);
221
static inline void lru_cache_add_active_anon(struct page *page)
223
__lru_cache_add(page, LRU_ACTIVE_ANON);
226
231
static inline void lru_cache_add_file(struct page *page)
228
233
__lru_cache_add(page, LRU_INACTIVE_FILE);
231
static inline void lru_cache_add_active_file(struct page *page)
233
__lru_cache_add(page, LRU_ACTIVE_FILE);
236
/* LRU Isolation modes. */
237
#define ISOLATE_INACTIVE 0 /* Isolate inactive pages. */
238
#define ISOLATE_ACTIVE 1 /* Isolate active pages. */
239
#define ISOLATE_BOTH 2 /* Isolate both active and inactive pages. */
236
241
/* linux/mm/vmscan.c */
237
242
extern unsigned long try_to_free_pages(struct zonelist *zonelist, int order,
269
273
extern unsigned long scan_unevictable_pages;
270
274
extern int scan_unevictable_handler(struct ctl_table *, int,
271
275
void __user *, size_t *, loff_t *);
272
277
extern int scan_unevictable_register_node(struct node *node);
273
278
extern void scan_unevictable_unregister_node(struct node *node);
280
static inline int scan_unevictable_register_node(struct node *node)
284
static inline void scan_unevictable_unregister_node(struct node *node)
275
289
extern int kswapd_run(int nid);
290
extern void kswapd_stop(int nid);
277
292
#ifdef CONFIG_MMU
278
293
/* linux/mm/shmem.c */
279
294
extern int shmem_unuse(swp_entry_t entry, struct page *page);
280
295
#endif /* CONFIG_MMU */
297
#ifdef CONFIG_CGROUP_MEM_RES_CTLR
298
extern void mem_cgroup_get_shmem_target(struct inode *inode, pgoff_t pgoff,
299
struct page **pagep, swp_entry_t *ent);
282
302
extern void swap_unplug_io_fn(struct backing_dev_info *, struct page *);
284
304
#ifdef CONFIG_SWAP
309
329
extern void si_swapinfo(struct sysinfo *);
310
330
extern swp_entry_t get_swap_page(void);
311
331
extern swp_entry_t get_swap_page_of_type(int);
312
extern void swap_duplicate(swp_entry_t);
332
extern int valid_swaphandles(swp_entry_t, unsigned long *);
333
extern int add_swap_count_continuation(swp_entry_t, gfp_t);
334
extern void swap_shmem_alloc(swp_entry_t);
335
extern int swap_duplicate(swp_entry_t);
313
336
extern int swapcache_prepare(swp_entry_t);
314
extern int valid_swaphandles(swp_entry_t, unsigned long *);
315
337
extern void swap_free(swp_entry_t);
316
338
extern void swapcache_free(swp_entry_t, struct page *page);
317
339
extern int free_swap_and_cache(swp_entry_t);
318
340
extern int swap_type_of(dev_t, sector_t, struct block_device **);
319
341
extern unsigned int count_swap_pages(int, int);
320
extern sector_t map_swap_page(struct swap_info_struct *, pgoff_t);
342
extern sector_t map_swap_page(struct page *, struct block_device **);
321
343
extern sector_t swapdev_block(int, pgoff_t);
322
extern struct swap_info_struct *get_swap_info_struct(unsigned);
323
344
extern int reuse_swap_page(struct page *);
324
345
extern int try_to_free_swap(struct page *);
325
346
struct backing_dev_info;