mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-04-14 22:51:50 +03:00
madvise(..., MADV_{RANODOM,NOSYNC}) swap files.
Initialize malloc before calling into the ctl_*() functions.
This commit is contained in:
parent
3c2343518c
commit
95833311f1
2 changed files with 22 additions and 0 deletions
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue