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

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