Advertisement
Guest User

ZFS ARC control

a guest
Jun 7th, 2010
465
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 4.60 KB | None | 0 0
  1. diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
  2. index b593792..4c56163 100644
  3. --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
  4. +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
  5. @@ -183,10 +183,15 @@ int zfs_arc_grow_retry = 0;
  6.  int zfs_arc_shrink_shift = 0;
  7.  int zfs_arc_p_min_shift = 0;
  8.  
  9. +uint64_t zfs_arc_bp_active;
  10. +uint64_t zfs_arc_bp_inactive;
  11. +
  12.  TUNABLE_QUAD("vfs.zfs.arc_max", &zfs_arc_max);
  13.  TUNABLE_QUAD("vfs.zfs.arc_min", &zfs_arc_min);
  14.  TUNABLE_QUAD("vfs.zfs.arc_meta_limit", &zfs_arc_meta_limit);
  15.  TUNABLE_INT("vfs.zfs.mdcomp_disable", &zfs_mdcomp_disable);
  16. +TUNABLE_QUAD("vfs.zfs.arc_bp_active", &zfs_arc_bp_active);
  17. +TUNABLE_QUAD("vfs.zfs.arc_bp_inactive", &zfs_arc_bp_inactive);
  18.  SYSCTL_DECL(_vfs_zfs);
  19.  SYSCTL_QUAD(_vfs_zfs, OID_AUTO, arc_max, CTLFLAG_RDTUN, &zfs_arc_max, 0,
  20.      "Maximum ARC size");
  21. @@ -195,6 +200,11 @@ SYSCTL_QUAD(_vfs_zfs, OID_AUTO, arc_min, CTLFLAG_RDTUN, &zfs_arc_min, 0,
  22.  SYSCTL_INT(_vfs_zfs, OID_AUTO, mdcomp_disable, CTLFLAG_RDTUN,
  23.      &zfs_mdcomp_disable, 0, "Disable metadata compression");
  24.  
  25. +SYSCTL_QUAD(_vfs_zfs, OID_AUTO, arc_bp_active, CTLFLAG_RW|CTLFLAG_TUN, &zfs_arc_bp_active, 0,
  26. +    "Start ARC backpressure if active memory is below this limit");
  27. +SYSCTL_QUAD(_vfs_zfs, OID_AUTO, arc_bp_inactive, CTLFLAG_RW|CTLFLAG_TUN, &zfs_arc_bp_inactive, 0,
  28. +    "Start ARC backpressure if inactive memory is below this limit");
  29. +
  30.  /*
  31.   * Note that buffers can be in one of 6 states:
  32.   * ARC_anon    - anonymous (discussed below)
  33. @@ -2105,7 +2115,6 @@ arc_shrink(void)
  34.  }
  35.  
  36.  static int needfree = 0;
  37. -
  38.  static int
  39.  arc_reclaim_needed(void)
  40.  {
  41. @@ -2114,20 +2123,58 @@ arc_reclaim_needed(void)
  42.  #endif
  43.  
  44.  #ifdef _KERNEL
  45. -   if (needfree)
  46. -       return (1);
  47. +        /* We've grown too much, */
  48.     if (arc_size > arc_c_max)
  49. -       return (1);
  50. +            return (1);
  51. +
  52. +        /* Pagedaemon is stuck, let's free something right away */
  53. +        if (vm_pageout_pages_needed)
  54. +            return 1;
  55. +
  56. +   /* Check if inactive list have grown too much */
  57. +   if ( zfs_arc_bp_inactive
  58. +        && (ptoa((uintmax_t)cnt.v_inactive_count) > zfs_arc_bp_inactive)) {
  59. +       /* tell pager to reap 1/2th of inactive queue*/
  60. +       atomic_add_int(&vm_pageout_deficit, cnt.v_inactive_count/2);
  61. +       pagedaemon_wakeup();
  62. +       return needfree;
  63. +   }
  64. +
  65. +   /* Same for active list... */
  66. +   if ( zfs_arc_bp_active
  67. +        && (ptoa((uintmax_t)cnt.v_active_count) > zfs_arc_bp_active)) {
  68. +       atomic_add_int(&vm_pageout_deficit, cnt.v_active_count/2);
  69. +       pagedaemon_wakeup();
  70. +       return needfree;
  71. +   }
  72. +
  73. +  
  74. +   /* Old style behavior -- ARC gives up memory whenever page daemon asks.. */
  75. +   if (needfree)
  76. +       return 1;
  77. +
  78. +        /*
  79. +          We got here either because active/inactive lists are
  80. +          getting short or because we've been called during voluntary
  81. +          ARC size checks. Kind of gray area...
  82. +        */
  83. +
  84. +        /* If we didn't reach our minimum yet, don't rush to give memory up..*/
  85.     if (arc_size <= arc_c_min)
  86.         return (0);
  87.  
  88. -   /*
  89. -    * If pages are needed or we're within 2048 pages
  90. -    * of needing to page need to reclaim
  91. +        /* If we're really short on memory now, give it up. */
  92. +   if (vm_page_count_min()) {
  93. +       return (1);
  94. +   }
  95. +        
  96. +        /*
  97. +         * If we're within 2048 pages of pagedaemon start, reclaim...
  98.      */
  99. -   if (vm_pages_needed || (vm_paging_target() > -2048))
  100. +   if (vm_pages_needed && (vm_paging_target() > -2048))
  101.         return (1);
  102.  
  103. +
  104.  #if 0
  105.     /*
  106.      * take 'desfree' extra pages, so we reclaim sooner, rather than later
  107. @@ -2171,8 +2218,6 @@ arc_reclaim_needed(void)
  108.         return (1);
  109.  #endif
  110.  #else
  111. -   if (kmem_used() > (kmem_size() * 3) / 4)
  112. -       return (1);
  113.  #endif
  114.  
  115.  #else
  116. @@ -2281,7 +2326,7 @@ arc_reclaim_thread(void *dummy __unused)
  117.         if (arc_eviction_list != NULL)
  118.             arc_do_user_evicts();
  119.  
  120. -       if (arc_reclaim_needed()) {
  121. +       if (needfree) {
  122.             needfree = 0;
  123.  #ifdef _KERNEL
  124.             wakeup(&needfree);
  125. @@ -3613,10 +3658,15 @@ arc_memory_throttle(uint64_t reserve, uint64_t txg)
  126.  {
  127.  #ifdef _KERNEL
  128.     uint64_t inflight_data = arc_anon->arcs_size;
  129. -   uint64_t available_memory = ptoa((uintmax_t)cnt.v_free_count);
  130. +   uint64_t available_memory;
  131.     static uint64_t page_load = 0;
  132.     static uint64_t last_txg = 0;
  133.  
  134. +        /* How much memory is potentially available */
  135. +        available_memory = ptoa((uintmax_t)cnt.v_free_count);
  136. +        available_memory += ptoa((uintmax_t)cnt.v_cache_count);
  137. +        available_memory -= ptoa((uintmax_t)cnt.v_free_min);
  138. +        
  139.  #if 0
  140.  #if defined(__i386)
  141.     available_memory =
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement