mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-08-25 00:23:33 +03:00
Ehooks: Add a "zero" ehook.
This is the first API expansion. It lets the hooks pick where and how to purge within themselves.
This commit is contained in:
parent
d0f187ad3b
commit
4b2e5ee8b9
3 changed files with 48 additions and 25 deletions
17
src/ehooks.c
17
src/ehooks.c
|
|
@ -209,6 +209,23 @@ ehooks_default_merge(extent_hooks_t *extent_hooks, void *addr_a, size_t size_a,
|
|||
return ehooks_default_merge_impl(addr_a, addr_b);
|
||||
}
|
||||
|
||||
void
|
||||
ehooks_default_zero_impl(void *addr, size_t size) {
|
||||
/*
|
||||
* By default, we try to zero out memory using OS-provided demand-zeroed
|
||||
* pages. If the user has specifically requested hugepages, though, we
|
||||
* don't want to purge in the middle of a hugepage (which would break it
|
||||
* up), so we act conservatively and use memset.
|
||||
*/
|
||||
bool needs_memset = true;
|
||||
if (opt_thp != thp_mode_always) {
|
||||
needs_memset = pages_purge_forced(addr, size);
|
||||
}
|
||||
if (needs_memset) {
|
||||
memset(addr, 0, size);
|
||||
}
|
||||
}
|
||||
|
||||
const extent_hooks_t ehooks_default_extent_hooks = {
|
||||
ehooks_default_alloc,
|
||||
ehooks_default_dalloc,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue