This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
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.
Siddhesh
> + {
> + /* Try to shrink. */
> + if (shrink_heap (heap, extra) != 0)
> + return 0;
>
> - ar_ptr->system_mem -= extra;
> - arena_mem -= extra;
> + ar_ptr->system_mem -= extra;
> + arena_mem -= extra;
>
> - /* Success. Adjust top accordingly. */
> - set_head (top_chunk, (top_size - extra) | PREV_INUSE);
> - /*check_chunk(ar_ptr, top_chunk);*/
> - return 1;
> + /* Success. Adjust top accordingly. */
> + set_head (top_chunk, (top_size - extra) | PREV_INUSE);
> + /*check_chunk(ar_ptr, top_chunk);*/
> + return 1;
> + }
> + return 0;
> }
>
> /* Create a new arena with initial size "size". */
Attachment:
pgpyIGfLmQGxQ.pgp
Description: PGP signature
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |