diff options
author | Jason Evans <je@facebook.com> | 2010-01-27 21:45:21 (GMT) |
---|---|---|
committer | Jason Evans <je@facebook.com> | 2010-01-27 21:47:28 (GMT) |
commit | 95833311f10ec7c23d9c550213909aa2e35bd1b6 (patch) | |
tree | 87676cc88ddf0603429eb5d98dd3d3ee2b96b0c8 /jemalloc | |
parent | 3c2343518c2b1fbbd66065c75a3c19f908de1d78 (diff) | |
download | jemalloc-95833311f10ec7c23d9c550213909aa2e35bd1b6.zip jemalloc-95833311f10ec7c23d9c550213909aa2e35bd1b6.tar.gz jemalloc-95833311f10ec7c23d9c550213909aa2e35bd1b6.tar.bz2 |
madvise(..., MADV_{RANODOM,NOSYNC}) swap files.
Initialize malloc before calling into the ctl_*() functions.
Diffstat (limited to 'jemalloc')
-rw-r--r-- | jemalloc/src/jemalloc.c | 9 | ||||
-rw-r--r-- | jemalloc/src/jemalloc_chunk_swap.c | 13 |
2 files changed, 22 insertions, 0 deletions
diff --git a/jemalloc/src/jemalloc.c b/jemalloc/src/jemalloc.c index b807a22..9f71c01 100644 --- a/jemalloc/src/jemalloc.c +++ b/jemalloc/src/jemalloc.c @@ -1246,6 +1246,9 @@ JEMALLOC_P(mallctl)(const char *name, void *oldp, size_t *oldlenp, void *newp, size_t newlen) { + if (malloc_init()) + return (EAGAIN); + return (ctl_byname(name, oldp, oldlenp, newp, newlen)); } @@ -1254,6 +1257,9 @@ int JEMALLOC_P(mallctlnametomib)(const char *name, size_t *mibp, size_t *miblenp) { + if (malloc_init()) + return (EAGAIN); + return (ctl_nametomib(name, mibp, miblenp)); } @@ -1263,6 +1269,9 @@ JEMALLOC_P(mallctlbymib)(const size_t *mib, size_t miblen, void *oldp, size_t *oldlenp, void *newp, size_t newlen) { + if (malloc_init()) + return (EAGAIN); + return (ctl_bymib(mib, miblen, oldp, oldlenp, newp, newlen)); } diff --git a/jemalloc/src/jemalloc_chunk_swap.c b/jemalloc/src/jemalloc_chunk_swap.c index fa5a5b1..c185d43 100644 --- a/jemalloc/src/jemalloc_chunk_swap.c +++ b/jemalloc/src/jemalloc_chunk_swap.c @@ -311,6 +311,19 @@ chunk_swap_enable(const int *fds, unsigned nfds, bool prezeroed) goto RETURN; } assert(addr == (void *)((uintptr_t)vaddr + voff)); + + /* + * Tell the kernel that the mapping will be accessed randomly, + * and that it should not gratuitously sync pages to the + * filesystem. + */ +#ifdef MADV_RANDOM + madvise(addr, sizes[i], MADV_RANDOM); +#endif +#ifdef MADV_NOSYNC + madvise(addr, sizes[i], MADV_NOSYNC); +#endif + voff += sizes[i]; } |