Date: Tue, 11 Aug 2015 14:21:37 +0200 From: Baptiste Daroussin <bapt@FreeBSD.org> To: Alexander Motin <mav@FreeBSD.org> Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r286625 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs Message-ID: <20150811122137.GI96980@ivaldir.etoilebsd.net> In-Reply-To: <201508111039.t7BAdK1x071658@repo.freebsd.org> References: <201508111039.t7BAdK1x071658@repo.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--81JctsDUVPekGcy+ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 >=20 > Log: > MFV r277425: > 5376 arc_kmem_reap_now() should not result in clearing arc_no_grow > Reviewed by: Christopher Siden <christopher.siden@delphix.com> > Reviewed by: George Wilson <george.wilson@delphix.com> > Reviewed by: Steven Hartland <killing@multiplay.co.uk> > Reviewed by: Richard Elling <richard.elling@richardelling.com> > Approved by: Dan McDonald <danmcd@omniti.com> > Author: Matthew Ahrens <mahrens@delphix.com> > =20 > illumos/illumos-gate@2ec99e3e987d8aa273f1e9ba2b983557d058198c >=20 > Modified: > head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c >=20 > Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- 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; > =20 > -#define ARC_REDUCE_DNLC_PERCENT 3 > -uint_t arc_reduce_dnlc_percent =3D 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 =3D 3; > =20 > /* > * The number of iterations through arc_evict_*() before we > @@ -174,7 +168,19 @@ static int arc_grow_retry =3D 60; > static int arc_p_min_shift =3D 4; > =20 > /* log2(fraction of arc to reclaim) */ > -static int arc_shrink_shift =3D 5; > +static int arc_shrink_shift =3D 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 b= lock > + * from the ARC. > + * > + * This must be less than arc_shrink_shift, so that when we shrink the A= RC, > + * we will still not allow it to grow. > + */ > +int arc_no_grow_shift =3D 5; > + > =20 > /* > * minimum lifespan of a prefetch block in clock ticks > @@ -3055,13 +3061,10 @@ arc_flush(spa_t *spa) > } > =20 > void > -arc_shrink(void) > +arc_shrink(int64_t to_free) > { > =20 > if (arc_c > arc_c_min) { > - uint64_t to_free; > - > - to_free =3D 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) > } > } > =20 > -static int needfree =3D 0; > +static long needfree =3D 0; > =20 > -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 =3D 64; > + > +/* > + * Additional reserve of pages for swapfs. > + */ > +int64_t arc_swapfs_reserve =3D 64; > + > +/* > + * Return the amount of memory that can be consumed before reclaim will = be > + * needed. Positive if there is sufficient free memory, negative indica= tes > + * the amount of memory that needs to be freed up. > + */ > +static int64_t > +arc_available_memory(void) > { > + int64_t lowest =3D INT64_MAX; > + int64_t n; > + free_memory_reason_t r =3D FMR_UNKNOWN; > =20 > #ifdef _KERNEL > - > - if (needfree) { > - DTRACE_PROBE(arc__reclaim_needfree); > - return (1); > + if (needfree > 0) { > + n =3D PAGESIZE * (-needfree); > + if (n < lowest) { > + lowest =3D n; > + r =3D FMR_NEEDFREE; > + } > } > =20 > /* > * 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 =3D PAGESIZE * (int64_t)(freemem - zfs_arc_free_target); > + if (n < lowest) { > + lowest =3D n; > + r =3D FMR_LOTSFREE; > } > =20 > #ifdef illumos > /* > - * take 'desfree' extra pages, so we reclaim sooner, rather than later > - */ > - extra =3D 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 =3D PAGESIZE * (freemem - lotsfree - needfree - desfree); > + if (n < lowest) { > + lowest =3D n; > + r =3D FMR_LOTSFREE; > + } > =20 > /* > * 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 =3D PAGESIZE * (availrmem - swapfs_minfree - swapfs_reserve - > + desfree - arc_swapfs_reserve); > + if (n < lowest) { > + lowest =3D n; > + r =3D FMR_SWAPFS_MINFREE; > + } > + > =20 > /* > * 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 <=3D pages_pp_maximum) > - return (1); > + n =3D PAGESIZE * (availrmem - pages_pp_maximum - > + arc_pages_pp_reserve); > + if (n < lowest) { > + lowest =3D n; > + r =3D FMR_PAGES_PP_MAXIMUM; > + } > =20 > #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 =3D vmem_size(heap_arena, VMEM_FREE) - > + (vmem_size(heap_arena, VMEM_FREE | VMEM_ALLOC) >> 2) Missing a ';' here Best regards, Bapt --81JctsDUVPekGcy+ Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAlXJ6NEACgkQ8kTtMUmk6Ey2kwCggjPXwGjvElzuHhgVCcEWn26l BIAAn3F49yU/aFnQ8V/gV8PS/X0kbzCM =CV17 -----END PGP SIGNATURE----- --81JctsDUVPekGcy+--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20150811122137.GI96980>