summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorQi Wang <interwq@gwu.edu>2017-08-24 21:29:28 (GMT)
committerQi Wang <interwq@gmail.com>2017-08-30 23:47:32 (GMT)
commit47b20bb6544de9cdd4ca7ab870d6ad257c0ce4ff (patch)
tree0c7a06a91a4c7988b9d95cbc0595c29403395fd9 /include
parentea91dfa58e11373748f747041c3041f72c9a7658 (diff)
downloadjemalloc-47b20bb6544de9cdd4ca7ab870d6ad257c0ce4ff.zip
jemalloc-47b20bb6544de9cdd4ca7ab870d6ad257c0ce4ff.tar.gz
jemalloc-47b20bb6544de9cdd4ca7ab870d6ad257c0ce4ff.tar.bz2
Change opt.metadata_thp to [disabled,auto,always].
To avoid the high RSS caused by THP + low usage arena (i.e. THP becomes a significant percentage), added a new "auto" option which will only start using THP after a base allocator used up the first THP region. Starting from the second hugepage (in a single arena), "auto" behaves the same as "always", i.e. madvise hugepage right away.
Diffstat (limited to 'include')
-rw-r--r--include/jemalloc/internal/base_externs.h3
-rw-r--r--include/jemalloc/internal/base_inlines.h4
-rw-r--r--include/jemalloc/internal/base_types.h17
3 files changed, 22 insertions, 2 deletions
diff --git a/include/jemalloc/internal/base_externs.h b/include/jemalloc/internal/base_externs.h
index a5cb8a8..6cd1187 100644
--- a/include/jemalloc/internal/base_externs.h
+++ b/include/jemalloc/internal/base_externs.h
@@ -1,7 +1,8 @@
#ifndef JEMALLOC_INTERNAL_BASE_EXTERNS_H
#define JEMALLOC_INTERNAL_BASE_EXTERNS_H
-extern bool opt_metadata_thp;
+extern metadata_thp_mode_t opt_metadata_thp;
+extern const char *metadata_thp_mode_names[];
base_t *b0get(void);
base_t *base_new(tsdn_t *tsdn, unsigned ind, extent_hooks_t *extent_hooks);
diff --git a/include/jemalloc/internal/base_inlines.h b/include/jemalloc/internal/base_inlines.h
index 931560b..aec0e2e 100644
--- a/include/jemalloc/internal/base_inlines.h
+++ b/include/jemalloc/internal/base_inlines.h
@@ -6,4 +6,8 @@ base_ind_get(const base_t *base) {
return base->ind;
}
+static inline bool
+metadata_thp_enabled(void) {
+ return (opt_metadata_thp != metadata_thp_disabled);
+}
#endif /* JEMALLOC_INTERNAL_BASE_INLINES_H */
diff --git a/include/jemalloc/internal/base_types.h b/include/jemalloc/internal/base_types.h
index 6e71033..97e38a9 100644
--- a/include/jemalloc/internal/base_types.h
+++ b/include/jemalloc/internal/base_types.h
@@ -4,6 +4,21 @@
typedef struct base_block_s base_block_t;
typedef struct base_s base_t;
-#define METADATA_THP_DEFAULT false
+#define METADATA_THP_DEFAULT metadata_thp_disabled
+
+typedef enum {
+ metadata_thp_disabled = 0,
+ /*
+ * Lazily enable hugepage for metadata. To avoid high RSS caused by THP
+ * + low usage arena (i.e. THP becomes a significant percentage), the
+ * "auto" option only starts using THP after a base allocator used up
+ * the first THP region. Starting from the second hugepage (in a single
+ * arena), "auto" behaves the same as "always", i.e. madvise hugepage
+ * right away.
+ */
+ metadata_thp_auto = 1,
+ metadata_thp_always = 2,
+ metadata_thp_mode_limit = 3
+} metadata_thp_mode_t;
#endif /* JEMALLOC_INTERNAL_BASE_TYPES_H */