summaryrefslogtreecommitdiffstats
path: root/include
Commit message (Collapse)AuthorAgeFilesLines
* Add quarantine unit tests.Jason Evans2013-12-172-0/+8
| | | | | | | | | Verify that freed regions are quarantined, and that redzone corruption is detected. Introduce a testing idiom for intercepting/replacing internal functions. In this case the replaced function is ordinarily a static function, but the idiom should work similarly for library-private functions.
* Add hash (MurmurHash3) tests.Jason Evans2013-12-171-1/+0
| | | | Add hash tests that are based on SMHasher's VerificationTest() function.
* Finish arena_prof_ctx_set() optimization.Jason Evans2013-12-161-7/+7
| | | | Delay reading the mapbits until it's unavoidable.
* Don't junk-fill reallocations unless usize changes.Jason Evans2013-12-161-0/+1
| | | | | | | | | | | Don't junk fill reallocations for which the request size is less than the current usable size, but not enough smaller to cause a size class change. Unlike malloc()/calloc()/realloc(), *allocx() contractually treats the full usize as the allocation, so a caller can ask for zeroed memory via mallocx() and a series of rallocx() calls that all specify MALLOCX_ZERO, and be assured that all newly allocated bytes will be zeroed and made available to the application without danger of allocator mutation until the size class decreases enough to cause usize reduction.
* Optimize arena_prof_ctx_set().Jason Evans2013-12-162-35/+41
| | | | | | Refactor such that arena_prof_ctx_set() receives usize as an argument, and use it to determine whether to handle ptr as a small region, rather than reading the chunk page map.
* Fix name mangling issues.Jason Evans2013-12-132-34/+34
| | | | | | | | | Move je_* definitions from jemalloc_macros.h.in to jemalloc_defs.h.in, because only the latter is an autoconf header (#undef substitution occurs). Fix unit tests to use automatic mangling, so that e.g. mallocx is macro-substituted to becom jet_mallocx.
* Implement the *allocx() API.Jason Evans2013-12-136-45/+89
| | | | | | | | | | | | | | | | | | | | | | | Implement the *allocx() API, which is a successor to the *allocm() API. The *allocx() functions are slightly simpler to use because they have fewer parameters, they directly return the results of primary interest, and mallocx()/rallocx() avoid the strict aliasing pitfall that allocm()/rallocx() share with posix_memalign(). The following code violates strict aliasing rules: foo_t *foo; allocm((void **)&foo, NULL, 42, 0); whereas the following is safe: foo_t *foo; void *p; allocm(&p, NULL, 42, 0); foo = (foo_t *)p; mallocx() does not have this problem: foo_t *foo = (foo_t *)mallocx(42, 0);
* Add mq (message queue) to test infrastructure.Jason Evans2013-12-123-6/+10
| | | | | | | | | Add mtx (mutex) to test infrastructure, in order to avoid bootstrapping complications that would result from directly using malloc_mutex. Rename test infrastructure's thread abstraction from je_thread to thd. Fix some header ordering issues.
* Fix inline-related macro issues.Jason Evans2013-12-101-8/+10
| | | | | | | | | Add JEMALLOC_INLINE_C and use it instead of JEMALLOC_INLINE in .c files, so that the annotated functions are always static. Remove SFMT's inline-related macros and use jemalloc's instead, so that there's no danger of interactions with jemalloc's definitions that disable inlining for debug builds.
* Add probabability distribution utility code.Jason Evans2013-12-102-1/+2
| | | | | | | | | | | | | | | Add probabability distribution utility code that enables generation of random deviates drawn from normal, Chi-square, and Gamma distributions. Fix format strings in several of the assert_* macros (remove a %s). Clean up header issues; it's critical that system headers are not included after internal definitions potentially do things like: #define inline Fix the build system to incorporate header dependencies for the test library C files.
* Normalize #define whitespace.Jason Evans2013-12-097-39/+39
| | | | Consistently use a tab rather than a space following #define.
* Refactor tests.Jason Evans2013-12-092-2/+2
| | | | | | | Refactor tests to use explicit testing assertions, rather than diff'ing test output. This makes the test code a bit shorter, more explicitly encodes testing intent, and makes test failure diagnosis more straightforward.
* Make jemalloc.h formatting more consistent.Jason Evans2013-12-074-63/+66
|
* Add test code coverage analysis.Jason Evans2013-12-072-2/+5
| | | | Add test code coverage analysis based on gcov.
* Disable floating point code/linking when possible.Jason Evans2013-12-061-0/+15
| | | | | | | | | | | Unless heap profiling is enabled, disable floating point code and don't link with libm. This, in combination with e.g. EXTRA_CFLAGS=-mno-sse on x64 systems, makes it possible to completely disable floating point register use. Some versions of glibc neglect to save/restore caller-saved floating point registers during dynamic lazy symbol loading, and the symbol loading code uses whatever malloc the application happens to have linked/loaded with, the result being potential floating point register corruption.
* Fix more test refactoring issues.Jason Evans2013-12-066-109/+111
|
* Fix test refactoring issues for Linux.Jason Evans2013-12-062-31/+31
|
* Refactor to support more varied testing.Jason Evans2013-12-0416-779/+851
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Refactor the test harness to support three types of tests: - unit: White box unit tests. These tests have full access to all internal jemalloc library symbols. Though in actuality all symbols are prefixed by jet_, macro-based name mangling abstracts this away from test code. - integration: Black box integration tests. These tests link with the installable shared jemalloc library, and with the exception of some utility code and configure-generated macro definitions, they have no access to jemalloc internals. - stress: Black box stress tests. These tests link with the installable shared jemalloc library, as well as with an internal allocator with symbols prefixed by jet_ (same as for unit tests) that can be used to allocate data structures that are internal to the test code. Move existing tests into test/{unit,integration}/ as appropriate. Split out internal parts of jemalloc_defs.h.in and put them in jemalloc_internal_defs.h.in. This reduces internals exposure to applications that #include <jemalloc/jemalloc.h>. Refactor jemalloc.h header generation so that a single header file results, and the prototypes can be used to generate jet_ prototypes for tests. Split jemalloc.h.in into multiple parts (jemalloc_defs.h.in, jemalloc_macros.h.in, jemalloc_protos.h.in, jemalloc_mangle.h.in) and use a shell script to generate a unified jemalloc.h at configure time. Change the default private namespace prefix from "" to "je_". Add missing private namespace mangling. Remove hard-coded private_namespace.h. Instead generate it and private_unnamespace.h from private_symbols.txt. Use similar logic for public symbols, which aids in name mangling for jet_ symbols. Add test_warn() and test_fail(). Replace existing exit(1) calls with test_fail() calls.
* Remove unnecessary zeroing in arena_palloc().Jason Evans2013-10-301-5/+6
|
* Add support for LinuxThreads.Leonard Crestez2013-10-251-0/+37
| | | | | | | | | | | | | | | | | When using LinuxThreads pthread_setspecific triggers recursive allocation on all threads. Work around this by creating a global linked list of in-progress tsd initializations. This modifies the _tsd_get_wrapper macro-generated function. When it has to initialize an TSD object it will push the item to the linked list first. If this causes a recursive allocation then the _get_wrapper request is satisfied from the list. When pthread_setspecific returns the item is removed from the list. This effectively adds a very poor substitute for real TLS used only during pthread_setspecific allocation recursion. Signed-off-by: Crestez Dan Leonard <lcrestez@ixiacom.com>
* Prefer not_reached() over assert(false) where appropriate.Jason Evans2013-10-211-6/+6
|
* Fix a Valgrind integration flaw.Jason Evans2013-10-201-2/+2
| | | | | | Fix a Valgrind integration flaw that caused Valgrind warnings about reads of uninitialized memory in internal zero-initialized data structures (relevant to tcache and prof code).
* Fix a Valgrind integration flaw.Jason Evans2013-10-202-25/+43
| | | | | Fix a Valgrind integration flaw that caused Valgrind warnings about reads of uninitialized memory in arena chunk headers.
* Fix inlining warning.Jason Evans2013-10-201-0/+12
| | | | | | | | | Add the JEMALLOC_ALWAYS_INLINE_C macro and use it for always-inlined functions declared in .c files. This fixes a function attribute inconsistency for debug builds that resulted in (harmless) compiler warnings about functions not being inlinable. Reported by Ricardo Nabinger Sanchez.
* Add aarch64 LG_QUANTUM size definitionRiku Voipio2013-05-071-0/+3
| | | | Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* Add no-op bodies to VALGRIND_*() macro stubs.Jason Evans2013-03-061-9/+11
| | | | | | | | | Add no-op bodies to VALGRIND_*() macro stubs so that they can be used in contexts like the following without generating a compiler warning about the 'if' statement having an empty body: if (config_valgrind) VALGRIND_MAKE_MEM_UNDEFINED(ret, size);
* fix building for s390 systemsMike Frysinger2013-03-061-1/+1
| | | | | | | | | Checking for __s390x__ means you work on s390x, but not s390 (32bit) systems. So use __s390__ which works for both. With this, `make check` passes on s390. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* Fix a prof-related locking order bug.Jason Evans2013-02-061-13/+20
| | | | | Fix a locking order bug that could cause deadlock during fork if heap profiling were enabled.
* Fix Valgrind integration.Jason Evans2013-02-012-2/+3
| | | | | Fix Valgrind integration to annotate all internally allocated memory in a way that keeps Valgrind happy about internal data structure access.
* Fix potential TLS-related memory corruption.Jason Evans2013-01-313-8/+55
| | | | | | | | | | Avoid writing to uninitialized TLS as a side effect of deallocation. Initializing TLS during deallocation is unsafe because it is possible that a thread never did any allocation, and that TLS has already been deallocated by the threads library, resulting in write-after-free corruption. These fixes affect prof_tdata and quarantine; all other uses of TLS are already safe, whether intentionally (as for tcache) or unintentionally (as for arenas).
* Specify 'inline' in addition to always_inline attribute.Jason Evans2013-01-231-1/+1
| | | | | Specify both inline and __attribute__((always_inline)), in order to avoid warnings when using newer versions of gcc.
* Update hash from MurmurHash2 to MurmurHash3.Jason Evans2013-01-224-40/+315
| | | | | | Update hash from MurmurHash2 to MurmurHash3, primarily because the latter generates 128 bits in a single call for no extra cost, which simplifies integration with cuckoo hashing.
* Add and use JEMALLOC_ALWAYS_INLINE.Jason Evans2013-01-223-48/+56
| | | | | Add JEMALLOC_ALWAYS_INLINE and use it to guarantee that the entire fast paths of the primary allocation/deallocation functions are inlined.
* Tighten valgrind integration.Jason Evans2013-01-221-0/+2
| | | | | | | Tighten valgrind integration such that immediately after memory is validated or zeroed, valgrind is told to forget the memory's 'defined' state. The only place newly allocated memory should be left marked as 'defined' is in the public functions (e.g. calloc() and realloc()).
* Fix build break on *BSDGarrett Cooper2012-12-242-1/+10
| | | | | | | Linux uses alloca.h; many other operating systems define alloca(3) in stdlib.h. Signed-off-by: Garrett Cooper <yanegomi@gmail.com>
* Avoid arena_prof_accum()-related locking when possible.Jason Evans2012-11-132-1/+43
| | | | | | | Refactor arena_prof_accum() and its callers to avoid arena locking when prof_interval is 0 (as when profiling is disabled). Reported by Ben Maurer.
* Purge unused dirty pages in a fragmentation-reducing order.Jason Evans2012-11-061-29/+24
| | | | | | | | | | | | | | | | Purge unused dirty pages in an order that first performs clean/dirty run defragmentation, in order to mitigate available run fragmentation. Remove the limitation that prevented purging unless at least one chunk worth of dirty pages had accumulated in an arena. This limitation was intended to avoid excessive purging for small applications, but the threshold was arbitrary, and the effect of questionable utility. Relax opt_lg_dirty_mult from 5 to 3. This compensates for increased likelihood of allocating clean runs, given the same ratio of clean:dirty runs, and reduces the potential for repeated purging in pathological large malloc/free loops that push the active:dirty page ratio just over the purge threshold.
* Add arena-specific and selective dss allocation.Jason Evans2012-10-138-35/+145
| | | | | | | | | | | | | | | | | | | Add the "arenas.extend" mallctl, so that it is possible to create new arenas that are outside the set that jemalloc automatically multiplexes threads onto. Add the ALLOCM_ARENA() flag for {,r,d}allocm(), so that it is possible to explicitly allocate from a particular arena. Add the "opt.dss" mallctl, which controls the default precedence of dss allocation relative to mmap allocation. Add the "arena.<i>.dss" mallctl, which makes it possible to set the default dss precedence on a per arena or global basis. Add the "arena.<i>.purge" mallctl, which obsoletes "arenas.purge". Add the "stats.arenas.<i>.dss" mallctl.
* Drop const from malloc_usable_size() argument on Linux.Jason Evans2012-10-092-1/+11
| | | | | Drop const from malloc_usable_size() argument on Linux, in order to match the prototype in Linux's malloc.h.
* Fix fork(2)-related deadlocks.Jason Evans2012-10-095-0/+31
| | | | | | | | | | | | | | | | | Add a library constructor for jemalloc that initializes the allocator. This fixes a race that could occur if threads were created by the main thread prior to any memory allocation, followed by fork(2), and then memory allocation in the child process. Fix the prefork/postfork functions to acquire/release the ctl, prof, and rtree mutexes. This fixes various fork() child process deadlocks, but one possible deadlock remains (intentionally) unaddressed: prof backtracing can acquire runtime library mutexes, so deadlock is still possible if heap profiling is enabled during fork(). This deadlock is known to be a real issue in at least the case of libgcc-based backtracing. Reported by tfengjun.
* Fix mlockall()/madvise() interaction.Jason Evans2012-10-092-1/+4
| | | | | | | | mlockall(2) can cause purging via madvise(2) to fail. Fix purging code to check whether madvise() succeeded, and base zeroed page metadata on the result. Reported by Olivier Lecomte.
* Define LG_QUANTUM for hppa.Jason Evans2012-10-081-0/+3
| | | | Submitted by Jory Pratt.
* Auto-detect whether running inside Valgrind.Jason Evans2012-05-151-0/+1
| | | | | Auto-detect whether running inside Valgrind, thus removing the need to manually specify MALLOC_CONF=valgrind:true.
* Fix heap profiling crash for realloc(p, 0) case.Jason Evans2012-05-151-1/+1
| | | | | Fix prof_realloc() to not call prof_ctx_set() if a sampled object is being freed via realloc(p, 0).
* Fix large calloc() zeroing bugs.Jason Evans2012-05-111-5/+10
| | | | | | | | | Refactor code such that arena_mapbits_{large,small}_set() always preserves the unzeroed flag, and manually manipulate the unzeroed flag in the one case where it actually gets reset (in arena_chunk_purge()). This fixes unzeroed preservation bugs in arena_run_split() and arena_ralloc_large_grow(). These bugs caused large calloc() to return non-zeroed memory under some circumstances.
* Update a comment.Jason Evans2012-05-101-9/+9
|
* Export je_memalign and je_vallocMike Hommey2012-05-091-0/+9
| | | | | | da99e31 removed attributes on je_memalign and je_valloc, while they didn't have a definition in the jemalloc.h header, thus making them non-exported. Export them again, by defining them in the jemalloc.h header.
* Add the --enable-mremap option.Jason Evans2012-05-092-6/+16
| | | | | | Add the --enable-mremap option, and disable the use of mremap(2) by default, for the same reason that freeing chunks via munmap(2) is disabled by default on Linux: semi-permanent VM map fragmentation.
* Use "standard" printf prefixes instead of MSVC ones in inttypes.hMike Hommey2012-05-021-51/+59
| | | | | We don't use MSVC's printf, but ours, and it doesn't support the I32 and I64 prefixes.
* Further optimize and harden arena_salloc().Jason Evans2012-05-022-34/+69
| | | | | | | | | Further optimize arena_salloc() to only look at the binind chunk map bits in the common case. Add more sanity checks to arena_salloc() that detect chunk map inconsistencies for large allocations (whether due to allocator bugs or application bugs).