Lines 216-221
Link Here
|
216 |
extern boolean_t zfs_prefetch_disable; |
216 |
extern boolean_t zfs_prefetch_disable; |
217 |
|
217 |
|
218 |
/* |
218 |
/* |
|
|
219 |
* KD 2015-02-10 |
220 |
* We have to be able to test for UIO use inside the arc allocator. |
221 |
* NOTE: DO NOT MODIFY HERE! |
222 |
*/ |
223 |
extern int zio_use_uma; |
224 |
extern int zfs_dynamic_write_buffer; |
225 |
|
226 |
|
227 |
/* |
219 |
* The arc has filled available memory and has now warmed up. |
228 |
* The arc has filled available memory and has now warmed up. |
220 |
*/ |
229 |
*/ |
221 |
static boolean_t arc_warm; |
230 |
static boolean_t arc_warm; |
Lines 242-248
Link Here
|
242 |
arc_free_target_init(void *unused __unused) |
251 |
arc_free_target_init(void *unused __unused) |
243 |
{ |
252 |
{ |
244 |
|
253 |
|
245 |
zfs_arc_free_target = vm_pageout_wakeup_thresh; |
254 |
zfs_arc_free_target = vm_pageout_wakeup_thresh + ((cnt.v_free_target - vm_pageout_wakeup_thresh) / 2); |
246 |
} |
255 |
} |
247 |
SYSINIT(arc_free_target_init, SI_SUB_KTHREAD_PAGE, SI_ORDER_ANY, |
256 |
SYSINIT(arc_free_target_init, SI_SUB_KTHREAD_PAGE, SI_ORDER_ANY, |
248 |
arc_free_target_init, NULL); |
257 |
arc_free_target_init, NULL); |
Lines 264-270
Link Here
|
264 |
SYSCTL_INT(_vfs_zfs, OID_AUTO, arc_shrink_shift, CTLFLAG_RW, |
273 |
SYSCTL_INT(_vfs_zfs, OID_AUTO, arc_shrink_shift, CTLFLAG_RW, |
265 |
&arc_shrink_shift, 0, |
274 |
&arc_shrink_shift, 0, |
266 |
"log2(fraction of arc to reclaim)"); |
275 |
"log2(fraction of arc to reclaim)"); |
267 |
|
276 |
SYSCTL_INT(_vfs_zfs, OID_AUTO, dynamic_write_buffer, CTLFLAG_RWTUN, |
|
|
277 |
&zfs_dynamic_write_buffer, 0, |
278 |
"Dynamically restrict dirty data when memory is low"); |
268 |
/* |
279 |
/* |
269 |
* We don't have a tunable for arc_free_target due to the dependency on |
280 |
* We don't have a tunable for arc_free_target due to the dependency on |
270 |
* pagedaemon initialisation. |
281 |
* pagedaemon initialisation. |
Lines 3524-3529
Link Here
|
3524 |
extern kmem_cache_t *zio_data_buf_cache[]; |
3535 |
extern kmem_cache_t *zio_data_buf_cache[]; |
3525 |
extern kmem_cache_t *range_seg_cache; |
3536 |
extern kmem_cache_t *range_seg_cache; |
3526 |
|
3537 |
|
|
|
3538 |
/* |
3539 |
* Used by arc_kmem_reap_now() and consider_reaping_arc_caches() |
3540 |
* to limit the time spent reaping. |
3541 |
* |
3542 |
* The arc_reaping_in_progress is a (somewhat racy) left over from a |
3543 |
* previous version of this code which could trigger multiple ARC cache |
3544 |
* reapings in parallel which should be avoided to reduce lock |
3545 |
* contention. It's hasn't been removed yet to encourage further |
3546 |
* experimenting. |
3547 |
*/ |
3548 |
static unsigned int arc_reaping_in_progress = 0; |
3549 |
static sbintime_t last_reaping = 0; |
3550 |
|
3551 |
static void __noinline |
3552 |
reap_arc_caches(void) |
3553 |
{ |
3554 |
size_t i; |
3555 |
kmem_cache_t *prev_cache = NULL; |
3556 |
kmem_cache_t *prev_data_cache = NULL; |
3557 |
|
3558 |
for (i = 0; i < SPA_MAXBLOCKSIZE >> SPA_MINBLOCKSHIFT; i++) { |
3559 |
if (zio_buf_cache[i] != prev_cache) { |
3560 |
prev_cache = zio_buf_cache[i]; |
3561 |
kmem_cache_reap_now(zio_buf_cache[i]); |
3562 |
} |
3563 |
if (zio_data_buf_cache[i] != prev_data_cache) { |
3564 |
prev_data_cache = zio_data_buf_cache[i]; |
3565 |
kmem_cache_reap_now(zio_data_buf_cache[i]); |
3566 |
} |
3567 |
} |
3568 |
kmem_cache_reap_now(buf_cache); |
3569 |
kmem_cache_reap_now(hdr_full_cache); |
3570 |
kmem_cache_reap_now(hdr_l2only_cache); |
3571 |
kmem_cache_reap_now(range_seg_cache); |
3572 |
} |
3573 |
|
3527 |
static __noinline void |
3574 |
static __noinline void |
3528 |
arc_kmem_reap_now(void) |
3575 |
arc_kmem_reap_now(void) |
3529 |
{ |
3576 |
{ |
Lines 3532-3537
Link Here
|
3532 |
kmem_cache_t *prev_data_cache = NULL; |
3579 |
kmem_cache_t *prev_data_cache = NULL; |
3533 |
|
3580 |
|
3534 |
DTRACE_PROBE(arc__kmem_reap_start); |
3581 |
DTRACE_PROBE(arc__kmem_reap_start); |
|
|
3582 |
arc_reaping_in_progress++; |
3583 |
|
3535 |
#ifdef _KERNEL |
3584 |
#ifdef _KERNEL |
3536 |
if (arc_meta_used >= arc_meta_limit) { |
3585 |
if (arc_meta_used >= arc_meta_limit) { |
3537 |
/* |
3586 |
/* |
Lines 3548-3567
Link Here
|
3548 |
#endif |
3597 |
#endif |
3549 |
#endif |
3598 |
#endif |
3550 |
|
3599 |
|
3551 |
for (i = 0; i < SPA_MAXBLOCKSIZE >> SPA_MINBLOCKSHIFT; i++) { |
3600 |
reap_arc_caches(); |
3552 |
if (zio_buf_cache[i] != prev_cache) { |
|
|
3553 |
prev_cache = zio_buf_cache[i]; |
3554 |
kmem_cache_reap_now(zio_buf_cache[i]); |
3555 |
} |
3556 |
if (zio_data_buf_cache[i] != prev_data_cache) { |
3557 |
prev_data_cache = zio_data_buf_cache[i]; |
3558 |
kmem_cache_reap_now(zio_data_buf_cache[i]); |
3559 |
} |
3560 |
} |
3561 |
kmem_cache_reap_now(buf_cache); |
3562 |
kmem_cache_reap_now(hdr_full_cache); |
3563 |
kmem_cache_reap_now(hdr_l2only_cache); |
3564 |
kmem_cache_reap_now(range_seg_cache); |
3565 |
|
3601 |
|
3566 |
#ifdef sun |
3602 |
#ifdef sun |
3567 |
if (zio_arena != NULL) { |
3603 |
if (zio_arena != NULL) { |
Lines 3572-3581
Link Here
|
3572 |
vmem_qcache_reap(zio_arena); |
3608 |
vmem_qcache_reap(zio_arena); |
3573 |
} |
3609 |
} |
3574 |
#endif |
3610 |
#endif |
|
|
3611 |
#ifdef _KERNEL |
3612 |
last_reaping = getsbinuptime(); |
3613 |
#endif |
3614 |
arc_reaping_in_progress = 0; |
3575 |
DTRACE_PROBE(arc__kmem_reap_end); |
3615 |
DTRACE_PROBE(arc__kmem_reap_end); |
3576 |
} |
3616 |
} |
3577 |
|
3617 |
|
|
|
3618 |
|
3578 |
/* |
3619 |
/* |
|
|
3620 |
* Declared writable to allow resetting it. |
3621 |
* XXX: Should probably be a uint64 and integrated with kstat. |
3622 |
*/ |
3623 |
static unsigned int arc_cache_reapings_skipped = 0; |
3624 |
SYSCTL_UINT(_vfs_zfs, OID_AUTO, arc_cache_reapings_skipped, CTLFLAG_RW, |
3625 |
&arc_cache_reapings_skipped, 0, "Number of times the ARC caches have not been reaped due to the reap delay"); |
3626 |
|
3627 |
static unsigned int min_arc_reap_delay = 200; |
3628 |
SYSCTL_UINT(_vfs_zfs, OID_AUTO, arc_reap_delay_min, CTLFLAG_RW, |
3629 |
&min_arc_reap_delay, 200, "Minimum delay between ARC cache reapings (milliseconds)"); |
3630 |
|
3631 |
static void __noinline |
3632 |
consider_reaping_arc_caches(void) |
3633 |
{ |
3634 |
#ifdef _KERNEL |
3635 |
sbintime_t now; |
3636 |
|
3637 |
if (arc_reaping_in_progress) |
3638 |
{ |
3639 |
/* Already reaping in another thread. */ |
3640 |
arc_cache_reapings_skipped++; |
3641 |
return; |
3642 |
} |
3643 |
|
3644 |
now = getsbinuptime(); |
3645 |
if ((now - last_reaping) / SBT_1MS < min_arc_reap_delay) |
3646 |
{ |
3647 |
/* Too soon to reap again. */ |
3648 |
arc_cache_reapings_skipped++; |
3649 |
return; |
3650 |
} |
3651 |
#endif |
3652 |
arc_kmem_reap_now(); |
3653 |
} |
3654 |
|
3655 |
/* |
3579 |
* Threads can block in arc_get_data_buf() waiting for this thread to evict |
3656 |
* Threads can block in arc_get_data_buf() waiting for this thread to evict |
3580 |
* enough data and signal them to proceed. When this happens, the threads in |
3657 |
* enough data and signal them to proceed. When this happens, the threads in |
3581 |
* arc_get_data_buf() are sleeping while holding the hash lock for their |
3658 |
* arc_get_data_buf() are sleeping while holding the hash lock for their |
Lines 3617-3624
Link Here
|
3617 |
*/ |
3694 |
*/ |
3618 |
growtime = ddi_get_lbolt() + (arc_grow_retry * hz); |
3695 |
growtime = ddi_get_lbolt() + (arc_grow_retry * hz); |
3619 |
|
3696 |
|
3620 |
arc_kmem_reap_now(); |
|
|
3621 |
|
3622 |
/* |
3697 |
/* |
3623 |
* If we are still low on memory, shrink the ARC |
3698 |
* If we are still low on memory, shrink the ARC |
3624 |
* so that we have arc_shrink_min free space. |
3699 |
* so that we have arc_shrink_min free space. |
Lines 3692-3697
Link Here
|
3692 |
while (!arc_user_evicts_thread_exit) { |
3767 |
while (!arc_user_evicts_thread_exit) { |
3693 |
mutex_exit(&arc_user_evicts_lock); |
3768 |
mutex_exit(&arc_user_evicts_lock); |
3694 |
|
3769 |
|
|
|
3770 |
/* |
3771 |
* Consider reaping the ARC caches at least once per |
3772 |
* second, but more often when signalled under pressure. |
3773 |
*/ |
3774 |
consider_reaping_arc_caches(); |
3775 |
|
3695 |
arc_do_user_evicts(); |
3776 |
arc_do_user_evicts(); |
3696 |
|
3777 |
|
3697 |
/* |
3778 |
/* |