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 struct swap_info_struct {
  16         unsigned int flags;
  17         kdev_t swap_device;
  18         struct inode * swap_file;
  19         unsigned char * swap_map;
  20         unsigned char * swap_lockmap;
  21         int lowest_bit;
  22         int highest_bit;
  23         int prio;                       /* swap priority */
  24         int pages;
  25         unsigned long max;
  26         int next;                       /* next entry on swap list */
  27 };
  28 
  29 extern int nr_swap_pages;
  30 extern int nr_free_pages;
  31 extern int min_free_pages;
  32 extern int free_pages_low;
  33 extern int free_pages_high;
  34 
  35 /* Incomplete types for prototype declarations: */
  36 struct task_struct;
  37 struct vm_area_struct;
  38 struct sysinfo;
  39 
  40 /* linux/ipc/shm.c */
  41 extern int shm_swap (int, unsigned long);
  42 
  43 /* linux/mm/swap_clock.c */
  44 extern int try_to_free_page(int, unsigned long);
  45 
  46 /* linux/mm/swap_io.c */
  47 extern void rw_swap_page(int, unsigned long, char *);
  48 #define read_swap_page(nr,buf) \
  49         rw_swap_page(READ,(nr),(buf))
  50 #define write_swap_page(nr,buf) \
  51         rw_swap_page(WRITE,(nr),(buf))
  52 
  53 /* linux/mm/swap_mman.c */
  54 extern void swap_in(struct task_struct *, struct vm_area_struct *,
  55                     pte_t *, unsigned long, int);
  56 
  57 
  58 /* linux/mm/swap_state.c */
  59 extern void show_swap_cache_info(void);
  60 extern int add_to_swap_cache(unsigned long, unsigned long);
  61 extern unsigned long init_swap_cache(unsigned long, unsigned long);
  62 extern void swap_duplicate(unsigned long);
  63 
  64 /* linux/mm/swapfile.c */
  65 extern int nr_swapfiles;
  66 extern struct swap_info_struct swap_info[];
  67 void si_swapinfo(struct sysinfo *);
  68 unsigned long get_swap_page(void);
  69 extern void swap_free(unsigned long);
  70 
  71 /*
  72  * vm_ops not present page codes for shared memory.
  73  *
  74  * Will go away eventually..
  75  */
  76 #define SHM_SWP_TYPE 0x40
  77 
  78 extern void shm_no_page (ulong *);
  79 
  80 /*
  81  * swap cache stuff (in linux/mm/swap_state.c)
  82  */
  83 
  84 #define SWAP_CACHE_INFO
  85 
  86 extern unsigned long * swap_cache;
  87 
  88 #ifdef SWAP_CACHE_INFO
  89 extern unsigned long swap_cache_add_total;
  90 extern unsigned long swap_cache_add_success;
  91 extern unsigned long swap_cache_del_total;
  92 extern unsigned long swap_cache_del_success;
  93 extern unsigned long swap_cache_find_total;
  94 extern unsigned long swap_cache_find_success;
  95 #endif
  96 
  97 extern inline unsigned long in_swap_cache(unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  98 {
  99         return swap_cache[MAP_NR(addr)]; 
 100 }
 101 
 102 extern inline long find_in_swap_cache (unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 103 {
 104         unsigned long entry;
 105 
 106 #ifdef SWAP_CACHE_INFO
 107         swap_cache_find_total++;
 108 #endif
 109         entry = xchg(swap_cache + MAP_NR(addr), 0);
 110 #ifdef SWAP_CACHE_INFO
 111         if (entry)
 112                 swap_cache_find_success++;
 113 #endif  
 114         return entry;
 115 }
 116 
 117 extern inline int delete_from_swap_cache(unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 118 {
 119         unsigned long entry;
 120         
 121 #ifdef SWAP_CACHE_INFO
 122         swap_cache_del_total++;
 123 #endif  
 124         entry= xchg(swap_cache + MAP_NR(addr), 0);
 125         if (entry)  {
 126 #ifdef SWAP_CACHE_INFO
 127                 swap_cache_del_success++;
 128 #endif
 129                 swap_free(entry);
 130                 return 1;
 131         }
 132         return 0;
 133 }
 134 
 135 
 136 #endif /* __KERNEL__*/
 137 
 138 #endif /* _LINUX_SWAP_H */

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