diff options
Diffstat (limited to 'include/linux/swap.h')
-rw-r--r-- | include/linux/swap.h | 79 |
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 { | |||
120 | enum { | 120 | enum { |
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 | */ |
136 | struct swap_info_struct { | 138 | struct 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 | ||
155 | struct swap_list_t { | 159 | struct swap_list_t { |
@@ -163,7 +167,6 @@ struct swap_list_t { | |||
163 | /* linux/mm/page_alloc.c */ | 167 | /* linux/mm/page_alloc.c */ |
164 | extern unsigned long totalram_pages; | 168 | extern unsigned long totalram_pages; |
165 | extern unsigned long totalreserve_pages; | 169 | extern unsigned long totalreserve_pages; |
166 | extern long nr_swap_pages; | ||
167 | extern unsigned int nr_free_buffer_pages(void); | 170 | extern unsigned int nr_free_buffer_pages(void); |
168 | extern unsigned int nr_free_pagecache_pages(void); | 171 | extern 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 */ |
175 | extern void __lru_cache_add(struct page *, enum lru_list lru); | 178 | extern void __lru_cache_add(struct page *, enum lru_list lru); |
176 | extern void lru_cache_add_lru(struct page *, enum lru_list lru); | 179 | extern void lru_cache_add_lru(struct page *, enum lru_list lru); |
177 | extern void lru_cache_add_active_or_unevictable(struct page *, | ||
178 | struct vm_area_struct *); | ||
179 | extern void activate_page(struct page *); | 180 | extern void activate_page(struct page *); |
180 | extern void mark_page_accessed(struct page *); | 181 | extern void mark_page_accessed(struct page *); |
181 | extern void lru_add_drain(void); | 182 | extern void lru_add_drain(void); |
@@ -213,7 +214,8 @@ static inline void lru_cache_add_active_file(struct page *page) | |||
213 | extern unsigned long try_to_free_pages(struct zonelist *zonelist, int order, | 214 | extern unsigned long try_to_free_pages(struct zonelist *zonelist, int order, |
214 | gfp_t gfp_mask); | 215 | gfp_t gfp_mask); |
215 | extern unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem, | 216 | extern 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); | ||
217 | extern int __isolate_lru_page(struct page *page, int mode, int file); | 219 | extern int __isolate_lru_page(struct page *page, int mode, int file); |
218 | extern unsigned long shrink_all_memory(unsigned long nr_pages); | 220 | extern unsigned long shrink_all_memory(unsigned long nr_pages); |
219 | extern int vm_swappiness; | 221 | extern int vm_swappiness; |
@@ -280,7 +282,7 @@ extern void end_swap_bio_read(struct bio *bio, int err); | |||
280 | extern struct address_space swapper_space; | 282 | extern struct address_space swapper_space; |
281 | #define total_swapcache_pages swapper_space.nrpages | 283 | #define total_swapcache_pages swapper_space.nrpages |
282 | extern void show_swap_cache_info(void); | 284 | extern void show_swap_cache_info(void); |
283 | extern int add_to_swap(struct page *, gfp_t); | 285 | extern int add_to_swap(struct page *); |
284 | extern int add_to_swap_cache(struct page *, swp_entry_t, gfp_t); | 286 | extern int add_to_swap_cache(struct page *, swp_entry_t, gfp_t); |
285 | extern void __delete_from_swap_cache(struct page *); | 287 | extern void __delete_from_swap_cache(struct page *); |
286 | extern void delete_from_swap_cache(struct page *); | 288 | extern 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 */ |
298 | extern long nr_swap_pages; | ||
296 | extern long total_swap_pages; | 299 | extern long total_swap_pages; |
297 | extern void si_swapinfo(struct sysinfo *); | 300 | extern void si_swapinfo(struct sysinfo *); |
298 | extern swp_entry_t get_swap_page(void); | 301 | extern swp_entry_t get_swap_page(void); |
@@ -300,15 +303,14 @@ extern swp_entry_t get_swap_page_of_type(int); | |||
300 | extern int swap_duplicate(swp_entry_t); | 303 | extern int swap_duplicate(swp_entry_t); |
301 | extern int valid_swaphandles(swp_entry_t, unsigned long *); | 304 | extern int valid_swaphandles(swp_entry_t, unsigned long *); |
302 | extern void swap_free(swp_entry_t); | 305 | extern void swap_free(swp_entry_t); |
303 | extern void free_swap_and_cache(swp_entry_t); | 306 | extern int free_swap_and_cache(swp_entry_t); |
304 | extern int swap_type_of(dev_t, sector_t, struct block_device **); | 307 | extern int swap_type_of(dev_t, sector_t, struct block_device **); |
305 | extern unsigned int count_swap_pages(int, int); | 308 | extern unsigned int count_swap_pages(int, int); |
306 | extern sector_t map_swap_page(struct swap_info_struct *, pgoff_t); | 309 | extern sector_t map_swap_page(struct swap_info_struct *, pgoff_t); |
307 | extern sector_t swapdev_block(int, pgoff_t); | 310 | extern sector_t swapdev_block(int, pgoff_t); |
308 | extern struct swap_info_struct *get_swap_info_struct(unsigned); | 311 | extern struct swap_info_struct *get_swap_info_struct(unsigned); |
309 | extern int can_share_swap_page(struct page *); | 312 | extern int reuse_swap_page(struct page *); |
310 | extern int remove_exclusive_swap_page(struct page *); | 313 | extern int try_to_free_swap(struct page *); |
311 | extern int remove_exclusive_swap_page_ref(struct page *); | ||
312 | struct backing_dev_info; | 314 | struct 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 | ||
338 | extern void mem_cgroup_uncharge_swapcache(struct page *page, swp_entry_t ent); | ||
339 | #else | ||
340 | static inline void | ||
341 | mem_cgroup_uncharge_swapcache(struct page *page, swp_entry_t ent) | ||
342 | { | ||
343 | } | ||
344 | #endif | ||
345 | #ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP | ||
346 | extern void mem_cgroup_uncharge_swap(swp_entry_t ent); | ||
347 | #else | ||
348 | static 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 | ||
353 | static 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 | |||
357 | static inline int swap_duplicate(swp_entry_t swp) | ||
358 | { | ||
359 | return 0; | ||
360 | } | ||
361 | 374 | ||
362 | static inline void swap_free(swp_entry_t swp) | 375 | static 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) | 390 | static inline int add_to_swap(struct page *page) |
391 | { | ||
392 | return 0; | ||
393 | } | ||
378 | 394 | ||
379 | static inline int add_to_swap_cache(struct page *page, swp_entry_t entry, | 395 | static 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 | ||
395 | static inline int remove_exclusive_swap_page(struct page *p) | 411 | static inline int try_to_free_swap(struct page *page) |
396 | { | ||
397 | return 0; | ||
398 | } | ||
399 | |||
400 | static 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 | ||
429 | static 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 */ |