|
Lines 190-195
static int arc_dead;
Link Here
|
| 190 |
extern int zfs_prefetch_disable; |
190 |
extern int zfs_prefetch_disable; |
| 191 |
|
191 |
|
| 192 |
/* |
192 |
/* |
|
|
193 |
* KD 2015-02-10 |
| 194 |
* We have to be able to test for UIO use inside the arc allocator. |
| 195 |
* NOTE: DO NOT MODIFY HERE! |
| 196 |
*/ |
| 197 |
extern int zio_use_uma; |
| 198 |
extern int zfs_dynamic_write_buffer; |
| 199 |
|
| 200 |
|
| 201 |
/* |
| 193 |
* The arc has filled available memory and has now warmed up. |
202 |
* The arc has filled available memory and has now warmed up. |
| 194 |
*/ |
203 |
*/ |
| 195 |
static boolean_t arc_warm; |
204 |
static boolean_t arc_warm; |
|
Lines 212-218
static void
Link Here
|
| 212 |
arc_free_target_init(void *unused __unused) |
221 |
arc_free_target_init(void *unused __unused) |
| 213 |
{ |
222 |
{ |
| 214 |
|
223 |
|
| 215 |
zfs_arc_free_target = vm_pageout_wakeup_thresh; |
224 |
zfs_arc_free_target = vm_pageout_wakeup_thresh + ((cnt.v_free_target - vm_pageout_wakeup_thresh) / 2); |
| 216 |
} |
225 |
} |
| 217 |
SYSINIT(arc_free_target_init, SI_SUB_KTHREAD_PAGE, SI_ORDER_ANY, |
226 |
SYSINIT(arc_free_target_init, SI_SUB_KTHREAD_PAGE, SI_ORDER_ANY, |
| 218 |
arc_free_target_init, NULL); |
227 |
arc_free_target_init, NULL); |
|
Lines 233-239
SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, arc_average_block
Link Here
|
| 233 |
SYSCTL_INT(_vfs_zfs, OID_AUTO, arc_shrink_shift, CTLFLAG_RW, |
242 |
SYSCTL_INT(_vfs_zfs, OID_AUTO, arc_shrink_shift, CTLFLAG_RW, |
| 234 |
&arc_shrink_shift, 0, |
243 |
&arc_shrink_shift, 0, |
| 235 |
"log2(fraction of arc to reclaim)"); |
244 |
"log2(fraction of arc to reclaim)"); |
| 236 |
|
245 |
SYSCTL_INT(_vfs_zfs, OID_AUTO, dynamic_write_buffer, CTLFLAG_RWTUN, |
|
|
246 |
&zfs_dynamic_write_buffer, 0, |
| 247 |
"Dynamically restrict dirty data when memory is low"); |
| 237 |
/* |
248 |
/* |
| 238 |
* We don't have a tunable for arc_free_target due to the dependency on |
249 |
* We don't have a tunable for arc_free_target due to the dependency on |
| 239 |
* pagedaemon initialisation. |
250 |
* pagedaemon initialisation. |
|
Lines 2635-2640
extern kmem_cache_t *zio_buf_cache[];
Link Here
|
| 2635 |
extern kmem_cache_t *zio_data_buf_cache[]; |
2646 |
extern kmem_cache_t *zio_data_buf_cache[]; |
| 2636 |
extern kmem_cache_t *range_seg_cache; |
2647 |
extern kmem_cache_t *range_seg_cache; |
| 2637 |
|
2648 |
|
|
|
2649 |
static void __used |
| 2650 |
reap_arc_caches() |
| 2651 |
{ |
| 2652 |
size_t i; |
| 2653 |
kmem_cache_t *prev_cache = NULL; |
| 2654 |
kmem_cache_t *prev_data_cache = NULL; |
| 2655 |
|
| 2656 |
for (i = 0; i < SPA_MAXBLOCKSIZE >> SPA_MINBLOCKSHIFT; i++) { |
| 2657 |
if (zio_buf_cache[i] != prev_cache) { |
| 2658 |
prev_cache = zio_buf_cache[i]; |
| 2659 |
kmem_cache_reap_now(zio_buf_cache[i]); |
| 2660 |
} |
| 2661 |
if (zio_data_buf_cache[i] != prev_data_cache) { |
| 2662 |
prev_data_cache = zio_data_buf_cache[i]; |
| 2663 |
kmem_cache_reap_now(zio_data_buf_cache[i]); |
| 2664 |
} |
| 2665 |
} |
| 2666 |
kmem_cache_reap_now(buf_cache); |
| 2667 |
kmem_cache_reap_now(hdr_cache); |
| 2668 |
kmem_cache_reap_now(range_seg_cache); |
| 2669 |
} |
| 2670 |
|
| 2638 |
static void __noinline |
2671 |
static void __noinline |
| 2639 |
arc_kmem_reap_now(arc_reclaim_strategy_t strat) |
2672 |
arc_kmem_reap_now(arc_reclaim_strategy_t strat) |
| 2640 |
{ |
2673 |
{ |
|
Lines 2666-2684
arc_kmem_reap_now(arc_reclaim_strategy_t strat)
Link Here
|
| 2666 |
if (strat == ARC_RECLAIM_AGGR) |
2699 |
if (strat == ARC_RECLAIM_AGGR) |
| 2667 |
arc_shrink(); |
2700 |
arc_shrink(); |
| 2668 |
|
2701 |
|
| 2669 |
for (i = 0; i < SPA_MAXBLOCKSIZE >> SPA_MINBLOCKSHIFT; i++) { |
2702 |
reap_arc_caches(); |
| 2670 |
if (zio_buf_cache[i] != prev_cache) { |
|
|
| 2671 |
prev_cache = zio_buf_cache[i]; |
| 2672 |
kmem_cache_reap_now(zio_buf_cache[i]); |
| 2673 |
} |
| 2674 |
if (zio_data_buf_cache[i] != prev_data_cache) { |
| 2675 |
prev_data_cache = zio_data_buf_cache[i]; |
| 2676 |
kmem_cache_reap_now(zio_data_buf_cache[i]); |
| 2677 |
} |
| 2678 |
} |
| 2679 |
kmem_cache_reap_now(buf_cache); |
| 2680 |
kmem_cache_reap_now(hdr_cache); |
| 2681 |
kmem_cache_reap_now(range_seg_cache); |
| 2682 |
|
2703 |
|
| 2683 |
#ifdef sun |
2704 |
#ifdef sun |
| 2684 |
/* |
2705 |
/* |
|
Lines 2697-2707
arc_reclaim_thread(void *dummy __unused)
Link Here
|
| 2697 |
clock_t growtime = 0; |
2718 |
clock_t growtime = 0; |
| 2698 |
arc_reclaim_strategy_t last_reclaim = ARC_RECLAIM_CONS; |
2719 |
arc_reclaim_strategy_t last_reclaim = ARC_RECLAIM_CONS; |
| 2699 |
callb_cpr_t cpr; |
2720 |
callb_cpr_t cpr; |
|
|
2721 |
int autoreap = 0; |
| 2700 |
|
2722 |
|
| 2701 |
CALLB_CPR_INIT(&cpr, &arc_reclaim_thr_lock, callb_generic_cpr, FTAG); |
2723 |
CALLB_CPR_INIT(&cpr, &arc_reclaim_thr_lock, callb_generic_cpr, FTAG); |
| 2702 |
|
2724 |
|
| 2703 |
mutex_enter(&arc_reclaim_thr_lock); |
2725 |
mutex_enter(&arc_reclaim_thr_lock); |
| 2704 |
while (arc_thread_exit == 0) { |
2726 |
while (arc_thread_exit == 0) { |
|
|
2727 |
|
| 2728 |
#ifdef _KERNEL |
| 2729 |
/* KD 2015-02-10 |
| 2730 |
* Protect against UMA free memory bloat. We already do this on a low-memory |
| 2731 |
* basis in the allocator; it has to happen there rather than here due to |
| 2732 |
* response time considerations. Make the call here once every 10 passes as |
| 2733 |
* well; this reclaims unused UMA buffers every 10 seconds on an idle system |
| 2734 |
* and more frequently if the reclaim thread gets woken up by low RAM |
| 2735 |
* conditions. |
| 2736 |
*/ |
| 2737 |
if ((zio_use_uma) && (autoreap++ == 10)) { |
| 2738 |
autoreap = 0; |
| 2739 |
DTRACE_PROBE(arc__reclaim_timed_reap); |
| 2740 |
reap_arc_caches(); |
| 2741 |
} |
| 2742 |
#endif /* _KERNEL */ |
| 2743 |
|
| 2705 |
if (arc_reclaim_needed()) { |
2744 |
if (arc_reclaim_needed()) { |
| 2706 |
|
2745 |
|
| 2707 |
if (arc_no_grow) { |
2746 |
if (arc_no_grow) { |
|
Lines 2889-2894
arc_get_data_buf(arc_buf_t *buf)
Link Here
|
| 2889 |
arc_space_consume(size, ARC_SPACE_DATA); |
2928 |
arc_space_consume(size, ARC_SPACE_DATA); |
| 2890 |
} else { |
2929 |
} else { |
| 2891 |
ASSERT(type == ARC_BUFC_DATA); |
2930 |
ASSERT(type == ARC_BUFC_DATA); |
|
|
2931 |
#ifdef _KERNEL |
| 2932 |
/* KD 2015-02-10 |
| 2933 |
* It would be nice if we could leave this to the arc_reclaim thread. |
| 2934 |
* Unfortunately we cannot; the test has to be done here as well, because |
| 2935 |
* under heavy I/O demand we can grab enough RAM fast enough to induce |
| 2936 |
* nasty oscillation problems. Fortunately we only need to call this when |
| 2937 |
* the system is under reasonably-severe memory stress. |
| 2938 |
*/ |
| 2939 |
if (zio_use_uma && (ptob(cnt.v_free_count) + size < ptob(cnt.v_free_target))) { |
| 2940 |
DTRACE_PROBE3(arc__alloc_lowmem_reap, int, cnt.v_free_count, int, size, int, cnt.v_free_target); |
| 2941 |
reap_arc_caches(); |
| 2942 |
} |
| 2943 |
#endif /* _KERNEL */ |
| 2892 |
buf->b_data = zio_data_buf_alloc(size); |
2944 |
buf->b_data = zio_data_buf_alloc(size); |
| 2893 |
ARCSTAT_INCR(arcstat_data_size, size); |
2945 |
ARCSTAT_INCR(arcstat_data_size, size); |
| 2894 |
atomic_add_64(&arc_size, size); |
2946 |
atomic_add_64(&arc_size, size); |