aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/swap.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/swap.h')
-rw-r--r--include/linux/swap.h79
1 files changed, 48 insertions, 31 deletions
diff --git a/include/linux/swap.h b/include/linux/swap.h
index a3af95b2cb6d..d30215578877 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -120,7 +120,9 @@ struct swap_extent {
120enum { 120enum {
121 SWP_USED = (1 << 0), /* is slot in swap_info[] used? */ 121 SWP_USED = (1 << 0), /* is slot in swap_info[] used? */
122 SWP_WRITEOK = (1 << 1), /* ok to write to this swap? */ 122 SWP_WRITEOK = (1 << 1), /* ok to write to this swap? */
123 SWP_ACTIVE = (SWP_USED | SWP_WRITEOK), 123 SWP_DISCARDABLE = (1 << 2), /* blkdev supports discard */
124 SWP_DISCARDING = (1 << 3), /* now discarding a free cluster */
125 SWP_SOLIDSTATE = (1 << 4), /* blkdev seeks are cheap */
124 /* add others here before... */ 126 /* add others here before... */
125 SWP_SCANNING = (1 << 8), /* refcount in scan_swap_map */ 127 SWP_SCANNING = (1 << 8), /* refcount in scan_swap_map */
126}; 128};
@@ -134,22 +136,24 @@ enum {
134 * The in-memory structure used to track swap areas. 136 * The in-memory structure used to track swap areas.
135 */ 137 */
136struct swap_info_struct { 138struct swap_info_struct {
137 unsigned int flags; 139 unsigned long flags;
138 int prio; /* swap priority */ 140 int prio; /* swap priority */
141 int next; /* next entry on swap list */
139 struct file *swap_file; 142 struct file *swap_file;
140 struct block_device *bdev; 143 struct block_device *bdev;
141 struct list_head extent_list; 144 struct list_head extent_list;
142 struct swap_extent *curr_swap_extent; 145 struct swap_extent *curr_swap_extent;
143 unsigned old_block_size; 146 unsigned short *swap_map;
144 unsigned short * swap_map;
145 unsigned int lowest_bit; 147 unsigned int lowest_bit;
146 unsigned int highest_bit; 148 unsigned int highest_bit;
149 unsigned int lowest_alloc; /* while preparing discard cluster */
150 unsigned int highest_alloc; /* while preparing discard cluster */
147 unsigned int cluster_next; 151 unsigned int cluster_next;
148 unsigned int cluster_nr; 152 unsigned int cluster_nr;
149 unsigned int pages; 153 unsigned int pages;
150 unsigned int max; 154 unsigned int max;
151 unsigned int inuse_pages; 155 unsigned int inuse_pages;
152 int next; /* next entry on swap list */ 156 unsigned int old_block_size;
153}; 157};
154 158
155struct swap_list_t { 159struct swap_list_t {
@@ -163,7 +167,6 @@ struct swap_list_t {
163/* linux/mm/page_alloc.c */ 167/* linux/mm/page_alloc.c */
164extern unsigned long totalram_pages; 168extern unsigned long totalram_pages;
165extern unsigned long totalreserve_pages; 169extern unsigned long totalreserve_pages;
166extern long nr_swap_pages;
167extern unsigned int nr_free_buffer_pages(void); 170extern unsigned int nr_free_buffer_pages(void);
168extern unsigned int nr_free_pagecache_pages(void); 171extern unsigned int nr_free_pagecache_pages(void);
169 172
@@ -174,8 +177,6 @@ extern unsigned int nr_free_pagecache_pages(void);
174/* linux/mm/swap.c */ 177/* linux/mm/swap.c */
175extern void __lru_cache_add(struct page *, enum lru_list lru); 178extern void __lru_cache_add(struct page *, enum lru_list lru);
176extern void lru_cache_add_lru(struct page *, enum lru_list lru); 179extern void lru_cache_add_lru(struct page *, enum lru_list lru);
177extern void lru_cache_add_active_or_unevictable(struct page *,
178 struct vm_area_struct *);
179extern void activate_page(struct page *); 180extern void activate_page(struct page *);
180extern void mark_page_accessed(struct page *); 181extern void mark_page_accessed(struct page *);
181extern void lru_add_drain(void); 182extern void lru_add_drain(void);
@@ -213,7 +214,8 @@ static inline void lru_cache_add_active_file(struct page *page)
213extern unsigned long try_to_free_pages(struct zonelist *zonelist, int order, 214extern unsigned long try_to_free_pages(struct zonelist *zonelist, int order,
214 gfp_t gfp_mask); 215 gfp_t gfp_mask);
215extern unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem, 216extern unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem,
216 gfp_t gfp_mask); 217 gfp_t gfp_mask, bool noswap,
218 unsigned int swappiness);
217extern int __isolate_lru_page(struct page *page, int mode, int file); 219extern int __isolate_lru_page(struct page *page, int mode, int file);
218extern unsigned long shrink_all_memory(unsigned long nr_pages); 220extern unsigned long shrink_all_memory(unsigned long nr_pages);
219extern int vm_swappiness; 221extern int vm_swappiness;
@@ -280,7 +282,7 @@ extern void end_swap_bio_read(struct bio *bio, int err);
280extern struct address_space swapper_space; 282extern struct address_space swapper_space;
281#define total_swapcache_pages swapper_space.nrpages 283#define total_swapcache_pages swapper_space.nrpages
282extern void show_swap_cache_info(void); 284extern void show_swap_cache_info(void);
283extern int add_to_swap(struct page *, gfp_t); 285extern int add_to_swap(struct page *);
284extern int add_to_swap_cache(struct page *, swp_entry_t, gfp_t); 286extern int add_to_swap_cache(struct page *, swp_entry_t, gfp_t);
285extern void __delete_from_swap_cache(struct page *); 287extern void __delete_from_swap_cache(struct page *);
286extern void delete_from_swap_cache(struct page *); 288extern void delete_from_swap_cache(struct page *);
@@ -293,6 +295,7 @@ extern struct page *swapin_readahead(swp_entry_t, gfp_t,
293 struct vm_area_struct *vma, unsigned long addr); 295 struct vm_area_struct *vma, unsigned long addr);
294 296
295/* linux/mm/swapfile.c */ 297/* linux/mm/swapfile.c */
298extern long nr_swap_pages;
296extern long total_swap_pages; 299extern long total_swap_pages;
297extern void si_swapinfo(struct sysinfo *); 300extern void si_swapinfo(struct sysinfo *);
298extern swp_entry_t get_swap_page(void); 301extern swp_entry_t get_swap_page(void);
@@ -300,15 +303,14 @@ extern swp_entry_t get_swap_page_of_type(int);
300extern int swap_duplicate(swp_entry_t); 303extern int swap_duplicate(swp_entry_t);
301extern int valid_swaphandles(swp_entry_t, unsigned long *); 304extern int valid_swaphandles(swp_entry_t, unsigned long *);
302extern void swap_free(swp_entry_t); 305extern void swap_free(swp_entry_t);
303extern void free_swap_and_cache(swp_entry_t); 306extern int free_swap_and_cache(swp_entry_t);
304extern int swap_type_of(dev_t, sector_t, struct block_device **); 307extern int swap_type_of(dev_t, sector_t, struct block_device **);
305extern unsigned int count_swap_pages(int, int); 308extern unsigned int count_swap_pages(int, int);
306extern sector_t map_swap_page(struct swap_info_struct *, pgoff_t); 309extern sector_t map_swap_page(struct swap_info_struct *, pgoff_t);
307extern sector_t swapdev_block(int, pgoff_t); 310extern sector_t swapdev_block(int, pgoff_t);
308extern struct swap_info_struct *get_swap_info_struct(unsigned); 311extern struct swap_info_struct *get_swap_info_struct(unsigned);
309extern int can_share_swap_page(struct page *); 312extern int reuse_swap_page(struct page *);
310extern int remove_exclusive_swap_page(struct page *); 313extern int try_to_free_swap(struct page *);
311extern int remove_exclusive_swap_page_ref(struct page *);
312struct backing_dev_info; 314struct backing_dev_info;
313 315
314/* linux/mm/thrash.c */ 316/* linux/mm/thrash.c */
@@ -332,9 +334,26 @@ static inline void disable_swap_token(void)
332 put_swap_token(swap_token_mm); 334 put_swap_token(swap_token_mm);
333} 335}
334 336
337#ifdef CONFIG_CGROUP_MEM_RES_CTLR
338extern void mem_cgroup_uncharge_swapcache(struct page *page, swp_entry_t ent);
339#else
340static inline void
341mem_cgroup_uncharge_swapcache(struct page *page, swp_entry_t ent)
342{
343}
344#endif
345#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
346extern void mem_cgroup_uncharge_swap(swp_entry_t ent);
347#else
348static inline void mem_cgroup_uncharge_swap(swp_entry_t ent)
349{
350}
351#endif
352
335#else /* CONFIG_SWAP */ 353#else /* CONFIG_SWAP */
336 354
337#define total_swap_pages 0 355#define nr_swap_pages 0L
356#define total_swap_pages 0L
338#define total_swapcache_pages 0UL 357#define total_swapcache_pages 0UL
339 358
340#define si_swapinfo(val) \ 359#define si_swapinfo(val) \
@@ -350,14 +369,8 @@ static inline void show_swap_cache_info(void)
350{ 369{
351} 370}
352 371
353static inline void free_swap_and_cache(swp_entry_t swp) 372#define free_swap_and_cache(swp) is_migration_entry(swp)
354{ 373#define swap_duplicate(swp) is_migration_entry(swp)
355}
356
357static inline int swap_duplicate(swp_entry_t swp)
358{
359 return 0;
360}
361 374
362static inline void swap_free(swp_entry_t swp) 375static inline void swap_free(swp_entry_t swp)
363{ 376{
@@ -374,7 +387,10 @@ static inline struct page *lookup_swap_cache(swp_entry_t swp)
374 return NULL; 387 return NULL;
375} 388}
376 389
377#define can_share_swap_page(p) (page_mapcount(p) == 1) 390static inline int add_to_swap(struct page *page)
391{
392 return 0;
393}
378 394
379static inline int add_to_swap_cache(struct page *page, swp_entry_t entry, 395static inline int add_to_swap_cache(struct page *page, swp_entry_t entry,
380 gfp_t gfp_mask) 396 gfp_t gfp_mask)
@@ -390,14 +406,9 @@ static inline void delete_from_swap_cache(struct page *page)
390{ 406{
391} 407}
392 408
393#define swap_token_default_timeout 0 409#define reuse_swap_page(page) (page_mapcount(page) == 1)
394 410
395static inline int remove_exclusive_swap_page(struct page *p) 411static inline int try_to_free_swap(struct page *page)
396{
397 return 0;
398}
399
400static inline int remove_exclusive_swap_page_ref(struct page *page)
401{ 412{
402 return 0; 413 return 0;
403} 414}
@@ -415,6 +426,12 @@ static inline swp_entry_t get_swap_page(void)
415#define has_swap_token(x) 0 426#define has_swap_token(x) 0
416#define disable_swap_token() do { } while(0) 427#define disable_swap_token() do { } while(0)
417 428
429static inline int mem_cgroup_cache_charge_swapin(struct page *page,
430 struct mm_struct *mm, gfp_t mask, bool locked)
431{
432 return 0;
433}
434
418#endif /* CONFIG_SWAP */ 435#endif /* CONFIG_SWAP */
419#endif /* __KERNEL__*/ 436#endif /* __KERNEL__*/
420#endif /* _LINUX_SWAP_H */ 437#endif /* _LINUX_SWAP_H */