vmscan: fix it to take care of nodemask
[safe/jmp/linux-2.6] / include / linux / swap.h
index 893096e..b8b0c4c 100644 (file)
@@ -1,16 +1,21 @@
 #ifndef _LINUX_SWAP_H
 #define _LINUX_SWAP_H
 
-#include <linux/config.h>
 #include <linux/spinlock.h>
 #include <linux/linkage.h>
 #include <linux/mmzone.h>
 #include <linux/list.h>
+#include <linux/memcontrol.h>
 #include <linux/sched.h>
+#include <linux/node.h>
 
 #include <asm/atomic.h>
 #include <asm/page.h>
 
+struct notifier_block;
+
+struct bio;
+
 #define SWAP_FLAG_PREFER       0x8000  /* set if swap priority specified */
 #define SWAP_FLAG_PRIO_MASK    0x7fff
 #define SWAP_FLAG_PRIO_SHIFT   0
@@ -29,7 +34,14 @@ static inline int current_is_kswapd(void)
  * the type/offset into the pte as 5/27 as well.
  */
 #define MAX_SWAPFILES_SHIFT    5
+#ifndef CONFIG_MIGRATION
 #define MAX_SWAPFILES          (1 << MAX_SWAPFILES_SHIFT)
+#else
+/* Use last two entries for page migration swap entries */
+#define MAX_SWAPFILES          ((1 << MAX_SWAPFILES_SHIFT)-2)
+#define SWP_MIGRATION_READ     MAX_SWAPFILES
+#define SWP_MIGRATION_WRITE    (MAX_SWAPFILES + 1)
+#endif
 
 /*
  * Magic header for a swap area. The first part of the union is
@@ -49,12 +61,14 @@ union swap_header {
                char magic[10];                 /* SWAP-SPACE or SWAPSPACE2 */
        } magic;
        struct {
-               char         bootbits[1024];    /* Space for disklabel etc. */
-               unsigned int version;
-               unsigned int last_page;
-               unsigned int nr_badpages;
-               unsigned int padding[125];
-               unsigned int badpages[1];
+               char            bootbits[1024]; /* Space for disklabel etc. */
+               __u32           version;
+               __u32           last_page;
+               __u32           nr_badpages;
+               unsigned char   sws_uuid[16];
+               unsigned char   sws_volume[16];
+               __u32           padding[117];
+               __u32           badpages[1];
        } info;
 };
 
@@ -106,7 +120,9 @@ struct swap_extent {
 enum {
        SWP_USED        = (1 << 0),     /* is slot in swap_info[] used? */
        SWP_WRITEOK     = (1 << 1),     /* ok to write to this swap?    */
-       SWP_ACTIVE      = (SWP_USED | SWP_WRITEOK),
+       SWP_DISCARDABLE = (1 << 2),     /* blkdev supports discard */
+       SWP_DISCARDING  = (1 << 3),     /* now discarding a free cluster */
+       SWP_SOLIDSTATE  = (1 << 4),     /* blkdev seeks are cheap */
                                        /* add others here before... */
        SWP_SCANNING    = (1 << 8),     /* refcount in scan_swap_map */
 };
@@ -120,22 +136,24 @@ enum {
  * The in-memory structure used to track swap areas.
  */
 struct swap_info_struct {
-       unsigned int flags;
+       unsigned long flags;
        int prio;                       /* swap priority */
+       int next;                       /* next entry on swap list */
        struct file *swap_file;
        struct block_device *bdev;
        struct list_head extent_list;
        struct swap_extent *curr_swap_extent;
-       unsigned old_block_size;
-       unsigned short * swap_map;
+       unsigned short *swap_map;
        unsigned int lowest_bit;
        unsigned int highest_bit;
+       unsigned int lowest_alloc;      /* while preparing discard cluster */
+       unsigned int highest_alloc;     /* while preparing discard cluster */
        unsigned int cluster_next;
        unsigned int cluster_nr;
        unsigned int pages;
        unsigned int max;
        unsigned int inuse_pages;
-       int next;                       /* next entry on swap list */
+       unsigned int old_block_size;
 };
 
 struct swap_list_t {
@@ -146,39 +164,106 @@ struct swap_list_t {
 /* Swap 50% full? Release swapcache more aggressively.. */
 #define vm_swap_full() (nr_swap_pages*2 < total_swap_pages)
 
-/* linux/mm/oom_kill.c */
-extern void out_of_memory(gfp_t gfp_mask, int order);
-
-/* linux/mm/memory.c */
-extern void swapin_readahead(swp_entry_t, unsigned long, struct vm_area_struct *);
-
 /* linux/mm/page_alloc.c */
 extern unsigned long totalram_pages;
-extern unsigned long totalhigh_pages;
-extern long nr_swap_pages;
-extern unsigned int nr_free_pages(void);
-extern unsigned int nr_free_pages_pgdat(pg_data_t *pgdat);
+extern unsigned long totalreserve_pages;
 extern unsigned int nr_free_buffer_pages(void);
 extern unsigned int nr_free_pagecache_pages(void);
 
+/* Definition of global_page_state not available yet */
+#define nr_free_pages() global_page_state(NR_FREE_PAGES)
+
+
 /* linux/mm/swap.c */
-extern void FASTCALL(lru_cache_add(struct page *));
-extern void FASTCALL(lru_cache_add_active(struct page *));
-extern void FASTCALL(activate_page(struct page *));
-extern void FASTCALL(mark_page_accessed(struct page *));
+extern void __lru_cache_add(struct page *, enum lru_list lru);
+extern void lru_cache_add_lru(struct page *, enum lru_list lru);
+extern void activate_page(struct page *);
+extern void mark_page_accessed(struct page *);
 extern void lru_add_drain(void);
-extern int rotate_reclaimable_page(struct page *page);
+extern int lru_add_drain_all(void);
+extern void rotate_reclaimable_page(struct page *page);
 extern void swap_setup(void);
 
+extern void add_page_to_unevictable_list(struct page *page);
+
+/**
+ * lru_cache_add: add a page to the page lists
+ * @page: the page to add
+ */
+static inline void lru_cache_add_anon(struct page *page)
+{
+       __lru_cache_add(page, LRU_INACTIVE_ANON);
+}
+
+static inline void lru_cache_add_active_anon(struct page *page)
+{
+       __lru_cache_add(page, LRU_ACTIVE_ANON);
+}
+
+static inline void lru_cache_add_file(struct page *page)
+{
+       __lru_cache_add(page, LRU_INACTIVE_FILE);
+}
+
+static inline void lru_cache_add_active_file(struct page *page)
+{
+       __lru_cache_add(page, LRU_ACTIVE_FILE);
+}
+
 /* linux/mm/vmscan.c */
-extern int try_to_free_pages(struct zone **, gfp_t);
-extern int shrink_all_memory(int);
+extern unsigned long try_to_free_pages(struct zonelist *zonelist, int order,
+                                       gfp_t gfp_mask, nodemask_t *mask);
+extern unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem,
+                                                 gfp_t gfp_mask, bool noswap,
+                                                 unsigned int swappiness);
+extern int __isolate_lru_page(struct page *page, int mode, int file);
+extern unsigned long shrink_all_memory(unsigned long nr_pages);
 extern int vm_swappiness;
+extern int remove_mapping(struct address_space *mapping, struct page *page);
+extern long vm_total_pages;
+
+#ifdef CONFIG_NUMA
+extern int zone_reclaim_mode;
+extern int sysctl_min_unmapped_ratio;
+extern int sysctl_min_slab_ratio;
+extern int zone_reclaim(struct zone *, gfp_t, unsigned int);
+#else
+#define zone_reclaim_mode 0
+static inline int zone_reclaim(struct zone *z, gfp_t mask, unsigned int order)
+{
+       return 0;
+}
+#endif
+
+#ifdef CONFIG_UNEVICTABLE_LRU
+extern int page_evictable(struct page *page, struct vm_area_struct *vma);
+extern void scan_mapping_unevictable_pages(struct address_space *);
+
+extern unsigned long scan_unevictable_pages;
+extern int scan_unevictable_handler(struct ctl_table *, int, struct file *,
+                                       void __user *, size_t *, loff_t *);
+extern int scan_unevictable_register_node(struct node *node);
+extern void scan_unevictable_unregister_node(struct node *node);
+#else
+static inline int page_evictable(struct page *page,
+                                               struct vm_area_struct *vma)
+{
+       return 1;
+}
 
-extern int isolate_lru_page(struct page *p);
-extern int putback_lru_pages(struct list_head *l);
+static inline void scan_mapping_unevictable_pages(struct address_space *mapping)
+{
+}
 
-extern int migrate_pages(struct list_head *l, struct list_head *t);
+static inline int scan_unevictable_register_node(struct node *node)
+{
+       return 0;
+}
+
+static inline void scan_unevictable_unregister_node(struct node *node) { }
+#endif
+
+extern int kswapd_run(int nid);
 
 #ifdef CONFIG_MMU
 /* linux/mm/shmem.c */
@@ -191,45 +276,45 @@ extern void swap_unplug_io_fn(struct backing_dev_info *, struct page *);
 /* linux/mm/page_io.c */
 extern int swap_readpage(struct file *, struct page *);
 extern int swap_writepage(struct page *page, struct writeback_control *wbc);
-extern int rw_swap_page_sync(int, swp_entry_t, struct page *);
+extern void end_swap_bio_read(struct bio *bio, int err);
 
 /* linux/mm/swap_state.c */
 extern struct address_space swapper_space;
 #define total_swapcache_pages  swapper_space.nrpages
 extern void show_swap_cache_info(void);
 extern int add_to_swap(struct page *);
+extern int add_to_swap_cache(struct page *, swp_entry_t, gfp_t);
 extern void __delete_from_swap_cache(struct page *);
 extern void delete_from_swap_cache(struct page *);
-extern int move_to_swap_cache(struct page *, swp_entry_t);
-extern int move_from_swap_cache(struct page *, unsigned long,
-               struct address_space *);
 extern void free_page_and_swap_cache(struct page *);
 extern void free_pages_and_swap_cache(struct page **, int);
-extern struct page * lookup_swap_cache(swp_entry_t);
-extern struct page * read_swap_cache_async(swp_entry_t, struct vm_area_struct *vma,
-                                          unsigned long addr);
+extern struct page *lookup_swap_cache(swp_entry_t);
+extern struct page *read_swap_cache_async(swp_entry_t, gfp_t,
+                       struct vm_area_struct *vma, unsigned long addr);
+extern struct page *swapin_readahead(swp_entry_t, gfp_t,
+                       struct vm_area_struct *vma, unsigned long addr);
+
 /* linux/mm/swapfile.c */
+extern long nr_swap_pages;
 extern long total_swap_pages;
-extern unsigned int nr_swapfiles;
-extern struct swap_info_struct swap_info[];
 extern void si_swapinfo(struct sysinfo *);
 extern swp_entry_t get_swap_page(void);
-extern swp_entry_t get_swap_page_of_type(int type);
+extern swp_entry_t get_swap_page_of_type(int);
 extern int swap_duplicate(swp_entry_t);
 extern int valid_swaphandles(swp_entry_t, unsigned long *);
 extern void swap_free(swp_entry_t);
-extern void free_swap_and_cache(swp_entry_t);
+extern int free_swap_and_cache(swp_entry_t);
+extern int swap_type_of(dev_t, sector_t, struct block_device **);
+extern unsigned int count_swap_pages(int, int);
 extern sector_t map_swap_page(struct swap_info_struct *, pgoff_t);
+extern sector_t swapdev_block(int, pgoff_t);
 extern struct swap_info_struct *get_swap_info_struct(unsigned);
-extern int can_share_swap_page(struct page *);
-extern int remove_exclusive_swap_page(struct page *);
+extern int reuse_swap_page(struct page *);
+extern int try_to_free_swap(struct page *);
 struct backing_dev_info;
 
-extern spinlock_t swap_lock;
-
 /* linux/mm/thrash.c */
 extern struct mm_struct * swap_token_mm;
-extern unsigned long swap_token_default_timeout;
 extern void grab_swap_token(void);
 extern void __put_swap_token(struct mm_struct *);
 
@@ -249,9 +334,26 @@ static inline void disable_swap_token(void)
        put_swap_token(swap_token_mm);
 }
 
+#ifdef CONFIG_CGROUP_MEM_RES_CTLR
+extern void mem_cgroup_uncharge_swapcache(struct page *page, swp_entry_t ent);
+#else
+static inline void
+mem_cgroup_uncharge_swapcache(struct page *page, swp_entry_t ent)
+{
+}
+#endif
+#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
+extern void mem_cgroup_uncharge_swap(swp_entry_t ent);
+#else
+static inline void mem_cgroup_uncharge_swap(swp_entry_t ent)
+{
+}
+#endif
+
 #else /* CONFIG_SWAP */
 
-#define total_swap_pages                       0
+#define nr_swap_pages                          0L
+#define total_swap_pages                       0L
 #define total_swapcache_pages                  0UL
 
 #define si_swapinfo(val) \
@@ -263,21 +365,50 @@ static inline void disable_swap_token(void)
 #define free_pages_and_swap_cache(pages, nr) \
        release_pages((pages), (nr), 0);
 
-#define show_swap_cache_info()                 /*NOTHING*/
-#define free_swap_and_cache(swp)               /*NOTHING*/
-#define swap_duplicate(swp)                    /*NOTHING*/
-#define swap_free(swp)                         /*NOTHING*/
-#define read_swap_cache_async(swp,vma,addr)    NULL
-#define lookup_swap_cache(swp)                 NULL
-#define valid_swaphandles(swp, off)            0
-#define can_share_swap_page(p)                 0
-#define move_to_swap_cache(p, swp)             1
-#define move_from_swap_cache(p, i, m)          1
-#define __delete_from_swap_cache(p)            /*NOTHING*/
-#define delete_from_swap_cache(p)              /*NOTHING*/
-#define swap_token_default_timeout             0
-
-static inline int remove_exclusive_swap_page(struct page *p)
+static inline void show_swap_cache_info(void)
+{
+}
+
+#define free_swap_and_cache(swp)       is_migration_entry(swp)
+#define swap_duplicate(swp)            is_migration_entry(swp)
+
+static inline void swap_free(swp_entry_t swp)
+{
+}
+
+static inline struct page *swapin_readahead(swp_entry_t swp, gfp_t gfp_mask,
+                       struct vm_area_struct *vma, unsigned long addr)
+{
+       return NULL;
+}
+
+static inline struct page *lookup_swap_cache(swp_entry_t swp)
+{
+       return NULL;
+}
+
+static inline int add_to_swap(struct page *page)
+{
+       return 0;
+}
+
+static inline int add_to_swap_cache(struct page *page, swp_entry_t entry,
+                                                       gfp_t gfp_mask)
+{
+       return -1;
+}
+
+static inline void __delete_from_swap_cache(struct page *page)
+{
+}
+
+static inline void delete_from_swap_cache(struct page *page)
+{
+}
+
+#define reuse_swap_page(page)  (page_mapcount(page) == 1)
+
+static inline int try_to_free_swap(struct page *page)
 {
        return 0;
 }
@@ -295,6 +426,12 @@ static inline swp_entry_t get_swap_page(void)
 #define has_swap_token(x) 0
 #define disable_swap_token() do { } while(0)
 
+static inline int mem_cgroup_cache_charge_swapin(struct page *page,
+                       struct mm_struct *mm, gfp_t mask, bool locked)
+{
+       return 0;
+}
+
 #endif /* CONFIG_SWAP */
 #endif /* __KERNEL__*/
 #endif /* _LINUX_SWAP_H */