root/include/linux/swap.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. in_swap_cache
  2. find_in_swap_cache
  3. delete_from_swap_cache

   1 #ifndef _LINUX_SWAP_H
   2 #define _LINUX_SWAP_H
   3 
   4 #define SWAP_FLAG_PREFER        0x8000  /* set if swap priority specified */
   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;                       /* swap priority */
  28         int pages;
  29         unsigned long max;
  30         int next;                       /* next entry on swap list */
  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 /* Incomplete types for prototype declarations: */
  41 struct task_struct;
  42 struct vm_area_struct;
  43 struct sysinfo;
  44 
  45 /* linux/ipc/shm.c */
  46 extern int shm_swap (int, unsigned long);
  47 
  48 /* linux/mm/vmscan.c */
  49 extern int try_to_free_page(int, unsigned long, int);
  50 
  51 /* linux/mm/page_io.c */
  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 
  58 /* linux/mm/page_alloc.c */
  59 extern void swap_in(struct task_struct *, struct vm_area_struct *,
  60                     pte_t *, unsigned long, int);
  61 
  62 
  63 /* linux/mm/swap_state.c */
  64 extern void show_swap_cache_info(void);
  65 extern int add_to_swap_cache(unsigned long, unsigned long);
  66 extern unsigned long init_swap_cache(unsigned long, unsigned long);
  67 extern void swap_duplicate(unsigned long);
  68 
  69 /* linux/mm/swapfile.c */
  70 extern int nr_swapfiles;
  71 extern struct swap_info_struct swap_info[];
  72 void si_swapinfo(struct sysinfo *);
  73 unsigned long get_swap_page(void);
  74 extern void swap_free(unsigned long);
  75 
  76 /*
  77  * vm_ops not present page codes for shared memory.
  78  *
  79  * Will go away eventually..
  80  */
  81 #define SHM_SWP_TYPE 0x40
  82 
  83 extern void shm_no_page (ulong *);
  84 
  85 /*
  86  * swap cache stuff (in linux/mm/swap_state.c)
  87  */
  88 
  89 #define SWAP_CACHE_INFO
  90 
  91 extern unsigned long * swap_cache;
  92 
  93 #ifdef SWAP_CACHE_INFO
  94 extern unsigned long swap_cache_add_total;
  95 extern unsigned long swap_cache_add_success;
  96 extern unsigned long swap_cache_del_total;
  97 extern unsigned long swap_cache_del_success;
  98 extern unsigned long swap_cache_find_total;
  99 extern unsigned long swap_cache_find_success;
 100 #endif
 101 
 102 extern inline unsigned long in_swap_cache(unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 103 {
 104         return swap_cache[MAP_NR(addr)]; 
 105 }
 106 
 107 extern inline long find_in_swap_cache (unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 108 {
 109         unsigned long entry;
 110 
 111 #ifdef SWAP_CACHE_INFO
 112         swap_cache_find_total++;
 113 #endif
 114         entry = xchg(swap_cache + MAP_NR(addr), 0);
 115 #ifdef SWAP_CACHE_INFO
 116         if (entry)
 117                 swap_cache_find_success++;
 118 #endif  
 119         return entry;
 120 }
 121 
 122 extern inline int delete_from_swap_cache(unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 123 {
 124         unsigned long entry;
 125         
 126 #ifdef SWAP_CACHE_INFO
 127         swap_cache_del_total++;
 128 #endif  
 129         entry= xchg(swap_cache + MAP_NR(addr), 0);
 130         if (entry)  {
 131 #ifdef SWAP_CACHE_INFO
 132                 swap_cache_del_success++;
 133 #endif
 134                 swap_free(entry);
 135                 return 1;
 136         }
 137         return 0;
 138 }
 139 
 140 
 141 #endif /* __KERNEL__*/
 142 
 143 #endif /* _LINUX_SWAP_H */

/* [previous][next][first][last][top][bottom][index][help] */