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 
  32 typedef struct swap_control_v5 swap_control_t;
  33 
  34 extern swap_control_t swap_control;
  35 
  36 #define SC_VERSION      1
  37 #define SC_MAX_VERSION  1
  38 
  39 #ifdef __KERNEL__
  40 
  41 /* Define the maximum (least urgent) priority for the page reclaim code */
  42 #define RCL_MAXPRI 6
  43 /* We use an extra priority in the swap accounting code to represent
  44    failure to free a resource at any priority */
  45 #define RCL_FAILURE (RCL_MAXPRI + 1)
  46 
  47 #define RCL_POLICY              (swap_control.sc_policy)
  48 #define AGE_CLUSTER_FRACT       (swap_control.sc_age_cluster_fract)
  49 #define AGE_CLUSTER_MIN         (swap_control.sc_age_cluster_min)
  50 #define PAGEOUT_WEIGHT          (swap_control.sc_pageout_weight)
  51 #define BUFFEROUT_WEIGHT        (swap_control.sc_bufferout_weight)
  52 
  53 #define NR_BUFFS_TO_FREE        (swap_control.sc_nr_buffs_to_free)
  54 #define NR_PAGES_TO_FREE        (swap_control.sc_nr_pages_to_free)
  55 
  56 #define BUFFERMEM_GRACE         (swap_control.sc_buffer_grace)
  57 
  58 /* Page aging (see mm/swap.c) */
  59 
  60 #define MAX_PAGE_AGE            (swap_control.sc_max_page_age)
  61 #define PAGE_ADVANCE            (swap_control.sc_page_advance)
  62 #define PAGE_DECLINE            (swap_control.sc_page_decline)
  63 #define PAGE_INITIAL_AGE        (swap_control.sc_page_initial_age)
  64 
  65 #define MAX_BUFF_AGE            (swap_control.sc_max_buff_age)
  66 #define BUFF_ADVANCE            (swap_control.sc_buff_advance)
  67 #define BUFF_DECLINE            (swap_control.sc_buff_decline)
  68 #define BUFF_INITIAL_AGE        (swap_control.sc_buff_initial_age)
  69 
  70 /* Given a resource of N units (pages or buffers etc), we only try to
  71  * age and reclaim AGE_CLUSTER_FRACT per 1024 resources each time we
  72  * scan the resource list. */
  73 static inline int AGE_CLUSTER_SIZE(int resources)
     /* [previous][next][first][last][top][bottom][index][help] */
  74 {
  75         int n = (resources * AGE_CLUSTER_FRACT) >> 10;
  76         if (n < AGE_CLUSTER_MIN)
  77                 return AGE_CLUSTER_MIN;
  78         else
  79                 return n;
  80 }
  81 
  82 static inline void touch_page(unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  83 {
  84         unsigned char age = mem_map[MAP_NR(addr)].age;
  85         if (age < (MAX_PAGE_AGE - PAGE_ADVANCE))
  86                 age += PAGE_ADVANCE;
  87         else
  88                 age = MAX_PAGE_AGE;
  89         mem_map[MAP_NR(addr)].age = age;
  90 }
  91 
  92 static inline void age_page(unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  93 {
  94         unsigned char age = mem_map[MAP_NR(addr)].age;
  95         if (age > PAGE_DECLINE)
  96                 age -= PAGE_DECLINE;
  97         else
  98                 age = 0;
  99         mem_map[MAP_NR(addr)].age = age;
 100 }
 101 
 102 static inline int age_of(unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 103 {
 104         return mem_map[MAP_NR(addr)].age;
 105 }
 106 
 107 static inline void set_page_new(unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 108 {
 109         mem_map[MAP_NR(addr)].age = PAGE_INITIAL_AGE;
 110 }
 111 
 112 #endif /* __KERNEL */
 113 
 114 #endif /* _LINUX_SWAPCTL_H */

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