[PATCH v2.1][BZ #11087] Use atomic operations to track memory

Siddhesh Poyarekar siddhesh@redhat.com
Mon Oct 28 06:29:00 GMT 2013


On Fri, Oct 25, 2013 at 08:07:28PM +0200, Ondřej Bílka wrote:
> @@ -2822,10 +2821,10 @@ mremap_chunk(mchunkptr p, size_t new_size)
>    assert((p->prev_size == offset));
>    set_head(p, (new_size - offset)|IS_MMAPPED);
>  
> -  mp_.mmapped_mem -= size + offset;
> -  mp_.mmapped_mem += new_size;
> -  if ((unsigned long)mp_.mmapped_mem > (unsigned long)mp_.max_mmapped_mem)
> -    mp_.max_mmapped_mem = mp_.mmapped_mem;
> +  INTERNAL_SIZE_T new;
> +  new = atomic_exchange_and_add (&mp_.mmapped_mem, new_size - size - offset) +
> +  + new_size - size - offset;
> +  atomic_max (&mp_.max_mmapped_mem, new);
>    return p;
>  }
>  

You have an extra plus sign there.  Also, the formatting is wrong.

Siddhesh



More information about the Libc-alpha mailing list