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 /*
  84  * swap cache stuff (in linux/mm/swap_state.c)
  85  */
  86 
  87 #define SWAP_CACHE_INFO
  88 
  89 extern unsigned long * swap_cache;
  90 
  91 #ifdef SWAP_CACHE_INFO
  92 extern unsigned long swap_cache_add_total;
  93 extern unsigned long swap_cache_add_success;
  94 extern unsigned long swap_cache_del_total;
  95 extern unsigned long swap_cache_del_success;
  96 extern unsigned long swap_cache_find_total;
  97 extern unsigned long swap_cache_find_success;
  98 #endif
  99 
 100 extern inline unsigned long in_swap_cache(unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 101 {
 102         return swap_cache[MAP_NR(addr)]; 
 103 }
 104 
 105 extern inline long find_in_swap_cache (unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 106 {
 107         unsigned long entry;
 108 
 109 #ifdef SWAP_CACHE_INFO
 110         swap_cache_find_total++;
 111 #endif
 112         entry = xchg(swap_cache + MAP_NR(addr), 0);
 113 #ifdef SWAP_CACHE_INFO
 114         if (entry)
 115                 swap_cache_find_success++;
 116 #endif  
 117         return entry;
 118 }
 119 
 120 extern inline int delete_from_swap_cache(unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 121 {
 122         unsigned long entry;
 123         
 124 #ifdef SWAP_CACHE_INFO
 125         swap_cache_del_total++;
 126 #endif  
 127         entry= xchg(swap_cache + MAP_NR(addr), 0);
 128         if (entry)  {
 129 #ifdef SWAP_CACHE_INFO
 130                 swap_cache_del_success++;
 131 #endif
 132                 swap_free(entry);
 133                 return 1;
 134         }
 135         return 0;
 136 }
 137 
 138 
 139 #endif /* __KERNEL__*/
 140 
 141 #endif /* _LINUX_SWAP_H */

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