This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[RFC][PATCH 3/4] malloc_info: report sizes of top chunks in each arena
- From: Ken Milmore <ken dot milmore at gmail dot com>
- To: libc-alpha at sourceware dot org
- Date: Mon, 30 Apr 2018 22:00:08 +0100
- Subject: [RFC][PATCH 3/4] malloc_info: report sizes of top chunks in each arena
---
malloc/malloc.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/malloc/malloc.c b/malloc/malloc.c
index dc0a96ed13..b65161c76a 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -5391,8 +5391,10 @@ __malloc_info (int options, FILE *fp)
int n = 0;
size_t total_nblocks = 0;
size_t total_nfastblocks = 0;
+ size_t total_narenas = 0;
size_t total_avail = 0;
size_t total_fastavail = 0;
+ size_t total_topavail = 0;
size_t total_system = 0;
size_t total_max_system = 0;
size_t total_aspace = 0;
@@ -5484,6 +5486,8 @@ __malloc_info (int options, FILE *fp)
avail += sizes[NFASTBINS - 1 + i].total;
}
+ size_t topavail = chunksize (top (ar_ptr));
+
size_t heap_size = 0;
size_t heap_mprotect_size = 0;
size_t heap_count = 0;
@@ -5509,6 +5513,9 @@ __malloc_info (int options, FILE *fp)
total_nblocks += nblocks;
total_avail += avail;
+ ++total_narenas;
+ total_topavail += topavail;
+
for (size_t i = 0; i < nsizes; ++i)
if (sizes[i].count != 0 && i != NFASTBINS)
fprintf (fp, "\
@@ -5527,9 +5534,10 @@ __malloc_info (int options, FILE *fp)
fprintf (fp,
"</sizes>\n<total type=\"fast\" count=\"%zu\" size=\"%zu\"/>\n"
"<total type=\"rest\" count=\"%zu\" size=\"%zu\"/>\n"
+ "<total type=\"top\" count=\"1\" size=\"%zu\"/>\n"
"<system type=\"current\" size=\"%zu\"/>\n"
"<system type=\"max\" size=\"%zu\"/>\n",
- nfastblocks, fastavail, nblocks, avail,
+ nfastblocks, fastavail, nblocks, avail, topavail,
ar_ptr->system_mem, ar_ptr->max_system_mem);
if (ar_ptr != &main_arena)
@@ -5560,6 +5568,7 @@ __malloc_info (int options, FILE *fp)
fprintf (fp,
"<total type=\"fast\" count=\"%zu\" size=\"%zu\"/>\n"
"<total type=\"rest\" count=\"%zu\" size=\"%zu\"/>\n"
+ "<total type=\"top\" count=\"%zu\" size=\"%zu\"/>\n"
"<total type=\"mmap\" count=\"%d\" size=\"%zu\"/>\n"
"<system type=\"current\" size=\"%zu\"/>\n"
"<system type=\"max\" size=\"%zu\"/>\n"
@@ -5567,6 +5576,7 @@ __malloc_info (int options, FILE *fp)
"<aspace type=\"mprotect\" size=\"%zu\"/>\n"
"</malloc>\n",
total_nfastblocks, total_fastavail, total_nblocks, total_avail,
+ total_narenas, total_topavail,
mp_.n_mmaps, mp_.mmapped_mem,
total_system, total_max_system,
total_aspace, total_aspace_mprotect);
--
2.11.0