View | Details | Raw Unified | Return to bug 187594 | Differences between
and this patch

Collapse All | Expand All

(-)cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c (+52 lines)
Lines 237-243 int zfs_arc_p_min_shift = 0; Link Here
237
int zfs_disable_dup_eviction = 0;
237
int zfs_disable_dup_eviction = 0;
238
uint64_t zfs_arc_average_blocksize = 8 * 1024; /* 8KB */
238
uint64_t zfs_arc_average_blocksize = 8 * 1024; /* 8KB */
239
u_int zfs_arc_free_target = 0;
239
u_int zfs_arc_free_target = 0;
240
u_int zfs_arc_wakeup_pager = 0;
241
u_int zfs_arc_wakeup_delay = 500;
240
242
243
#define	WAKE_PAGER
244
#ifdef	WAKE_PAGER
245
#define	WAKE_PAGER_CONSTANT	10 / 9	/* Pager wakeup threshold */
246
static	int	arc_init_done = 0;	/* After arc_warm is valid */
247
extern void pagedaemon_wakeup(void);
248
#endif
249
241
/* Absolute min for arc min / max is 16MB. */
250
/* Absolute min for arc min / max is 16MB. */
242
static uint64_t arc_abs_min = 16 << 20;
251
static uint64_t arc_abs_min = 16 << 20;
243
252
Lines 252-257 arc_free_target_init(void *unused __unused) Link Here
252
{
261
{
253
262
254
	zfs_arc_free_target = vm_pageout_wakeup_thresh;
263
	zfs_arc_free_target = vm_pageout_wakeup_thresh;
264
	zfs_arc_wakeup_pager = zfs_arc_free_target * WAKE_PAGER_CONSTANT;
255
}
265
}
256
SYSINIT(arc_free_target_init, SI_SUB_KTHREAD_PAGE, SI_ORDER_ANY,
266
SYSINIT(arc_free_target_init, SI_SUB_KTHREAD_PAGE, SI_ORDER_ANY,
257
    arc_free_target_init, NULL);
267
    arc_free_target_init, NULL);
Lines 3476-3481 int64_t arc_pages_pp_reserve = 64; Link Here
3476
int64_t arc_swapfs_reserve = 64;
3486
int64_t arc_swapfs_reserve = 64;
3477
3487
3478
/*
3488
/*
3489
 * Declare file-local static for event processor bypass
3490
 */
3491
static unsigned int arc_no_wake_event = 0;
3492
3493
/*
3479
 * Return the amount of memory that can be consumed before reclaim will be
3494
 * Return the amount of memory that can be consumed before reclaim will be
3480
 * needed.  Positive if there is sufficient free memory, negative indicates
3495
 * needed.  Positive if there is sufficient free memory, negative indicates
3481
 * the amount of memory that needs to be freed up.
3496
 * the amount of memory that needs to be freed up.
Lines 3488-3493 arc_available_memory(void) Link Here
3488
	free_memory_reason_t r = FMR_UNKNOWN;
3503
	free_memory_reason_t r = FMR_UNKNOWN;
3489
3504
3490
#ifdef _KERNEL
3505
#ifdef _KERNEL
3506
#ifdef WAKE_PAGER
3507
	sbintime_t now;
3508
	static sbintime_t last_pagedaemon_wake = 0;
3509
	void call_arc_kmem_reap(void);
3510
#endif	/* WAKE_PAGER */
3511
3491
	if (needfree > 0) {
3512
	if (needfree > 0) {
3492
		n = PAGESIZE * (-needfree);
3513
		n = PAGESIZE * (-needfree);
3493
		if (n < lowest) {
3514
		if (n < lowest) {
Lines 3495-3500 arc_available_memory(void) Link Here
3495
			r = FMR_NEEDFREE;
3516
			r = FMR_NEEDFREE;
3496
		}
3517
		}
3497
	}
3518
	}
3519
#ifdef WAKE_PAGER
3520
/*
3521
 * If memory is less than the ARC wakeup threshold and time has expired since
3522
 * the last time we woke the pager... Do not execute until the ARC warms up.
3523
 */
3524
	if ((arc_init_done) &&
3525
		(((int64_t) freemem - zfs_arc_wakeup_pager) < 0) &&
3526
		(arc_warm == B_TRUE)
3527
	) {
3528
		now = getsbinuptime();
3529
		if ((now - last_pagedaemon_wake) / SBT_1MS > zfs_arc_wakeup_delay) {
3530
			last_pagedaemon_wake = now;
3531
			arc_no_wake_event++;    /* Set bypass flag for ARC */
3532
			call_arc_kmem_reap();	/* Reap caches if we're close */
3533
			DTRACE_PROBE(arc__wake_pagedaemon);
3534
			(void) pagedaemon_wakeup();    /* Wake the pager */
3535
		}
3536
	}
3537
#endif /* WAKE_PAGER */
3498
3538
3499
	/*
3539
	/*
3500
	 * Cooperate with pagedaemon when it's time for it to scan
3540
	 * Cooperate with pagedaemon when it's time for it to scan
Lines 3684-3689 arc_kmem_reap_now(void) Link Here
3684
	DTRACE_PROBE(arc__kmem_reap_end);
3724
	DTRACE_PROBE(arc__kmem_reap_end);
3685
}
3725
}
3686
3726
3727
void	call_arc_kmem_reap()
3728
{
3729
	arc_kmem_reap_now();
3730
}
3731
3687
/*
3732
/*
3688
 * Threads can block in arc_get_data_buf() waiting for this thread to evict
3733
 * Threads can block in arc_get_data_buf() waiting for this thread to evict
3689
 * enough data and signal them to proceed. When this happens, the threads in
3734
 * enough data and signal them to proceed. When this happens, the threads in
Lines 5431-5436 static eventhandler_tag arc_event_lowmem = NULL; Link Here
5431
static void
5476
static void
5432
arc_lowmem(void *arg __unused, int howto __unused)
5477
arc_lowmem(void *arg __unused, int howto __unused)
5433
{
5478
{
5479
	if (arc_no_wake_event) {        /* Don't do it if we woke the pager */
5480
		arc_no_wake_event = 0;  /* Just clear the flag */
5481
		return;
5482
	}
5434
5483
5435
	mutex_enter(&arc_reclaim_lock);
5484
	mutex_enter(&arc_reclaim_lock);
5436
	/* XXX: Memory deficit should be passed as argument. */
5485
	/* XXX: Memory deficit should be passed as argument. */
Lines 5696-5701 arc_init(void) Link Here
5696
		printf("             in /boot/loader.conf.\n");
5745
		printf("             in /boot/loader.conf.\n");
5697
	}
5746
	}
5698
#endif
5747
#endif
5748
#ifdef	WAKE_PAGER
5749
	arc_init_done++;
5750
#endif	/* WAKE_PAGER */
5699
}
5751
}
5700
5752
5701
void
5753
void

Return to bug 187594