aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDavid T. Goldblatt <davidtgoldblatt@gmail.com>2017-10-01 18:27:40 -0700
committerDavid Goldblatt <davidtgoldblatt@gmail.com>2017-12-18 16:29:10 -0800
commit8aafa270fd56c36db374fa9f294217fa80151b3d (patch)
tree7c9f082405a756ba7aa458a38250a57b716d945d /include
parent48bb4a056be97214fa049f21bead9618429c807a (diff)
downloadplatform_external_jemalloc_new-8aafa270fd56c36db374fa9f294217fa80151b3d.tar.gz
platform_external_jemalloc_new-8aafa270fd56c36db374fa9f294217fa80151b3d.tar.bz2
platform_external_jemalloc_new-8aafa270fd56c36db374fa9f294217fa80151b3d.zip
Move bin stats code from arena to bin module.
Diffstat (limited to 'include')
-rw-r--r--include/jemalloc/internal/bin.h21
-rw-r--r--include/jemalloc/internal/stats.h6
2 files changed, 26 insertions, 1 deletions
diff --git a/include/jemalloc/internal/bin.h b/include/jemalloc/internal/bin.h
index 4e551663..89572fa1 100644
--- a/include/jemalloc/internal/bin.h
+++ b/include/jemalloc/internal/bin.h
@@ -78,10 +78,29 @@ struct bin_s {
malloc_bin_stats_t stats;
};
-/* Returns true on error. */
+/* Initializes a bin to empty. Returns true on error. */
bool bin_init(bin_t *bin);
+
+/* Forking. */
void bin_prefork(tsdn_t *tsdn, bin_t *bin);
void bin_postfork_parent(tsdn_t *tsdn, bin_t *bin);
void bin_postfork_child(tsdn_t *tsdn, bin_t *bin);
+/* Stats. */
+static inline void
+bin_stats_merge(tsdn_t *tsdn, malloc_bin_stats_t *dst_bin_stats, bin_t *bin) {
+ malloc_mutex_lock(tsdn, &bin->lock);
+ malloc_mutex_prof_read(tsdn, &dst_bin_stats->mutex_data, &bin->lock);
+ dst_bin_stats->nmalloc += bin->stats.nmalloc;
+ dst_bin_stats->ndalloc += bin->stats.ndalloc;
+ dst_bin_stats->nrequests += bin->stats.nrequests;
+ dst_bin_stats->curregs += bin->stats.curregs;
+ dst_bin_stats->nfills += bin->stats.nfills;
+ dst_bin_stats->nflushes += bin->stats.nflushes;
+ dst_bin_stats->nslabs += bin->stats.nslabs;
+ dst_bin_stats->reslabs += bin->stats.reslabs;
+ dst_bin_stats->curslabs += bin->stats.curslabs;
+ malloc_mutex_unlock(tsdn, &bin->lock);
+}
+
#endif /* JEMALLOC_INTERNAL_BIN_H */
diff --git a/include/jemalloc/internal/stats.h b/include/jemalloc/internal/stats.h
index f19df374..1da5b024 100644
--- a/include/jemalloc/internal/stats.h
+++ b/include/jemalloc/internal/stats.h
@@ -6,6 +6,12 @@
#include "jemalloc/internal/mutex.h"
#include "jemalloc/internal/size_classes.h"
+/*
+ * The synchronization for stats counters may piggyback on existing
+ * synchronization in the associated data. Therefore, the merging functions for
+ * a module's stats will lie in the module, instead of with the stats.
+ */
+
/* OPTION(opt, var_name, default, set_value_to) */
#define STATS_PRINT_OPTIONS \
OPTION('J', json, false, true) \