diff options
author | Andreas Schwab <schwab@redhat.com> | 2009-10-30 16:11:14 +0100 |
---|---|---|
committer | Andreas Schwab <schwab@redhat.com> | 2009-10-30 16:11:14 +0100 |
commit | 017dd87448e913383a8be5773569f218e8c661c5 (patch) | |
tree | d9124fdbb290416e60553c87aa9f9f1750d7acb8 /malloc | |
parent | f8e81cec78280ef92014305c1e10a808b1260683 (diff) | |
parent | 3a83202db6e5591f2b72974c1ad98602c6620770 (diff) |
Merge remote branch 'origin/master' into fedora/master
Diffstat (limited to 'malloc')
-rw-r--r-- | malloc/malloc.c | 4 | ||||
-rw-r--r-- | malloc/memusage.c | 9 | ||||
-rw-r--r-- | malloc/memusagestat.c | 32 |
3 files changed, 26 insertions, 19 deletions
diff --git a/malloc/malloc.c b/malloc/malloc.c index 79ba6b6f06..ea10d17f85 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -6474,8 +6474,8 @@ malloc_info (int options, FILE *fp) fprintf (fp, "<total type=\"fast\" count=\"%zu\" size=\"%zu\"/>\n" "<total type=\"rest\" count=\"%zu\" size=\"%zu\"/>\n" - "<system type=\"current\" size=\"%zu\n/>\n" - "<system type=\"max\" size=\"%zu\n/>\n" + "<system type=\"current\" size=\"%zu\"/>\n" + "<system type=\"max\" size=\"%zu\"/>\n" "<aspace type=\"total\" size=\"%zu\"/>\n" "<aspace type=\"mprotect\" size=\"%zu\"/>\n" "</malloc>\n", diff --git a/malloc/memusage.c b/malloc/memusage.c index fcd58dc684..382261c1c4 100644 --- a/malloc/memusage.c +++ b/malloc/memusage.c @@ -163,15 +163,16 @@ update_data (struct header *result, size_t len, size_t old_len) if (fd != -1) { uatomic32_t idx = catomic_exchange_and_add (&buffer_cnt, 1); - if (idx >= 2 * buffer_size) + if (idx + 1 >= 2 * buffer_size) { /* We try to reset the counter to the correct range. If this fails because of another thread increasing the counter it does not matter since that thread will take care of the correction. */ - uatomic32_t reset = idx % (2 * buffer_size); - catomic_compare_and_exchange_val_acq (&buffer_cnt, reset, idx); - idx = reset; + uatomic32_t reset = (idx + 1) % (2 * buffer_size); + catomic_compare_and_exchange_val_acq (&buffer_cnt, reset, idx + 1); + if (idx >= 2 * buffer_size) + idx = reset - 1; } assert (idx < 2 * DEFAULT_BUFFER_SIZE); diff --git a/malloc/memusagestat.c b/malloc/memusagestat.c index bf33175415..4d57f2cc23 100644 --- a/malloc/memusagestat.c +++ b/malloc/memusagestat.c @@ -191,13 +191,6 @@ main (int argc, char *argv[]) maxsize_heap = headent[1].heap; maxsize_stack = headent[1].stack; maxsize_total = headent[0].stack; - if (also_total) - { - /* We use one scale and since we also draw the total amount of - memory used we have to adapt the maximum. */ - maxsize_heap = maxsize_total; - maxsize_stack = maxsize_total; - } if (maxsize_heap == 0 && maxsize_stack == 0) { @@ -210,18 +203,31 @@ main (int argc, char *argv[]) { if (read (fd, &next, sizeof (next)) == 0) break; - if (next.heap > headent[1].heap) - headent[1].heap = next.heap; - if (next.stack > headent[1].stack) - headent[1].stack = next.stack; + if (next.heap > maxsize_heap) + maxsize_heap = next.heap; + if (next.stack > maxsize_stack) + maxsize_stack = next.stack; + if (maxsize_heap + maxsize_stack > maxsize_total) + maxsize_total = maxsize_heap + maxsize_stack; } + headent[0].stack = maxsize_total; + headent[1].heap = maxsize_heap; + headent[1].stack = maxsize_stack; headent[1].time_low = next.time_low; headent[1].time_high = next.time_high; /* Write the computed values in the file. */ - lseek (fd, sizeof (struct entry), SEEK_SET); - write (fd, &headent[1], sizeof (struct entry)); + lseek (fd, 0, SEEK_SET); + write (fd, headent, 2 * sizeof (struct entry)); + } + + if (also_total) + { + /* We use one scale and since we also draw the total amount of + memory used we have to adapt the maximum. */ + maxsize_heap = maxsize_total; + maxsize_stack = maxsize_total; } start_time = ((uint64_t) headent[0].time_high) << 32 | headent[0].time_low; |