svn commit: r286625 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs
Baptiste Daroussin
bapt at FreeBSD.org
Tue Aug 11 12:21:43 UTC 2015
On Tue, Aug 11, 2015 at 10:39:20AM +0000, Alexander Motin wrote:
> Author: mav
> Date: Tue Aug 11 10:39:19 2015
> New Revision: 286625
> URL: https://svnweb.freebsd.org/changeset/base/286625
>
> Log:
> MFV r277425:
> 5376 arc_kmem_reap_now() should not result in clearing arc_no_grow
> Reviewed by: Christopher Siden <christopher.siden at delphix.com>
> Reviewed by: George Wilson <george.wilson at delphix.com>
> Reviewed by: Steven Hartland <killing at multiplay.co.uk>
> Reviewed by: Richard Elling <richard.elling at richardelling.com>
> Approved by: Dan McDonald <danmcd at omniti.com>
> Author: Matthew Ahrens <mahrens at delphix.com>
>
> illumos/illumos-gate at 2ec99e3e987d8aa273f1e9ba2b983557d058198c
>
> Modified:
> head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
>
> Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
> ==============================================================================
> --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Tue Aug 11 09:26:11 2015 (r286624)
> +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Tue Aug 11 10:39:19 2015 (r286625)
> @@ -153,13 +153,7 @@ static kmutex_t arc_reclaim_thr_lock;
> static kcondvar_t arc_reclaim_thr_cv; /* used to signal reclaim thr */
> static uint8_t arc_thread_exit;
>
> -#define ARC_REDUCE_DNLC_PERCENT 3
> -uint_t arc_reduce_dnlc_percent = ARC_REDUCE_DNLC_PERCENT;
> -
> -typedef enum arc_reclaim_strategy {
> - ARC_RECLAIM_AGGR, /* Aggressive reclaim strategy */
> - ARC_RECLAIM_CONS /* Conservative reclaim strategy */
> -} arc_reclaim_strategy_t;
> +uint_t arc_reduce_dnlc_percent = 3;
>
> /*
> * The number of iterations through arc_evict_*() before we
> @@ -174,7 +168,19 @@ static int arc_grow_retry = 60;
> static int arc_p_min_shift = 4;
>
> /* log2(fraction of arc to reclaim) */
> -static int arc_shrink_shift = 5;
> +static int arc_shrink_shift = 7;
> +
> +/*
> + * log2(fraction of ARC which must be free to allow growing).
> + * I.e. If there is less than arc_c >> arc_no_grow_shift free memory,
> + * when reading a new block into the ARC, we will evict an equal-sized block
> + * from the ARC.
> + *
> + * This must be less than arc_shrink_shift, so that when we shrink the ARC,
> + * we will still not allow it to grow.
> + */
> +int arc_no_grow_shift = 5;
> +
>
> /*
> * minimum lifespan of a prefetch block in clock ticks
> @@ -3055,13 +3061,10 @@ arc_flush(spa_t *spa)
> }
>
> void
> -arc_shrink(void)
> +arc_shrink(int64_t to_free)
> {
>
> if (arc_c > arc_c_min) {
> - uint64_t to_free;
> -
> - to_free = arc_c >> arc_shrink_shift;
> DTRACE_PROBE4(arc__shrink, uint64_t, arc_c, uint64_t,
> arc_c_min, uint64_t, arc_p, uint64_t, to_free);
> if (arc_c > arc_c_min + to_free)
> @@ -3089,44 +3092,76 @@ arc_shrink(void)
> }
> }
>
> -static int needfree = 0;
> +static long needfree = 0;
>
> -static int
> -arc_reclaim_needed(void)
> +typedef enum free_memory_reason_t {
> + FMR_UNKNOWN,
> + FMR_NEEDFREE,
> + FMR_LOTSFREE,
> + FMR_SWAPFS_MINFREE,
> + FMR_PAGES_PP_MAXIMUM,
> + FMR_HEAP_ARENA,
> + FMR_ZIO_ARENA,
> + FMR_ZIO_FRAG,
> +} free_memory_reason_t;
> +
> +int64_t last_free_memory;
> +free_memory_reason_t last_free_reason;
> +
> +/*
> + * Additional reserve of pages for pp_reserve.
> + */
> +int64_t arc_pages_pp_reserve = 64;
> +
> +/*
> + * Additional reserve of pages for swapfs.
> + */
> +int64_t arc_swapfs_reserve = 64;
> +
> +/*
> + * Return the amount of memory that can be consumed before reclaim will be
> + * needed. Positive if there is sufficient free memory, negative indicates
> + * the amount of memory that needs to be freed up.
> + */
> +static int64_t
> +arc_available_memory(void)
> {
> + int64_t lowest = INT64_MAX;
> + int64_t n;
> + free_memory_reason_t r = FMR_UNKNOWN;
>
> #ifdef _KERNEL
> -
> - if (needfree) {
> - DTRACE_PROBE(arc__reclaim_needfree);
> - return (1);
> + if (needfree > 0) {
> + n = PAGESIZE * (-needfree);
> + if (n < lowest) {
> + lowest = n;
> + r = FMR_NEEDFREE;
> + }
> }
>
> /*
> * Cooperate with pagedaemon when it's time for it to scan
> * and reclaim some pages.
> */
> - if (freemem < zfs_arc_free_target) {
> - DTRACE_PROBE2(arc__reclaim_freemem, uint64_t,
> - freemem, uint64_t, zfs_arc_free_target);
> - return (1);
> + n = PAGESIZE * (int64_t)(freemem - zfs_arc_free_target);
> + if (n < lowest) {
> + lowest = n;
> + r = FMR_LOTSFREE;
> }
>
> #ifdef illumos
> /*
> - * take 'desfree' extra pages, so we reclaim sooner, rather than later
> - */
> - extra = desfree;
> -
> - /*
> * check that we're out of range of the pageout scanner. It starts to
> * schedule paging if freemem is less than lotsfree and needfree.
> * lotsfree is the high-water mark for pageout, and needfree is the
> * number of needed free pages. We add extra pages here to make sure
> * the scanner doesn't start up while we're freeing memory.
> */
> - if (freemem < lotsfree + needfree + extra)
> - return (1);
> + n = PAGESIZE * (freemem - lotsfree - needfree - desfree);
> + if (n < lowest) {
> + lowest = n;
> + r = FMR_LOTSFREE;
> + }
>
> /*
> * check to make sure that swapfs has enough space so that anon
> @@ -3135,8 +3170,13 @@ arc_reclaim_needed(void)
> * swap pages. We also add a bit of extra here just to prevent
> * circumstances from getting really dire.
> */
> - if (availrmem < swapfs_minfree + swapfs_reserve + extra)
> - return (1);
> + n = PAGESIZE * (availrmem - swapfs_minfree - swapfs_reserve -
> + desfree - arc_swapfs_reserve);
> + if (n < lowest) {
> + lowest = n;
> + r = FMR_SWAPFS_MINFREE;
> + }
> +
>
> /*
> * Check that we have enough availrmem that memory locking (e.g., via
> @@ -3145,8 +3185,12 @@ arc_reclaim_needed(void)
> * drops below pages_pp_maximum, page locking mechanisms such as
> * page_pp_lock() will fail.)
> */
> - if (availrmem <= pages_pp_maximum)
> - return (1);
> + n = PAGESIZE * (availrmem - pages_pp_maximum -
> + arc_pages_pp_reserve);
> + if (n < lowest) {
> + lowest = n;
> + r = FMR_PAGES_PP_MAXIMUM;
> + }
>
> #endif /* illumos */
> #if defined(__i386) || !defined(UMA_MD_SMALL_ALLOC)
> @@ -3161,12 +3205,11 @@ arc_reclaim_needed(void)
> * heap is allocated. (Or, in the calculation, if less than 1/4th is
> * free)
> */
> - if (vmem_size(heap_arena, VMEM_FREE) <
> - (vmem_size(heap_arena, VMEM_FREE | VMEM_ALLOC) >> 2)) {
> - DTRACE_PROBE2(arc__reclaim_used, uint64_t,
> - vmem_size(heap_arena, VMEM_FREE), uint64_t,
> - (vmem_size(heap_arena, VMEM_FREE | VMEM_ALLOC)) >> 2);
> - return (1);
> + n = vmem_size(heap_arena, VMEM_FREE) -
> + (vmem_size(heap_arena, VMEM_FREE | VMEM_ALLOC) >> 2)
Missing a ';' here
Best regards,
Bapt
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/svn-src-head/attachments/20150811/c79708bc/attachment.bin>
More information about the svn-src-head
mailing list