From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1944) id 4C468384B060; Thu, 11 Mar 2021 17:38:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4C468384B060 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Szabolcs Nagy To: glibc-cvs@sourceware.org Subject: [glibc/nsz/mtag] malloc: Avoid taggig mmaped memory on free X-Act-Checkin: glibc X-Git-Author: Szabolcs Nagy X-Git-Refname: refs/heads/nsz/mtag X-Git-Oldrev: 474064c5d992d292aa6e6d535fc030a340d380e9 X-Git-Newrev: d9ba54fe178563174ff409481553f67b2e65296e Message-Id: <20210311173850.4C468384B060@sourceware.org> Date: Thu, 11 Mar 2021 17:38:50 +0000 (GMT) X-BeenThere: glibc-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Mar 2021 17:38:50 -0000 https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=d9ba54fe178563174ff409481553f67b2e65296e commit d9ba54fe178563174ff409481553f67b2e65296e Author: Szabolcs Nagy Date: Thu Feb 4 11:52:14 2021 +0000 malloc: Avoid taggig mmaped memory on free Either the memory belongs to the dumped area, in which case we don't want to tag (the dumped area has the same tag as malloc internal data so tagging is unnecessary, but chunks there may not have the right alignment for the tag granule), or the memory will be unmapped immediately (and thus tagging is not useful). Reviewed-by: DJ Delorie Diff: --- malloc/malloc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/malloc/malloc.c b/malloc/malloc.c index 61c25d0f93..ecb87350b0 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -3284,9 +3284,6 @@ __libc_free (void *mem) p = mem2chunk (mem); - /* Mark the chunk as belonging to the library again. */ - (void)TAG_REGION (chunk2rawmem (p), CHUNK_AVAILABLE_SIZE (p) - CHUNK_HDR_SZ); - if (chunk_is_mmapped (p)) /* release mmapped memory. */ { /* See if the dynamic brk/mmap threshold needs adjusting. @@ -3307,6 +3304,10 @@ __libc_free (void *mem) { MAYBE_INIT_TCACHE (); + /* Mark the chunk as belonging to the library again. */ + (void)TAG_REGION (chunk2rawmem (p), + CHUNK_AVAILABLE_SIZE (p) - CHUNK_HDR_SZ); + ar_ptr = arena_for_chunk (p); _int_free (ar_ptr, p, 0); }