[PATCH] [v5] malloc: Consistently apply trim_threshold to all heaps [BZ #17195]

Mel Gorman mgorman@suse.de
Fri Feb 20 13:17:00 GMT 2015


On Fri, Feb 20, 2015 at 06:14:20PM +0530, Siddhesh Poyarekar wrote:
> On Thu, Feb 19, 2015 at 10:42:05AM +0000, Mel Gorman wrote:
> > 2015-02-19  Mel Gorman  <mgorman@suse.de>
> > 
> >   [BZ #17195]
> >   * malloc/arena.c (free): Apply trim threshold to per-thread heaps
> >     as well as the main arena.
> > ---
> >  malloc/arena.c | 25 +++++++++++++------------
> >  1 file changed, 13 insertions(+), 12 deletions(-)
> > 
> > diff --git a/malloc/arena.c b/malloc/arena.c
> > index 886defb074a2..cdb4e900a66a 100644
> > --- a/malloc/arena.c
> > +++ b/malloc/arena.c
> > @@ -696,20 +696,21 @@ heap_trim (heap_info *heap, size_t pad)
> >      }
> >    top_size = chunksize (top_chunk);
> >    extra = (top_size - pad - MINSIZE - 1) & ~(pagesz - 1);
> > -  if (extra < (long) pagesz)
> > -    return 0;
> > -
> > -  /* Try to shrink. */
> > -  if (shrink_heap (heap, extra) != 0)
> > -    return 0;
> > +  if (extra >= (long) mp_.trim_threshold)
> 
> Cast EXTRA to unsigned long instead.  The above will break if trimming
> is disabled since it will always trim instead.
> 
> Why did you change the condition BTW?  The earlier one-line change was
> nicer and only needed to have the cast fixed.
> 

Only because it matched similar logic on the main arena.

-- 
Mel Gorman
SUSE Labs



More information about the Libc-alpha mailing list