diff options
author | joseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d> | 2007-01-09 13:36:33 +0000 |
---|---|---|
committer | joseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d> | 2007-01-09 13:36:33 +0000 |
commit | d5eb1af9881447485ac579723b442301880c3ecd (patch) | |
tree | 2a269b8c14ec9d02cc860d4cf969e9067a84eb59 /libc/malloc | |
parent | 16ace07529ae1123eaa768ce99f5e64a158a98cf (diff) | |
download | eglibc2-d5eb1af9881447485ac579723b442301880c3ecd.tar.gz |
Merge changes between r858 and r1147 /fsf/trunk.
git-svn-id: svn://svn.eglibc.org/trunk@1148 7b3dc134-2b1b-0410-93df-9e9f96275f8d
Diffstat (limited to 'libc/malloc')
-rw-r--r-- | libc/malloc/malloc.c | 22 | ||||
-rw-r--r-- | libc/malloc/memusage.c | 38 | ||||
-rwxr-xr-x | libc/malloc/memusage.sh | 4 | ||||
-rw-r--r-- | libc/malloc/memusagestat.c | 4 | ||||
-rw-r--r-- | libc/malloc/mtrace.pl | 4 |
5 files changed, 56 insertions, 16 deletions
diff --git a/libc/malloc/malloc.c b/libc/malloc/malloc.c index d15ed57bd..6427608a7 100644 --- a/libc/malloc/malloc.c +++ b/libc/malloc/malloc.c @@ -2896,7 +2896,13 @@ static Void_t* sYSMALLOc(nb, av) INTERNAL_SIZE_T nb; mstate av; is one SIZE_SZ unit larger than for normal chunks, because there is no following chunk whose prev_size field could be used. */ +#if 1 + /* See the front_misalign handling below, for glibc there is no + need for further alignments. */ + size = (nb + SIZE_SZ + pagemask) & ~pagemask; +#else size = (nb + SIZE_SZ + MALLOC_ALIGN_MASK + pagemask) & ~pagemask; +#endif tried_mmap = true; /* Don't try if size wraps around 0 */ @@ -2914,6 +2920,12 @@ static Void_t* sYSMALLOc(nb, av) INTERNAL_SIZE_T nb; mstate av; address argument for later munmap in free() and realloc(). */ +#if 1 + /* For glibc, chunk2mem increases the address by 2*SIZE_SZ and + MALLOC_ALIGN_MASK is 2*SIZE_SZ-1. Each mmap'ed area is page + aligned and therefore definitely MALLOC_ALIGN_MASK-aligned. */ + assert (((INTERNAL_SIZE_T)chunk2mem(mm) & MALLOC_ALIGN_MASK) == 0); +#else front_misalign = (INTERNAL_SIZE_T)chunk2mem(mm) & MALLOC_ALIGN_MASK; if (front_misalign > 0) { correction = MALLOC_ALIGNMENT - front_misalign; @@ -2921,10 +2933,12 @@ static Void_t* sYSMALLOc(nb, av) INTERNAL_SIZE_T nb; mstate av; p->prev_size = correction; set_head(p, (size - correction) |IS_MMAPPED); } - else { - p = (mchunkptr)mm; - set_head(p, size|IS_MMAPPED); - } + else +#endif + { + p = (mchunkptr)mm; + set_head(p, size|IS_MMAPPED); + } /* update statistics */ diff --git a/libc/malloc/memusage.c b/libc/malloc/memusage.c index bf2978ef0..d11e9e6ed 100644 --- a/libc/malloc/memusage.c +++ b/libc/malloc/memusage.c @@ -80,6 +80,7 @@ static memusage_cntr_t large; static memusage_cntr_t calls_total; static memusage_cntr_t inplace; static memusage_cntr_t decreasing; +static memusage_cntr_t realloc_free; static memusage_cntr_t inplace_mremap; static memusage_cntr_t decreasing_mremap; static memusage_size_t current_heap; @@ -103,8 +104,8 @@ extern const char *__progname; struct entry { - size_t heap; - size_t stack; + uint64_t heap; + uint64_t stack; uint32_t time_low; uint32_t time_high; }; @@ -267,6 +268,7 @@ me (void) GETTIME (first.time_low, first.time_high); /* Write it two times since we need the starting and end time. */ write (fd, &first, sizeof (first)); + write (fd, &first, sizeof (first)); /* Determine the buffer size. We use the default if the environment variable is not present. */ @@ -411,6 +413,23 @@ realloc (void *old, size_t len) /* Keep track of total memory requirement. */ catomic_add (&grand_total, len - old_len); } + + if (len == 0 && old != NULL) + { + /* Special case. */ + catomic_increment (&realloc_free); + /* Keep track of total memory freed using `free'. */ + catomic_add (&total[idx_free], real->length); + + /* Update the allocation data and write out the records if necessary. */ + update_data (NULL, 0, old_len); + + /* Do the real work. */ + (*freep) (real); + + return NULL; + } + /* Remember the size of the request. */ if (len < 65536) catomic_increment (&histogram[len / 16]); @@ -770,7 +789,12 @@ dest (void) if (fd != -1) { /* Write the partially filled buffer. */ - write (fd, buffer, buffer_cnt * sizeof (struct entry)); + if (buffer_cnt > buffer_size) + write (fd, buffer + buffer_size, + (buffer_cnt - buffer_size) * sizeof (struct entry)); + else + write (fd, buffer, buffer_cnt * sizeof (struct entry)); + /* Go back to the beginning of the file. We allocated two records here when we opened the file. */ lseek (fd, 0, SEEK_SET); @@ -794,7 +818,7 @@ dest (void) \e[01;32mMemory usage summary:\e[0;0m heap total: %llu, heap peak: %lu, stack peak: %lu\n\ \e[04;34m total calls total memory failed calls\e[0m\n\ \e[00;34m malloc|\e[0m %10lu %12llu %s%12lu\e[00;00m\n\ -\e[00;34mrealloc|\e[0m %10lu %12llu %s%12lu\e[00;00m (in place: %ld, dec: %ld)\n\ +\e[00;34mrealloc|\e[0m %10lu %12llu %s%12lu\e[00;00m (nomove:%ld, dec:%ld, free:%ld)\n\ \e[00;34m calloc|\e[0m %10lu %12llu %s%12lu\e[00;00m\n\ \e[00;34m free|\e[0m %10lu %12llu\n", (unsigned long long int) grand_total, (unsigned long int) peak_heap, @@ -807,7 +831,9 @@ dest (void) (unsigned long long int) total[idx_realloc], failed[idx_realloc] ? "\e[01;41m" : "", (unsigned long int) failed[idx_realloc], - (unsigned long int) inplace, (unsigned long int) decreasing, + (unsigned long int) inplace, + (unsigned long int) decreasing, + (unsigned long int) realloc_free, (unsigned long int) calls[idx_calloc], (unsigned long long int) total[idx_calloc], failed[idx_calloc] ? "\e[01;41m" : "", @@ -820,7 +846,7 @@ dest (void) \e[00;34mmmap(r)|\e[0m %10lu %12llu %s%12lu\e[00;00m\n\ \e[00;34mmmap(w)|\e[0m %10lu %12llu %s%12lu\e[00;00m\n\ \e[00;34mmmap(a)|\e[0m %10lu %12llu %s%12lu\e[00;00m\n\ -\e[00;34m mremap|\e[0m %10lu %12llu %s%12lu\e[00;00m (in place: %ld, dec: %ld)\n\ +\e[00;34m mremap|\e[0m %10lu %12llu %s%12lu\e[00;00m (nomove: %ld, dec:%ld)\n\ \e[00;34m munmap|\e[0m %10lu %12llu %s%12lu\e[00;00m\n", (unsigned long int) calls[idx_mmap_r], (unsigned long long int) total[idx_mmap_r], diff --git a/libc/malloc/memusage.sh b/libc/malloc/memusage.sh index ad833523f..67af4998c 100755 --- a/libc/malloc/memusage.sh +++ b/libc/malloc/memusage.sh @@ -1,5 +1,5 @@ #! @BASH@ -# Copyright (C) 1999-2004, 2005, 2006 Free Software Foundation, Inc. +# Copyright (C) 1999-2004, 2005, 2006, 2007 Free Software Foundation, Inc. # This file is part of the GNU C Library. # Contributed by Ulrich Drepper <drepper@gnu.org>, 1999. @@ -71,7 +71,7 @@ do_version() { printf $"Copyright (C) %s Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -" "2006" +" "2007" printf $"Written by %s. " "Ulrich Drepper" exit 0 diff --git a/libc/malloc/memusagestat.c b/libc/malloc/memusagestat.c index d8fc71b72..93ac2cd74 100644 --- a/libc/malloc/memusagestat.c +++ b/libc/malloc/memusagestat.c @@ -81,8 +81,8 @@ static struct argp argp = struct entry { - size_t heap; - size_t stack; + uint64_t heap; + uint64_t stack; uint32_t time_low; uint32_t time_high; }; diff --git a/libc/malloc/mtrace.pl b/libc/malloc/mtrace.pl index 8a0fbc7e9..280b469d9 100644 --- a/libc/malloc/mtrace.pl +++ b/libc/malloc/mtrace.pl @@ -1,7 +1,7 @@ #! @PERL@ eval "exec @PERL@ -S $0 $*" if 0; -# Copyright (C) 1997-2004, 2005, 2006 Free Software Foundation, Inc. +# Copyright (C) 1997-2004, 2005, 2006, 2007 Free Software Foundation, Inc. # This file is part of the GNU C Library. # Contributed by Ulrich Drepper <drepper@gnu.org>, 1997. # Based on the mtrace.awk script. @@ -45,7 +45,7 @@ arglist: while (@ARGV) { $ARGV[0] eq "--vers" || $ARGV[0] eq "--versi" || $ARGV[0] eq "--versio" || $ARGV[0] eq "--version") { print "mtrace (GNU $PACKAGE) $VERSION\n"; - print "Copyright (C) 2006 Free Software Foundation, Inc.\n"; + print "Copyright (C) 2007 Free Software Foundation, Inc.\n"; print "This is free software; see the source for copying conditions. There is NO\n"; print "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"; print "Written by Ulrich Drepper <drepper\@gnu.org>\n"; |