> Date: Tue, 22 Nov 2016 12:45:44 +1000
> From: David Gwynne <[email protected]>
>
> at the moment pages can be freed on a pool_put call and from the gc.
>
> it is a bit unfair that pool_get may end up doing the heavy lifting
> of allocating a pool page and pool_put wont have to do an equivalent
> free, but we should try and minimise the amount of work done in
> these hot paths.
>
> ok?
A potentially serious downside of this approach is that this makes us
rely on a thread to run in order to free up memory. That may be ok
now that most of the network stack runs out of a thread. But I'm not
confident (yet) that this is safe.
Best not to pile this immediately onto the other pool changes.
> Index: subr_pool.c
> ===================================================================
> RCS file: /cvs/src/sys/kern/subr_pool.c,v
> retrieving revision 1.204
> diff -u -p -r1.204 subr_pool.c
> --- subr_pool.c 21 Nov 2016 01:44:06 -0000 1.204
> +++ subr_pool.c 22 Nov 2016 02:43:23 -0000
> @@ -707,7 +707,7 @@ void
> pool_put(struct pool *pp, void *v)
> {
> struct pool_item *pi = v;
> - struct pool_page_header *ph, *freeph = NULL;
> + struct pool_page_header *ph;
>
> #ifdef DIAGNOSTIC
> if (v == NULL)
> @@ -770,17 +770,7 @@ pool_put(struct pool *pp, void *v)
> pp->pr_nout--;
> pp->pr_nput++;
>
> - /* is it time to free a page? */
> - if (pp->pr_nidle > pp->pr_maxpages &&
> - (ph = TAILQ_FIRST(&pp->pr_emptypages)) != NULL &&
> - (ticks - ph->ph_tick) > (hz * pool_wait_free)) {
> - freeph = ph;
> - pool_p_remove(pp, freeph);
> - }
> mtx_leave(&pp->pr_mtx);
> -
> - if (freeph != NULL)
> - pool_p_free(pp, freeph);
>
> if (!TAILQ_EMPTY(&pp->pr_requests)) {
> mtx_enter(&pp->pr_requests_mtx);
>
>