> On 5 Jul 2017, at 20:11, Visa Hankala wrote:
>
> The current pool cache code increases the number of items that can be
> cached locally in response to lock contention. This patch adds a tweak
> that lowers the number when contention does not occur. The idea is to
> let resources be returned to the common pool when pressure on the cache
> has decreased.
>
> This change alone does not move elements from the cache to the common
> pool. The cache has to have some activity for the moving to happen.
>
> It is likely that `pr_cache_items' does not settle on a single value
> but oscillates within some range. In my testing, I have not seen any
> wild swings that would indicate positive feedback in the process.
> The adjustments are constant per step and happen relatively rarely.
>
> OK?
ok
>
> Index: kern/subr_pool.c
> ===
> RCS file: src/sys/kern/subr_pool.c,v
> retrieving revision 1.217
> diff -u -p -r1.217 subr_pool.c
> --- kern/subr_pool.c 23 Jun 2017 01:21:55 - 1.217
> +++ kern/subr_pool.c 5 Jul 2017 09:27:40 -
> @@ -1957,6 +1957,9 @@ pool_cache_gc(struct pool *pp)
> if ((contention - pp->pr_cache_contention_prev) > 8 /* magic */) {
> if ((ncpusfound * 8 * 2) <= pp->pr_cache_nitems)
> pp->pr_cache_items += 8;
> + } else if ((contention - pp->pr_cache_contention_prev) == 0) {
> + if (pp->pr_cache_items > 8)
> + pp->pr_cache_items--;
> }
> pp->pr_cache_contention_prev = contention;
> }
>