Re: only free pool pages from the gc task

2016-11-22 Thread Mark Kettenis
> Date: Tue, 22 Nov 2016 12:45:44 +1000
> From: David Gwynne 
> 
> 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 -  1.204
> +++ subr_pool.c   22 Nov 2016 02:43:23 -
> @@ -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);
> 
> 



Re: only free pool pages from the gc task

2016-11-22 Thread Martin Pieuchot
On 22/11/16(Tue) 12:45, David Gwynne wrote:
> [...] 
> 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.

Any number, analysis or reference to back your claim?