summaryrefslogtreecommitdiffstats
path: root/jemalloc
diff options
context:
space:
mode:
authorJason Evans <jasone@canonware.com>2010-01-25 00:41:01 (GMT)
committerJason Evans <jasone@canonware.com>2010-01-25 00:41:01 (GMT)
commitbc25a47ee0e2ac8e10a94d5fa070f0dbbdeb7e7e (patch)
treea5c5e7c11b36a2d5792b409feee38c2b6ec90d61 /jemalloc
parent4201af05425b69ee37ffca437aca0cdd604d1e51 (diff)
downloadjemalloc-bc25a47ee0e2ac8e10a94d5fa070f0dbbdeb7e7e.zip
jemalloc-bc25a47ee0e2ac8e10a94d5fa070f0dbbdeb7e7e.tar.gz
jemalloc-bc25a47ee0e2ac8e10a94d5fa070f0dbbdeb7e7e.tar.bz2
Various minor cleanups.
Clean up whitespace. Lock access of swap_avail when printing stats. Use inttypes.h for portable printf() format specifiers, specifically for uint64_t (PRIu64). Change highchunks and curchunks stats from (unsigned long) to (size_t).
Diffstat (limited to 'jemalloc')
-rw-r--r--jemalloc/src/internal/jemalloc_arena.h3
-rw-r--r--jemalloc/src/internal/jemalloc_internal.h.in1
-rw-r--r--jemalloc/src/internal/jemalloc_stats.h4
-rw-r--r--jemalloc/src/jemalloc_arena.c24
-rw-r--r--jemalloc/src/jemalloc_stats.c17
5 files changed, 32 insertions, 17 deletions
diff --git a/jemalloc/src/internal/jemalloc_arena.h b/jemalloc/src/internal/jemalloc_arena.h
index 96b7e89..c4e63c5 100644
--- a/jemalloc/src/internal/jemalloc_arena.h
+++ b/jemalloc/src/internal/jemalloc_arena.h
@@ -289,7 +289,7 @@ struct arena_s {
arena_chunk_t *spare;
/* Number of pages in active runs. */
- size_t nactive;
+ size_t nactive;
/*
* Current count of pages within unused runs that are potentially
@@ -299,7 +299,6 @@ struct arena_s {
*/
size_t ndirty;
-
/*
* Size/address-ordered tree of this arena's available runs. This tree
* is used for first-best-fit run allocation.
diff --git a/jemalloc/src/internal/jemalloc_internal.h.in b/jemalloc/src/internal/jemalloc_internal.h.in
index cc03af5..af6543e 100644
--- a/jemalloc/src/internal/jemalloc_internal.h.in
+++ b/jemalloc/src/internal/jemalloc_internal.h.in
@@ -17,6 +17,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
+#include <inttypes.h>
#include <string.h>
#include <strings.h>
#include <unistd.h>
diff --git a/jemalloc/src/internal/jemalloc_stats.h b/jemalloc/src/internal/jemalloc_stats.h
index 4a3a881..2e0ad52 100644
--- a/jemalloc/src/internal/jemalloc_stats.h
+++ b/jemalloc/src/internal/jemalloc_stats.h
@@ -110,14 +110,14 @@ struct chunk_stats_s {
uint64_t nchunks;
/* High-water mark for number of chunks allocated. */
- unsigned long highchunks;
+ size_t highchunks;
/*
* Current number of chunks allocated. This value isn't maintained for
* any other purpose, so keep track of it in order to be able to set
* highchunks.
*/
- unsigned long curchunks;
+ size_t curchunks;
};
#endif /* JEMALLOC_H_STRUCTS */
diff --git a/jemalloc/src/jemalloc_arena.c b/jemalloc/src/jemalloc_arena.c
index 3818f9c..3dbf47d 100644
--- a/jemalloc/src/jemalloc_arena.c
+++ b/jemalloc/src/jemalloc_arena.c
@@ -1612,8 +1612,8 @@ arena_stats_aprint(size_t nactive, size_t ndirty, const arena_stats_t *astats,
{
malloc_cprintf(write4, w4opaque,
- "dirty pages: %zu:%zu active:dirty, %llu sweep%s,"
- " %llu madvise%s, %llu purged\n",
+ "dirty pages: %zu:%zu active:dirty, %"PRIu64" sweep%s,"
+ " %"PRIu64" madvise%s, %"PRIu64" purged\n",
nactive, ndirty,
astats->npurge, astats->npurge == 1 ? "" : "s",
astats->nmadvise, astats->nmadvise == 1 ? "" : "s",
@@ -1621,16 +1621,20 @@ arena_stats_aprint(size_t nactive, size_t ndirty, const arena_stats_t *astats,
malloc_cprintf(write4, w4opaque,
" allocated nmalloc ndalloc\n");
- malloc_cprintf(write4, w4opaque, "small: %12zu %12llu %12llu\n",
+ malloc_cprintf(write4, w4opaque,
+ "small: %12zu %12"PRIu64" %12"PRIu64"\n",
astats->allocated_small, astats->nmalloc_small,
astats->ndalloc_small);
- malloc_cprintf(write4, w4opaque, "medium: %12zu %12llu %12llu\n",
+ malloc_cprintf(write4, w4opaque,
+ "medium: %12zu %12"PRIu64" %12"PRIu64"\n",
astats->allocated_medium, astats->nmalloc_medium,
astats->ndalloc_medium);
- malloc_cprintf(write4, w4opaque, "large: %12zu %12llu %12llu\n",
+ malloc_cprintf(write4, w4opaque,
+ "large: %12zu %12"PRIu64" %12"PRIu64"\n",
astats->allocated_large, astats->nmalloc_large,
astats->ndalloc_large);
- malloc_cprintf(write4, w4opaque, "total: %12zu %12llu %12llu\n",
+ malloc_cprintf(write4, w4opaque,
+ "total: %12zu %12"PRIu64" %12"PRIu64"\n",
astats->allocated_small + astats->allocated_medium +
astats->allocated_large, astats->nmalloc_small +
astats->nmalloc_medium + astats->nmalloc_large,
@@ -1674,11 +1678,11 @@ arena_stats_bprint(arena_t *arena, const malloc_bin_stats_t *bstats,
gap_start = UINT_MAX;
}
malloc_cprintf(write4, w4opaque,
- "%13u %1s %5u %4u %3u %9llu %9llu"
+ "%13u %1s %5u %4u %3u %9"PRIu64" %9"PRIu64
#ifdef JEMALLOC_TCACHE
- " %9llu %9llu"
+ " %9"PRIu64" %9"PRIu64""
#endif
- " %9llu %7zu %7zu\n",
+ " %9"PRIu64" %7zu %7zu\n",
i,
i < ntbins ? "T" : i < ntbins + nqbins ?
"Q" : i < ntbins + nqbins + ncbins ? "C" :
@@ -1733,7 +1737,7 @@ arena_stats_lprint(const malloc_large_stats_t *lstats,
gap_start = -1;
}
malloc_cprintf(write4, w4opaque,
- "%13zu %5zu %9llu %9zu %9zu\n",
+ "%13zu %5zu %9"PRIu64" %9zu %9zu\n",
(i+1) << PAGE_SHIFT, i+1,
lstats[i].nrequests,
lstats[i].highruns,
diff --git a/jemalloc/src/jemalloc_stats.c b/jemalloc/src/jemalloc_stats.c
index 979eb79..a70cb57 100644
--- a/jemalloc/src/jemalloc_stats.c
+++ b/jemalloc/src/jemalloc_stats.c
@@ -278,18 +278,28 @@ stats_print(void (*write4)(void *, const char *, const char *, const char *,
/* Print chunk stats. */
{
chunk_stats_t chunks_stats;
+#ifdef JEMALLOC_SWAP
+ size_t swap_avail_chunks;
+#endif
malloc_mutex_lock(&huge_mtx);
chunks_stats = stats_chunks;
malloc_mutex_unlock(&huge_mtx);
+#ifdef JEMALLOC_SWAP
+ malloc_mutex_lock(&swap_mtx);
+ swap_avail_chunks = swap_avail >> opt_lg_chunk;
+ malloc_mutex_unlock(&swap_mtx);
+#endif
+
malloc_cprintf(write4, w4opaque, "chunks: nchunks "
"highchunks curchunks"
#ifdef JEMALLOC_SWAP
" swap_avail"
#endif
"\n");
- malloc_cprintf(write4, w4opaque, " %13llu%13lu%13lu"
+ malloc_cprintf(write4, w4opaque,
+ " %13"PRIu64"%13zu%13zu"
#ifdef JEMALLOC_SWAP
"%13zu"
#endif
@@ -297,7 +307,7 @@ stats_print(void (*write4)(void *, const char *, const char *, const char *,
chunks_stats.nchunks, chunks_stats.highchunks,
chunks_stats.curchunks
#ifdef JEMALLOC_SWAP
- , (swap_avail >> opt_lg_chunk)
+ , swap_avail_chunks
#endif
);
}
@@ -305,7 +315,8 @@ stats_print(void (*write4)(void *, const char *, const char *, const char *,
/* Print chunk stats. */
malloc_cprintf(write4, w4opaque,
"huge: nmalloc ndalloc allocated\n");
- malloc_cprintf(write4, w4opaque, " %12llu %12llu %12zu\n",
+ malloc_cprintf(write4, w4opaque,
+ " %12"PRIu64" %12"PRIu64" %12zu\n",
huge_nmalloc, huge_ndalloc, huge_allocated);
if (merged) {