summaryrefslogtreecommitdiffstats
path: root/src/pages.c
Commit message (Collapse)AuthorAgeFilesLines
* Try to use sysctl(3) instead of sysctlbyname(3).Edward Tomasz Napierala2017-11-031-0/+13
| | | | | | | | | This attempts to use VM_OVERCOMMIT OID - newly introduced in -CURRENT few days ago, specifically for this purpose - instead of querying the sysctl by its string name. Due to how syctlbyname(3) works, this means we do one syscall during binary startup instead of two. Signed-off-by: Edward Tomasz Napierala <trasz@FreeBSD.org>
* Use getpagesize(3) under FreeBSD.Edward Tomasz Napierala2017-11-031-0/+2
| | | | | | | This avoids sysctl(2) syscall during binary startup, using the value passed in the ELF aux vector instead. Signed-off-by: Edward Tomasz Napierala <trasz@FreeBSD.org>
* Add pages_dontdump and pages_dodump.David Goldblatt2017-10-161-0/+23
| | | | This will, eventually, enable us to avoid dumping eden regions.
* Define MADV_FREE on our own when needed.Qi Wang2017-10-111-1/+7
| | | | | | On x86 Linux, we define our own MADV_FREE if madvise(2) is available, but no MADV_FREE is detected. This allows the feature to be built in and enabled with runtime detection.
* Add runtime detection of lazy purging support.Qi Wang2017-09-271-0/+24
| | | | | | It's possible to build with lazy purge enabled but depoly to systems without such support. In this case, rely on the boot time detection instead of keep making unnecessary madvise calls (which all returns EINVAL).
* Change opt.metadata_thp to [disabled,auto,always].Qi Wang2017-08-301-1/+1
| | | | | | | | 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.
* Fix test/unit/pages.Qi Wang2017-08-111-6/+7
| | | | | | As part of the metadata_thp support, We now have a separate swtich (JEMALLOC_HAVE_MADVISE_HUGE) for MADV_HUGEPAGE availability. Use that instead of JEMALLOC_THP (which doesn't guard pages_huge anymore) in tests.
* Implement opt.metadata_thpQi Wang2017-08-111-2/+51
| | | | | This option enables transparent huge page for base allocators (require MADV_HUGEPAGE support).
* Validates fd before calling fcntlY. T. Chung2017-07-221-3/+9
|
* Fall back to FD_CLOEXEC when O_CLOEXEC is unavailable.Y. T. Chung2017-07-201-5/+22
| | | | | | | Older Linux systems don't have O_CLOEXEC. If that's the case, we fcntl immediately after open, to minimize the length of the racy period in which an operation in another thread can leak a file descriptor to a child.
* Pass the O_CLOEXEC flag to open(2).Jason Evans2017-05-311-3/+4
| | | | This resolves #528.
* Header refactoring: pages.h - unify and remove from catchall.David Goldblatt2017-04-251-0/+3
|
* Use openat syscall if availableJim Chen2017-04-211-0/+3
| | | | | | | | | | Some architectures like AArch64 may not have the open syscall because it was superseded by the openat syscall, so check and use SYS_openat if SYS_open is not available. Additionally, Android headers for AArch64 define SYS_open to __NR_open, even though __NR_open is undefined. Undefine SYS_open in that case so SYS_openat is used.
* Support --with-lg-page values larger than system page size.Jason Evans2017-04-191-44/+138
| | | | | | | | | All mappings continue to be PAGE-aligned, even if the system page size is smaller. This change is primarily intended to provide a mechanism for supporting multiple page sizes with the same binary; smaller page sizes work better in conjunction with jemalloc's design. This resolves #467.
* Header refactoring: move assert.h out of the catch-allDavid Goldblatt2017-04-191-0/+1
|
* Header refactoring: move malloc_io.h out of the catchallDavid Goldblatt2017-04-191-0/+2
|
* Header refactoring: Split up jemalloc_internal.hDavid Goldblatt2017-04-111-1/+2
| | | | | | | | | | | | | | This is a biggy. jemalloc_internal.h has been doing multiple jobs for a while now: - The source of system-wide definitions. - The catch-all include file. - The module header file for jemalloc.c This commit splits up this functionality. The system-wide definitions responsibility has moved to jemalloc_preamble.h. The catch-all include file is now jemalloc_internal_includes.h. The module headers for jemalloc.c are now in jemalloc_internal_[externs|inlines|types].h, just as they are for the other modules.
* Propagate madvise() success/failure from pages_purge_lazy().Jason Evans2017-03-161-3/+3
|
* Add alignment/size assertions to pages_*().Jason Evans2017-03-141-0/+15
| | | | | These sanity checks prevent what otherwise might result in failed system calls and unintended fallback execution paths.
* Fix pages_purge_forced() to discard pages on non-Linux systems.Jason Evans2017-03-141-1/+8
| | | | | madvise(..., MADV_DONTNEED) only causes demand-zeroing on Linux, so fall back to overlaying a new mapping.
* Replace tabs following #define with spaces.Jason Evans2017-01-211-1/+1
| | | | This resolves #564.
* Remove extraneous parens around return arguments.Jason Evans2017-01-211-18/+18
| | | | This resolves #540.
* Update brace style.Jason Evans2017-01-211-42/+43
| | | | | | | Add braces around single-line blocks, and remove line breaks before function-opening braces. This resolves #537.
* Remove leading blank lines from function bodies.Jason Evans2017-01-131-9/+0
| | | | This resolves #535.
* Refactor purging and splitting/merging.Jason Evans2016-12-271-21/+22
| | | | | | | | | | | | | | Split purging into lazy and forced variants. Use the forced variant for zeroing dss. Add support for NULL function pointers as an opt-out mechanism for the dalloc, commit, decommit, purge_lazy, purge_forced, split, and merge fields of extent_hooks_t. Add short-circuiting checks in large_ralloc_no_move_{shrink,expand}() so that no attempt is made if splitting/merging is not supported. This resolves #268.
* Add huge page configuration and pages_[no}huge().Jason Evans2016-12-271-1/+30
| | | | | | | | Add the --with-lg-hugepage configure option, but automatically configure LG_HUGEPAGE even if it isn't specified. Add the pages_[no]huge() functions, which toggle huge page state via madvise(..., MADV_[NO]HUGEPAGE) calls.
* Add --disable-syscall.Jason Evans2016-12-041-3/+3
| | | | This resolves #517.
* Refactor madvise(2) configuration.Jason Evans2016-11-171-5/+5
| | | | | | | | | Add feature tests for the MADV_FREE and MADV_DONTNEED flags to madvise(2), so that MADV_FREE is detected and used for Linux kernel versions 4.5 and newer. Refactor pages_purge() so that on systems which support both flags, MADV_FREE is preferred over MADV_DONTNEED. This resolves #387.
* Do not use syscall(2) on OS X 10.12 (deprecated).Jason Evans2016-11-031-3/+3
|
* Use syscall(2) rather than {open,read,close}(2) during boot.Jason Evans2016-10-301-0/+19
| | | | | | | | | Some applications wrap various system calls, and if they call the allocator in their wrappers, unexpected reentry can result. This is not a general solution (many other syscalls are spread throughout the code), but this resolves a bootstrapping issue that is apparently common. This resolves #443.
* Close file descriptor after reading "/proc/sys/vm/overcommit_memory".Jason Evans2016-09-261-0/+1
| | | | | | | This bug was introduced by c2f970c32b527660a33fa513a76d913c812dcf7c (Modify pages_map() to support mapping uncommitted virtual memory.). This resolves #399.
* Modify pages_map() to support mapping uncommitted virtual memory.Jason Evans2016-05-061-18/+98
| | | | | | | | | | | If the OS overcommits: - Commit all mappings in pages_map() regardless of whether the caller requested committed memory. - Linux-specific: Specify MAP_NORESERVE to avoid unfortunate interactions with heuristic overcommit mode during fork(2). This resolves #193.
* Try to decommit new chunks.Jason Evans2015-08-121-1/+7
| | | | Always leave decommit disabled on non-Windows systems.
* Refactor arena_mapbits_{small,large}_set() to not preserve unzeroed.Jason Evans2015-08-111-1/+1
| | | | | Fix arena_run_split_large_helper() to treat newly committed memory as zeroed.
* Refactor arena_mapbits unzeroed flag management.Jason Evans2015-08-111-1/+1
| | | | | | Only set the unzeroed flag when initializing the entire mapbits entry, rather than mutating just the unzeroed bit. This simplifies the possible mapbits state transitions.
* Generalize chunk management hooks.Jason Evans2015-08-041-0/+167
Add the "arena.<i>.chunk_hooks" mallctl, which replaces and expands on the "arena.<i>.chunk.{alloc,dalloc,purge}" mallctls. The chunk hooks allow control over chunk allocation/deallocation, decommit/commit, purging, and splitting/merging, such that the application can rely on jemalloc's internal chunk caching and retaining functionality, yet implement a variety of chunk management mechanisms and policies. Merge the chunks_[sz]ad_{mmap,dss} red-black trees into chunks_[sz]ad_retained. This slightly reduces how hard jemalloc tries to honor the dss precedence setting; prior to this change the precedence setting was also consulted when recycling chunks. Fix chunk purging. Don't purge chunks in arena_purge_stashed(); instead deallocate them in arena_unstash_purged(), so that the dirty memory linkage remains valid until after the last time it is used. This resolves #176 and #201.