root/include/linux/swapctl.h

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

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. AGE_CLUSTER_SIZE
  2. touch_page
  3. age_page
  4. age_of
  5. set_page_new

   1 #ifndef _LINUX_SWAPCTL_H
   2 #define _LINUX_SWAPCTL_H
   3 
   4 #include <asm/page.h>
   5 #include <linux/fs.h>
   6 
   7 /* Swap tuning control */
   8 
   9 /* First, enumerate the different reclaim policies */
  10 enum RCL_POLICY {RCL_ROUND_ROBIN, RCL_BUFF_FIRST, RCL_PERSIST};
  11 
  12 typedef struct swap_control_v5
  13 {
  14         int     sc_max_page_age;
  15         int     sc_page_advance;
  16         int     sc_page_decline;
  17         int     sc_page_initial_age;
  18         int     sc_max_buff_age;
  19         int     sc_buff_advance;
  20         int     sc_buff_decline;
  21         int     sc_buff_initial_age;
  22         int     sc_age_cluster_fract;
  23         int     sc_age_cluster_min;
  24         int     sc_pageout_weight;
  25         int     sc_bufferout_weight;
  26         int     sc_buffer_grace;
  27         int     sc_nr_buffs_to_free;
  28         int     sc_nr_pages_to_free;
  29         enum RCL_POLICY sc_policy;
  30 } swap_control_v5;
  31 typedef struct swap_control_v5 swap_control_t;
  32 extern swap_control_t swap_control;
  33 
  34 typedef struct kswapd_control_v1
  35 {
  36         int     maxpages;
  37         int     pages_buff;
  38         int     pages_shm;
  39         int     pages_mmap;
  40         int     pages_swap;
  41 } kswapd_control_v1;
  42 typedef kswapd_control_v1 kswapd_control_t;
  43 extern kswapd_control_t kswapd_ctl;
  44 
  45 #define SC_VERSION      1
  46 #define SC_MAX_VERSION  1
  47 
  48 #ifdef __KERNEL__
  49 
  50 /* Define the maximum (least urgent) priority for the page reclaim code */
  51 #define RCL_MAXPRI 6
  52 /* We use an extra priority in the swap accounting code to represent
  53    failure to free a resource at any priority */
  54 #define RCL_FAILURE (RCL_MAXPRI + 1)
  55 
  56 #define RCL_POLICY              (swap_control.sc_policy)
  57 #define AGE_CLUSTER_FRACT       (swap_control.sc_age_cluster_fract)
  58 #define AGE_CLUSTER_MIN         (swap_control.sc_age_cluster_min)
  59 #define PAGEOUT_WEIGHT          (swap_control.sc_pageout_weight)
  60 #define BUFFEROUT_WEIGHT        (swap_control.sc_bufferout_weight)
  61 
  62 #define NR_BUFFS_TO_FREE        (swap_control.sc_nr_buffs_to_free)
  63 #define NR_PAGES_TO_FREE        (swap_control.sc_nr_pages_to_free)
  64 
  65 #define BUFFERMEM_GRACE         (swap_control.sc_buffer_grace)
  66 
  67 /* Page aging (see mm/swap.c) */
  68 
  69 #define MAX_PAGE_AGE            (swap_control.sc_max_page_age)
  70 #define PAGE_ADVANCE            (swap_control.sc_page_advance)
  71 #define PAGE_DECLINE            (swap_control.sc_page_decline)
  72 #define PAGE_INITIAL_AGE        (swap_control.sc_page_initial_age)
  73 
  74 #define MAX_BUFF_AGE            (swap_control.sc_max_buff_age)
  75 #define BUFF_ADVANCE            (swap_control.sc_buff_advance)
  76 #define BUFF_DECLINE            (swap_control.sc_buff_decline)
  77 #define BUFF_INITIAL_AGE        (swap_control.sc_buff_initial_age)
  78 
  79 /* Given a resource of N units (pages or buffers etc), we only try to
  80  * age and reclaim AGE_CLUSTER_FRACT per 1024 resources each time we
  81  * scan the resource list. */
  82 static inline int AGE_CLUSTER_SIZE(int resources)
     /* [previous][next][first][last][top][bottom][index][help] */
  83 {
  84         int n = (resources * AGE_CLUSTER_FRACT) >> 10;
  85         if (n < AGE_CLUSTER_MIN)
  86                 return AGE_CLUSTER_MIN;
  87         else
  88                 return n;
  89 }
  90 
  91 static inline void touch_page(struct page *page)
     /* [previous][next][first][last][top][bottom][index][help] */
  92 {
  93         if (page->age < (MAX_PAGE_AGE - PAGE_ADVANCE))
  94                 page->age += PAGE_ADVANCE;
  95         else
  96                 page->age = MAX_PAGE_AGE;
  97 }
  98 
  99 static inline void age_page(struct page *page)
     /* [previous][next][first][last][top][bottom][index][help] */
 100 {
 101         if (page->age > PAGE_DECLINE)
 102                 page->age -= PAGE_DECLINE;
 103         else
 104                 page->age = 0;
 105 }
 106 
 107 static inline int age_of(unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 108 {
 109         return mem_map[MAP_NR(addr)].age;
 110 }
 111 
 112 static inline void set_page_new(unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 113 {
 114         mem_map[MAP_NR(addr)].age = PAGE_INITIAL_AGE;
 115 }
 116 
 117 #endif /* __KERNEL */
 118 
 119 #endif /* _LINUX_SWAPCTL_H */

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