madvise(..., MADV_{RANODOM,NOSYNC}) swap files.
Initialize malloc before calling into the ctl_*() functions.
This commit is contained in:
parent
3c2343518c
commit
95833311f1
@ -1246,6 +1246,9 @@ JEMALLOC_P(mallctl)(const char *name, void *oldp, size_t *oldlenp, void *newp,
|
|||||||
size_t newlen)
|
size_t newlen)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (malloc_init())
|
||||||
|
return (EAGAIN);
|
||||||
|
|
||||||
return (ctl_byname(name, oldp, oldlenp, newp, newlen));
|
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)
|
JEMALLOC_P(mallctlnametomib)(const char *name, size_t *mibp, size_t *miblenp)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (malloc_init())
|
||||||
|
return (EAGAIN);
|
||||||
|
|
||||||
return (ctl_nametomib(name, mibp, miblenp));
|
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)
|
size_t *oldlenp, void *newp, size_t newlen)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (malloc_init())
|
||||||
|
return (EAGAIN);
|
||||||
|
|
||||||
return (ctl_bymib(mib, miblen, oldp, oldlenp, newp, newlen));
|
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;
|
goto RETURN;
|
||||||
}
|
}
|
||||||
assert(addr == (void *)((uintptr_t)vaddr + voff));
|
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];
|
voff += sizes[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user