History log of /external/jemalloc/src/jemalloc.c
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
fb795867f0b3aa28bbdf177e1026f3e3408e0338 14-Nov-2014 Christopher Ferris <cferris@google.com> Tune the jemalloc to reign in PSS.

The tcache in jemalloc can take up quite a bit of extra PSS. Disabling
the tcache can save a lot of PSS, but it radically reduces performance.

Tune the number of small and large values to store in the tcache.
Immediately force any dirty pages to be purged, rather than keep some
number of dirty pages around.

Restore the chunk size back to 4MB. Using this chunk size and the force
dirty page results in a higher cf-bench native mallocs score but about
the same amount of PSS use.

Limit the number of arenas to 2. The default is 2 * number of cpus, but
that increases the amount of PSS used. My benchmarking indicates that
more than 2 really doesn't help too much even on a device with 4 cpus.
Nearly all speed-ups come from the tcache.

Bug: 17498287

Change-Id: I23b23dd88288c90e002a0a04684fb06dbf4ee742
/external/jemalloc/src/jemalloc.c
ea3e483d2fe28e8aa071f96d2b289e2dbe160cc5 17-Jul-2014 Christopher Ferris <cferris@google.com> Do not look for config data on the file system.

There are three ways to get jemalloc config data, but only the
configuration information embedded in the executable is really
applicable for android.

This avoids a bunch of checks for files in /etc that will never exist.

(cherry picked from commit ca3c0aad9f2dd1b19f478df5404474c1cbb3d872)

Change-Id: I457a30eeb28bcae89efc4b82b80f125e6a647c40
/external/jemalloc/src/jemalloc.c
f7bb72530b8a59634651c91bc00ef3f106686e71 29-May-2014 Richard Diamond <wichard@vitalitystudios.com> Don't catch fork()ing events for Native Client.

Native Client doesn't allow forking, thus there is no need to catch
fork()ing events for Native Client.

Additionally, without this commit, jemalloc will introduce an unresolved
pthread_atfork() in PNaCl Rust bins.
/external/jemalloc/src/jemalloc.c
12141150fdbda57651a53ae2fe0edaea4891d814 16-May-2014 Jason Evans <je@fb.com> Refactor huge allocation to be managed by arenas.

Refactor huge allocation to be managed by arenas (though the global
red-black tree of huge allocations remains for lookup during
deallocation). This is the logical conclusion of recent changes that 1)
made per arena dss precedence apply to huge allocation, and 2) made it
possible to replace the per arena chunk allocation/deallocation
functions.

Remove the top level huge stats, and replace them with per arena huge
stats.

Normalize function names and types to *dalloc* (some were *dealloc*).

Remove the --enable-mremap option. As jemalloc currently operates, this
is a performace regression for some applications, but planned work to
logarithmically space huge size classes should provide similar amortized
performance. The motivation for this change was that mremap-based huge
reallocation forced leaky abstractions that prevented refactoring.
/external/jemalloc/src/jemalloc.c
59113bcc94b9fc7549611afb99ca99cad1a7f196 06-May-2014 aravind <aravind@fb.com> Add support for user-specified chunk allocators/deallocators.

Add new mallctl endpoints "arena<i>.chunk.alloc" and
"arena<i>.chunk.dealloc" to allow userspace to configure
jemalloc's chunk allocator and deallocator on a per-arena
basis.
/external/jemalloc/src/jemalloc.c
8888fdb946de0fff946f6a27ded0f54b06bdc51f 02-May-2014 Jason Evans <je@fb.com> Fix coding sytle nits.
/external/jemalloc/src/jemalloc.c
73b37a9697acd53496bbef06ed25696e0c897341 23-Apr-2014 Jason Evans <jasone@canonware.com> Simplify backtracing.

Simplify backtracing to not ignore any frames, and compensate for this
in pprof in order to increase flexibility with respect to function-based
refactoring even in the presence of non-deterministic inlining. Modify
pprof to blacklist all jemalloc allocation entry points including
non-standard ones like mallocx(), and ignore all allocator-internal
frames. Prior to this change, pprof excluded the specifically
blacklisted functions from backtraces, but it left allocator-internal
frames intact.
/external/jemalloc/src/jemalloc.c
bd87b01999416ec7418ff8bdb504d9b6c009ff68 16-Apr-2014 Jason Evans <je@fb.com> Optimize Valgrind integration.

Forcefully disable tcache if running inside Valgrind, and remove
Valgrind calls in tcache-specific code.

Restructure Valgrind-related code to move most Valgrind calls out of the
fast path functions.

Take advantage of static knowledge to elide some branches in
JEMALLOC_VALGRIND_REALLOC().
/external/jemalloc/src/jemalloc.c
ecd3e59ca351d7111ec72a327fe0c009f2aa69a0 15-Apr-2014 Jason Evans <je@fb.com> Remove the "opt.valgrind" mallctl.

Remove the "opt.valgrind" mallctl because it is unnecessary -- jemalloc
automatically detects whether it is running inside valgrind.
/external/jemalloc/src/jemalloc.c
9790b9667fd975b1f9a4f108f9d0a20ab265c6b6 15-Apr-2014 Jason Evans <jasone@canonware.com> Remove the *allocm() API, which is superceded by the *allocx() API.
/external/jemalloc/src/jemalloc.c
9b0cbf0850b130a9b0a8c58bd10b2926b2083510 11-Apr-2014 Jason Evans <je@fb.com> Remove support for non-prof-promote heap profiling metadata.

Make promotion of sampled small objects to large objects mandatory, so
that profiling metadata can always be stored in the chunk map, rather
than requiring one pointer per small region in each small-region page
run. In practice the non-prof-promote code was only useful when using
jemalloc to track all objects and report them as leaks at program exit.
However, Valgrind is at least as good a tool for this particular use
case.

Furthermore, the non-prof-promote code is getting in the way of
some optimizations that will make heap profiling much cheaper for the
predominant use case (sampling a small representative proportion of all
allocations).
/external/jemalloc/src/jemalloc.c
be8e59f5a64ef775c9694aee0d6a87d92336d303 06-Apr-2014 Ben Maurer <bmaurer@fb.com> Don't dereference chunk->arena in free() hot path

When you call free() we load chunk->arena even though that
data isn't used on the tcache hot path.

In profiling some FB applications, I found that ~30% of the
dTLB misses in the free() function come from this line. With
4 MB chunks, the arena_chunk_t->map is ~ 32 KB (1024 pages
in the chunk, 4 8 byte pointers in arena_chunk_map_t). This
means there's only a 1/8 chance of the page containing
chunk->arena also comtaining the map bits.
/external/jemalloc/src/jemalloc.c
fbb31029a5c2f556f39e04a8781340d4ee4cf16c 27-Mar-2014 Max Wang <mwang@fb.com> Use arena dss prec instead of default for huge allocs.

Pass a dss_prec_t parameter to huge_{m,p,r}alloc instead of defaulting
to the chunk dss prec.
/external/jemalloc/src/jemalloc.c
e2206edebcce662e3979c68ba182d0bcf38141ba 21-Jan-2014 Jason Evans <jasone@canonware.com> Fix unused variable warnings.
/external/jemalloc/src/jemalloc.c
b2c31660be917ea6d59cd54e6f650b06b5e812ed 13-Jan-2014 Jason Evans <je@fb.com> Extract profiling code from [re]allocation functions.

Extract profiling code from malloc(), imemalign(), calloc(), realloc(),
mallocx(), rallocx(), and xallocx(). This slightly reduces the amount
of code compiled into the fast paths, but the primary benefit is the
combinatorial complexity reduction.

Simplify iralloc[t]() by creating a separate ixalloc() that handles the
no-move cases.

Further simplify [mrxn]allocx() (and by implication [mrn]allocm()) to
make request size overflows due to size class and/or alignment
constraints trigger undefined behavior (detected by debug-only
assertions).

Report ENOMEM rather than EINVAL if an OOM occurs during heap profiling
backtrace creation in imemalign(). This bug impacted posix_memalign()
and aligned_alloc().
/external/jemalloc/src/jemalloc.c
040531292147e8e4847d6c666746a426403d0cf5 21-Dec-2013 Jason Evans <je@fb.com> Fix an uninitialized variable read in xallocx().
/external/jemalloc/src/jemalloc.c
665769357cd77b74e00a146f196fff19243b33c4 16-Dec-2013 Jason Evans <jasone@canonware.com> Optimize arena_prof_ctx_set().

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.
/external/jemalloc/src/jemalloc.c
d82a5e6a34f20698ab9368bb2b4953b81d175552 13-Dec-2013 Jason Evans <jasone@canonware.com> Implement the *allocx() API.

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);
/external/jemalloc/src/jemalloc.c
736923254409aed1a4a226e0ba7429f573c1f372 10-Dec-2013 Jason Evans <je@fb.com> Silence some unused variable warnings.
/external/jemalloc/src/jemalloc.c
52b30691f9a98fe7c8c59d587eb6285a3bacaabc 03-Dec-2013 Jason Evans <je@fb.com> Remove unused variable.
/external/jemalloc/src/jemalloc.c
addad093f887cecddd462b7130125a0e08060e1f 30-Nov-2013 Jason Evans <jasone@canonware.com> Clean up malloc_ncpus().

Clean up malloc_ncpus() by replacing incorrectly indented if..else
branches with a ?: expression.

Submitted by Igor Podlesny.
/external/jemalloc/src/jemalloc.c
39e7fd0580a140912fa1170de7a7699c86afe45d 26-Nov-2013 Jason Evans <je@fb.com> Fix ALLOCM_ARENA(a) handling in rallocm().

Fix rallocm() to use the specified arena for allocation, not just
deallocation.

Clarify ALLOCM_ARENA(a) documentation.
/external/jemalloc/src/jemalloc.c
ac4403cacb225c0cf2c926179af39c21bd7bfc3a 21-Oct-2013 Leonard Crestez <lcrestez@ixiacom.com> Delay pthread_atfork registering.

This function causes recursive allocation on LinuxThreads.

Signed-off-by: Crestez Dan Leonard <lcrestez@ixiacom.com>
/external/jemalloc/src/jemalloc.c
1d1cee127aebc6ca25207435ddc6ae5d9bb90d41 22-Oct-2013 Jason Evans <je@fb.com> Add a missing mutex unlock in malloc_init_hard() error path.

Add a missing mutex unlock in a malloc_init_hard() error path (failed
mutex initialization). In practice this bug was very unlikely to ever
trigger, but if it did, application deadlock would likely result.

Reported by Pat Lynch.
/external/jemalloc/src/jemalloc.c
e2985a23819670866c041ba07964099eeb9e0e07 22-Oct-2013 Jason Evans <je@fb.com> Avoid (x < 0) comparison for unsigned x.

Avoid (min < 0) comparison for unsigned min in malloc_conf_init(). This
bug had no practical consequences.

Reported by Pat Lynch.
/external/jemalloc/src/jemalloc.c
6556e28be15d9acd8f3835fb9fad90145e1edbff 21-Oct-2013 Jason Evans <je@fb.com> Prefer not_reached() over assert(false) where appropriate.
/external/jemalloc/src/jemalloc.c
543abf7e6c7de06fe9654e91190b5c44a11b065e 20-Oct-2013 Jason Evans <jasone@canonware.com> Fix inlining warning.

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.
/external/jemalloc/src/jemalloc.c
dd6ef0302f3980200ed602ec600e211f55e58694 20-Sep-2013 Alexandre Perrin <alex@kaworu.ch> malloc_conf_init: revert errno value when readlink(2) fail.
/external/jemalloc/src/jemalloc.c
88c222c8e91499bf5d3fba53b24222df0cda5771 06-Feb-2013 Jason Evans <je@fb.com> Fix a prof-related locking order bug.

Fix a locking order bug that could cause deadlock during fork if heap
profiling were enabled.
/external/jemalloc/src/jemalloc.c
bbe29d374d0fa5f4684621f16c099294e56c26ef 31-Jan-2013 Jason Evans <je@fb.com> Fix potential TLS-related memory corruption.

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).
/external/jemalloc/src/jemalloc.c
d1b6e18a99caf7e0c38707f4aed7ec8c492e0424 23-Jan-2013 Jason Evans <je@fb.com> Revert opt_abort and opt_junk refactoring.

Revert refactoring of opt_abort and opt_junk declarations. clang
accepts the config_*-based declarations (and generates correct code),
but gcc complains with:

error: initializer element is not constant
/external/jemalloc/src/jemalloc.c
ba175a2bfb236d79404012d9b5bb6e9b3c8be8dd 22-Jan-2013 Jason Evans <jasone@canonware.com> Use config_* instead of JEMALLOC_*.

Convert a couple of stragglers from JEMALLOC_* to use config_*.
/external/jemalloc/src/jemalloc.c
88393cb0eb9a046000d20809809d4adac11957ab 22-Jan-2013 Jason Evans <jasone@canonware.com> Add and use JEMALLOC_ALWAYS_INLINE.

Add JEMALLOC_ALWAYS_INLINE and use it to guarantee that the entire fast
paths of the primary allocation/deallocation functions are inlined.
/external/jemalloc/src/jemalloc.c
6e6164ae159d9c3bd4f44bd2cba6fc3237687c80 03-Dec-2012 Garrett Cooper <yanegomi@gmail.com> Don't mangle errno with free(3) if utrace(2) fails

This ensures POLA on FreeBSD (at least) as free(3) is generally assumed
to not fiddle around with errno.

Signed-off-by: Garrett Cooper <yanegomi@gmail.com>
/external/jemalloc/src/jemalloc.c
1bf2743e08ba66cc141e296812839947223e4370 23-Dec-2012 Jason Evans <jasone@canonware.com> Add clipping support to lg_chunk option processing.

Modify processing of the lg_chunk option so that it clips an
out-of-range input to the edge of the valid range. This makes it
possible to request the minimum possible chunk size without intimate
knowledge of allocator internals.

Submitted by Ian Lepore (see FreeBSD PR bin/174641).
/external/jemalloc/src/jemalloc.c
609ae595f0358157b19311b0f9f9591db7cee705 11-Oct-2012 Jason Evans <je@fb.com> Add arena-specific and selective dss allocation.

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.
/external/jemalloc/src/jemalloc.c
2cc11ff83748be63302b0289a3abb1d86e1e437f 10-Oct-2012 Jason Evans <je@fb.com> Make malloc_usable_size() implementation consistent with prototype.

Use JEMALLOC_USABLE_SIZE_CONST for the malloc_usable_size()
implementation as well as the prototype, for consistency's sake.
/external/jemalloc/src/jemalloc.c
b5225928fe106a7d809bd34e849abcd6941e93c7 10-Oct-2012 Jason Evans <je@fb.com> Fix fork(2)-related mutex acquisition order.

Fix mutex acquisition order inversion for the chunks rtree and the base
mutex. Chunks rtree acquisition was introduced by the previous commit,
so this bug was short-lived.
/external/jemalloc/src/jemalloc.c
20f1fc95adb35ea63dc61f47f2b0ffbd37d39f32 09-Oct-2012 Jason Evans <je@fb.com> Fix fork(2)-related deadlocks.

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.
/external/jemalloc/src/jemalloc.c
1d553f72cbbcbacc1802d2cc96a4024315e616b3 26-Sep-2012 Corey Richardson <corey@octayn.net> If sysconf() fails, the number of CPUs is reported as UINT_MAX, not 1 as it should be
/external/jemalloc/src/jemalloc.c
5c710cee783a44061fa2c467ffd8984b8047b90e 24-May-2012 Jason Evans <je@fb.com> Remove const from __*_hook variable declarations.

Remove const from __*_hook variable declarations, so that glibc can
modify them during process forking.
/external/jemalloc/src/jemalloc.c
174b70efb4942be112b1ea38db1e5c6ca7599e5d 16-May-2012 Jason Evans <je@fb.com> Disable tcache by default if running inside Valgrind.

Disable tcache by default if running inside Valgrind, in order to avoid
making unallocated objects appear reachable to Valgrind.
/external/jemalloc/src/jemalloc.c
781fe75e0a03f13bc1f5403acbbf87796ceea1dc 15-May-2012 Jason Evans <je@fb.com> Auto-detect whether running inside Valgrind.

Auto-detect whether running inside Valgrind, thus removing the need to
manually specify MALLOC_CONF=valgrind:true.
/external/jemalloc/src/jemalloc.c
58ad1e4956affe0f9949445dce4410ad70b4cdac 12-May-2012 Jason Evans <jasone@canonware.com> Return early in _malloc_{pre,post}fork() if uninitialized.

Avoid mutex operations in _malloc_{pre,post}fork() unless jemalloc has
been initialized.

Reported by David Xu.
/external/jemalloc/src/jemalloc.c
fd97b1dfc76647c3f90f28dc63cc987041fe20df 30-Apr-2012 Mike Hommey <mh@glandium.org> Add support for MSVC

Tested with MSVC 8 32 and 64 bits.
/external/jemalloc/src/jemalloc.c
da99e31105eb709ef4ec8a120b115c32a6b9723a 30-Apr-2012 Mike Hommey <mh@glandium.org> Replace JEMALLOC_ATTR with various different macros when it makes sense

Theses newly added macros will be used to implement the equivalent under
MSVC. Also, move the definitions to headers, where they make more sense,
and for some, are even more useful there (e.g. malloc).
/external/jemalloc/src/jemalloc.c
a14bce85e885f83c96116cc5438ae52d740f3727 30-Apr-2012 Mike Hommey <mh@glandium.org> Use Get/SetLastError on Win32

Using errno on win32 doesn't quite work, because the value set in a shared
library can't be read from e.g. an executable calling the function setting
errno.

At the same time, since buferror always uses errno/GetLastError, don't pass
it.
/external/jemalloc/src/jemalloc.c
3fb50b0407ff7dfe14727995706e2b42836f0f7e 25-Apr-2012 Jason Evans <je@fb.com> Fix a PROF_ALLOC_PREP() error path.

Fix a PROF_ALLOC_PREP() error path to initialize the return value to
NULL.
/external/jemalloc/src/jemalloc.c
8694e2e7b901eb3254a7da2461709ba2ce135aba 23-Apr-2012 Jason Evans <je@fb.com> Silence compiler warnings.
/external/jemalloc/src/jemalloc.c
a19e87fbad020e8dd3d26682032929e8e5ae71c1 22-Apr-2012 Mike Hommey <mh@glandium.org> Add support for Mingw
/external/jemalloc/src/jemalloc.c
a8f8d7540d66ddee7337db80c92890916e1063ca 22-Apr-2012 Jason Evans <jasone@canonware.com> Remove mmap_unaligned.

Remove mmap_unaligned, which was used to heuristically decide whether to
optimistically call mmap() in such a way that could reduce the total
number of system calls. If I remember correctly, the intention of
mmap_unaligned was to avoid always executing the slow path in the
presence of ASLR. However, that reasoning seems to have been based on a
flawed understanding of how ASLR actually works. Although ASLR
apparently causes mmap() to ignore address requests, it does not cause
total placement randomness, so there is a reasonable expectation that
iterative mmap() calls will start returning chunk-aligned mappings once
the first chunk has been properly aligned.
/external/jemalloc/src/jemalloc.c
606f1fdc3cdbc700717133ca56685313caea24bb 21-Apr-2012 Jason Evans <jasone@canonware.com> Put CONF_HANDLE_*() keys in quotes.

Put CONF_HANDLE_*() keys in quotes, so that they aren't mangled when
--with-private-namespace is used.
/external/jemalloc/src/jemalloc.c
86e58583bb443fcfe885a1a96b466ab5933cb443 19-Apr-2012 Jason Evans <jasone@canonware.com> Make special FreeBSD function overrides visible.

Make special FreeBSD libc/libthr function overrides for
_malloc_prefork(), _malloc_postfork(), and _malloc_thread_cleanup()
visible.
/external/jemalloc/src/jemalloc.c
0b25fe79aaf8840a5acda7e3160a053d42349872 18-Apr-2012 Jason Evans <je@fb.com> Update prof defaults to match common usage.

Change the "opt.lg_prof_sample" default from 0 to 19 (1 B to 512 KiB).

Change the "opt.prof_accum" default from true to false.

Add the "opt.prof_final" mallctl, so that "opt.prof_prefix" need not be
abused to disable final profile dumping.
/external/jemalloc/src/jemalloc.c
7ca0fdfb85b2a9fc7a112e158892c098e004385b 13-Apr-2012 Jason Evans <je@fb.com> Disable munmap() if it causes VM map holes.

Add a configure test to determine whether common mmap()/munmap()
patterns cause VM map holes, and only use munmap() to discard unused
chunks if the problem does not exist.

Unify the chunk caching for mmap and dss.

Fix options processing to limit lg_chunk to be large enough that
redzones will always fit.
/external/jemalloc/src/jemalloc.c
d6abcbb14b8d1c8beb1c61bfc5a24cb54578b85c 13-Apr-2012 Jason Evans <jasone@canonware.com> Always disable redzone by default.

Always disable redzone by default, even when --enable-debug is
specified. The memory overhead for redzones can be substantial, which
makes this feature something that should only be opted into.
/external/jemalloc/src/jemalloc.c
b8325f9cb031285585567cdeb1338aeca4185f6c 12-Apr-2012 Mike Hommey <mh@glandium.org> Call base_boot before chunk_boot0

Chunk_boot0 calls rtree_new, which calls base_alloc, which locks the
base_mtx mutex. That mutex is initialized in base_boot.
/external/jemalloc/src/jemalloc.c
5ff709c264e52651de25b788692c62ff1f6f389c 12-Apr-2012 Jason Evans <jasone@canonware.com> Normalize aligned allocation algorithms.

Normalize arena_palloc(), chunk_alloc_mmap_slow(), and
chunk_recycle_dss() to use the same algorithm for trimming
over-allocation.

Add the ALIGNMENT_ADDR2BASE(), ALIGNMENT_ADDR2OFFSET(), and
ALIGNMENT_CEILING() macros, and use them where appropriate.

Remove the run_size_p parameter from sa2u().

Fix a potential deadlock in chunk_recycle_dss() that was introduced by
eae269036c9f702d9fa9be497a1a2aa1be13a29e (Add alignment support to
chunk_alloc()).
/external/jemalloc/src/jemalloc.c
122449b073bcbaa504c4f592ea2d733503c272d2 06-Apr-2012 Jason Evans <je@fb.com> Implement Valgrind support, redzones, and quarantine.

Implement Valgrind support, as well as the redzone and quarantine
features, which help Valgrind detect memory errors. Redzones are only
implemented for small objects because the changes necessary to support
redzones around large and huge objects are complicated by in-place
reallocation, to the point that it isn't clear that the maintenance
burden is worth the incremental improvement to Valgrind support.

Merge arena_salloc() and arena_salloc_demote().

Refactor i[v]salloc() to expose the 'demote' option.
/external/jemalloc/src/jemalloc.c
a1ee7838e14b321a97bfacb1f1cf5004198f2203 11-Apr-2012 Jason Evans <je@fb.com> Rename labels.

Rename labels from FOO to label_foo in order to avoid system macro
definitions, in particular OUT and ERROR on mingw.

Reported by Mike Hommey.
/external/jemalloc/src/jemalloc.c
b147611b5253921a873191bb0589d3b18f613946 05-Apr-2012 Jason Evans <jasone@canonware.com> Add utrace(2)-based tracing (--enable-utrace).
/external/jemalloc/src/jemalloc.c
02b231205e802a7c4f33899a569adcb1312a85d5 05-Apr-2012 Jason Evans <je@fb.com> Fix threaded initialization and enable it on Linux.

Reported by Mike Hommey.
/external/jemalloc/src/jemalloc.c
01b3fe55ff3ac8e4aa689f09fcb0729da8037638 03-Apr-2012 Jason Evans <jasone@canonware.com> Add a0malloc(), a0calloc(), and a0free().

Add a0malloc(), a0calloc(), and a0free(), which are used by FreeBSD's
libc to allocate/deallocate TLS in static binaries.
/external/jemalloc/src/jemalloc.c
633aaff96787db82c06d35baf012de197a1a1902 03-Apr-2012 Jason Evans <jasone@canonware.com> Postpone mutex initialization on FreeBSD.

Postpone mutex initialization on FreeBSD until after base allocation is
safe.
/external/jemalloc/src/jemalloc.c
ae4c7b4b4092906c641d69b4bf9fcb4a7d50790d 02-Apr-2012 Jason Evans <jasone@canonware.com> Clean up *PAGE* macros.

s/PAGE_SHIFT/LG_PAGE/g and s/PAGE_SIZE/PAGE/g.

Remove remnants of the dynamic-page-shift code.

Rename the "arenas.pagesize" mallctl to "arenas.page".

Remove the "arenas.chunksize" mallctl, which is redundant with
"opt.lg_chunk".
/external/jemalloc/src/jemalloc.c
f0047372673da7f213f733465dab0d8825eb1c9f 03-Apr-2012 Jason Evans <jasone@canonware.com> Revert "Avoid NULL check in free() and malloc_usable_size()."

This reverts commit 96d4120ac08db3f2d566e8e5c3bc134a24aa0afc.

ivsalloc() depends on chunks_rtree being initialized. This can be
worked around via a NULL pointer check. However,
thread_allocated_tsd_get() also depends on initialization having
occurred, and there is no way to guard its call in free() that is
cheaper than checking whether ptr is NULL.
/external/jemalloc/src/jemalloc.c
96d4120ac08db3f2d566e8e5c3bc134a24aa0afc 02-Apr-2012 Jason Evans <jasone@canonware.com> Avoid NULL check in free() and malloc_usable_size().

Generalize isalloc() to handle NULL pointers in such a way that the NULL
checking overhead is only paid when introspecting huge allocations (or
NULL). This allows free() and malloc_usable_size() to no longer check
for NULL.

Submitted by Igor Bukanov and Mike Hommey.
/external/jemalloc/src/jemalloc.c
80b25932ca52e9506d4e2b8ee0fa58aa5ae3306d 02-Apr-2012 Mike Hommey <mh@glandium.org> Move last bit of zone initialization in zone.c, and lazy-initialize
/external/jemalloc/src/jemalloc.c
4eeb52f080edb1f4b518249388f6c617386c00e5 02-Apr-2012 Jason Evans <jasone@canonware.com> Remove vsnprintf() and strtoumax() validation.

Remove code that validates malloc_vsnprintf() and malloc_strtoumax()
against their namesakes. The validation code has adequately served its
usefulness at this point, and it isn't worth dealing with the different
formatting for %p with glibc versus other implementations for NULL
pointers ("(nil)" vs. "0x0").

Reported by Mike Hommey.
/external/jemalloc/src/jemalloc.c
3c2ba0dcbc2f4896a892fad84d5dcf5bd4c30a81 27-Mar-2012 Mike Hommey <mh@glandium.org> Avoid crashes when system libraries use the purgeable zone allocator
/external/jemalloc/src/jemalloc.c
71a93b8725fb52ae393ab88e2fccd5afa84c66a0 27-Mar-2012 Mike Hommey <mh@glandium.org> Move zone registration to zone.c
/external/jemalloc/src/jemalloc.c
e77fa59ece7e23de586f08980f627b8102511755 28-Mar-2012 Mike Hommey <mh@glandium.org> Don't use pthread_atfork to register prefork/postfork handlers on OSX

OSX libc calls zone allocators' force_lock/force_unlock already.
/external/jemalloc/src/jemalloc.c
2465bdf4937ffba309e7289014443c6b51566f22 26-Mar-2012 Jason Evans <jasone@canonware.com> Check for NULL ptr in malloc_usable_size().

Check for NULL ptr in malloc_usable_size(), rather than just asserting
that ptr is non-NULL. This matches behavior of other implementations
(e.g., glibc and tcmalloc).
/external/jemalloc/src/jemalloc.c
5c89c50d1803dc0fb6544c1abd40552e76c8614d 26-Mar-2012 Mike Hommey <mh@glandium.org> Fix glibc hooks when using both --with-jemalloc-prefix and --with-mangling
/external/jemalloc/src/jemalloc.c
41b6afb834b1f5250223678c52bd4f013d4234f6 03-Feb-2012 Jason Evans <jasone@canonware.com> Port to FreeBSD.

Use FreeBSD-specific functions (_pthread_mutex_init_calloc_cb(),
_malloc_{pre,post}fork()) to avoid bootstrapping issues due to
allocation in libc and libthr.

Add malloc_strtoumax() and use it instead of strtoul(). Disable
validation code in malloc_vsnprintf() and malloc_strtoumax() until
jemalloc is initialized. This is necessary because locale
initialization causes allocation for both vsnprintf() and strtoumax().

Force the lazy-lock feature on in order to avoid pthread_self(),
because it causes allocation.

Use syscall(SYS_write, ...) rather than write(...), because libthr wraps
write() and causes allocation. Without this workaround, it would not be
possible to print error messages in malloc_conf_init() without
substantially reworking bootstrapping.

Fix choose_arena_hard() to look at how many threads are assigned to the
candidate choice, rather than checking whether the arena is
uninitialized. This bug potentially caused more arenas to be
initialized than necessary.
/external/jemalloc/src/jemalloc.c
6da5418ded9170b087c35960e0010006430117c1 24-Mar-2012 Jason Evans <je@fb.com> Remove ephemeral mutexes.

Remove ephemeral mutexes from the prof machinery, and remove
malloc_mutex_destroy(). This simplifies mutex management on systems
that call malloc()/free() inside pthread_mutex_{create,destroy}().

Add atomic_*_u() for operation on unsigned values.

Fix prof_printf() to call malloc_vsnprintf() rather than
malloc_snprintf().
/external/jemalloc/src/jemalloc.c
9225a1991a58190207cca2ff3cdba966bb322dd5 23-Mar-2012 Jason Evans <je@fb.com> Add JEMALLOC_CC_SILENCE_INIT().

Add JEMALLOC_CC_SILENCE_INIT(), which provides succinct syntax for
initializing a variable to avoid a spurious compiler warning.
/external/jemalloc/src/jemalloc.c
cd9a1346e96f71bdecdc654ea50fc62d76371e74 22-Mar-2012 Jason Evans <je@fb.com> Implement tsd.

Implement tsd, which is a TLS/TSD abstraction that uses one or both
internally. Modify bootstrapping such that no tsd's are utilized until
allocation is safe.

Remove malloc_[v]tprintf(), and use malloc_snprintf() instead.

Fix %p argument size handling in malloc_vsnprintf().

Fix a long-standing statistics-related bug in the "thread.arena"
mallctl that could cause crashes due to linked list corruption.
/external/jemalloc/src/jemalloc.c
154829d2560a202ef6378b089655747585e44fb5 20-Mar-2012 Mike Hommey <mh@glandium.org> Improve zone support for OSX

I tested a build from 10.7 run on 10.7 and 10.6, and a build from 10.6
run on 10.6. The AC_COMPILE_IFELSE limbo is to avoid running a program
during configure, which presumably makes it work when cross compiling
for iOS.
/external/jemalloc/src/jemalloc.c
e24c7af35d1e9d24d02166ac98cfca7cf807ff13 19-Mar-2012 Jason Evans <je@fb.com> Invert NO_TLS to JEMALLOC_TLS.
/external/jemalloc/src/jemalloc.c
4e2e3dd9cf19ed5991938a708a8b50611aa5bbf8 14-Mar-2012 Jason Evans <je@fb.com> Fix fork-related bugs.

Acquire/release arena bin locks as part of the prefork/postfork. This
bug made deadlock in the child between fork and exec a possibility.

Split jemalloc_postfork() into jemalloc_postfork_{parent,child}() so
that the child can reinitialize mutexes rather than unlocking them. In
practice, this bug tended not to cause problems.
/external/jemalloc/src/jemalloc.c
0a0bbf63e5d9bc60d6854c6d46b437fbeebd1470 13-Mar-2012 Jason Evans <je@fb.com> Implement aligned_alloc().

Implement aligned_alloc(), which was added in the C11 standard. The
function is weakly specified to the point that a minimally compliant
implementation would be painful to use (size must be an integral
multiple of alignment!), which in practice makes posix_memalign() a
safer choice.
/external/jemalloc/src/jemalloc.c
4c2faa8a7c42a47a6bea509f5a23234bc5a66d40 13-Mar-2012 Jason Evans <je@fb.com> Fix a regression in JE_COMPILABLE().

Revert JE_COMPILABLE() so that it detects link errors. Cross-compiling
should still work as long as a valid configure cache is provided.

Clean up some comments/whitespace.
/external/jemalloc/src/jemalloc.c
d81e4bdd5c991bd5642c8b859ef1f752b51cd9be 06-Mar-2012 Jason Evans <je@fb.com> Implement malloc_vsnprintf().

Implement malloc_vsnprintf() (a subset of vsnprintf(3)) as well as
several other printing functions based on it, so that formatted printing
can be relied upon without concern for inducing a dependency on floating
point runtime support. Replace malloc_write() calls with
malloc_*printf() where doing so simplifies the code.

Add name mangling for library-private symbols in the data and BSS
sections. Adjust CONF_HANDLE_*() macros in malloc_conf_init() to expose
all opt_* variable use to cpp so that proper mangling occurs.
/external/jemalloc/src/jemalloc.c
4507f34628dfae26e6b0a6faa13e5f9a49600616 05-Mar-2012 Jason Evans <je@fb.com> Remove the lg_tcache_gc_sweep option.

Remove the lg_tcache_gc_sweep option, because it is no longer
very useful. Prior to the addition of dynamic adjustment of tcache fill
count, it was possible for fill/flush overhead to be a problem, but this
problem no longer occurs.
/external/jemalloc/src/jemalloc.c
7e77eaffffe5c73d44ee64b14ba4b3d7693179d6 03-Mar-2012 Jason Evans <je@fb.com> Add the --disable-experimental option.
/external/jemalloc/src/jemalloc.c
0a5489e37da88a1a50fbf8552e0d3a7f8fd93ffc 02-Mar-2012 Jason Evans <je@fb.com> Add --with-mangling.

Add the --with-mangling configure option, which can be used to specify
name mangling on a per public symbol basis that takes precedence over
--with-jemalloc-prefix.

Expose the memalign() and valloc() overrides even if
--with-jemalloc-prefix is specified. This change does no real harm, and
simplifies the code.
/external/jemalloc/src/jemalloc.c
7e15dab94d3f008b0a6c296ad7afec9ed47ff1ac 29-Feb-2012 Jason Evans <je@fb.com> Add nallocm().

Add nallocm(), which computes the real allocation size that would result
from the corresponding allocm() call. nallocm() is a functional
superset of OS X's malloc_good_size(), in that it takes alignment
constraints into account.
/external/jemalloc/src/jemalloc.c
4bb09830133ffa8b27a95bc3727558007722c152 29-Feb-2012 Jason Evans <je@fb.com> Use glibc allocator hooks.

When jemalloc is used as a libc malloc replacement (i.e. not prefixed),
some particular setups may end up inconsistently calling malloc from
libc and free from jemalloc, or the other way around.

glibc provides hooks to make its functions use alternative
implementations. Use them.

Submitted by Karl Tomlinson and Mike Hommey.
/external/jemalloc/src/jemalloc.c
5965631636c620fba2eb33698accee75fd207aab 29-Feb-2012 Jason Evans <je@fb.com> Do not enforce minimum alignment in memalign().

Do not enforce minimum alignment in memalign(). This is a non-standard
function, and there is disagreement over whether to enforce minimum
alignment. Solaris documentation (whence memalign() originated) says
that minimum alignment is required:

The value of alignment must be a power of two and must be greater than
or equal to the size of a word.

However, Linux's manual page says in its NOTES section:

memalign() may not check that the boundary parameter is correct.

This is descriptive rather than prescriptive, but applications with
bad assumptions about memalign() exist, so be as forgiving as possible.

Reported by Mike Hommey.
/external/jemalloc/src/jemalloc.c
d073a321091800e71ea56f98701253dc0969d879 29-Feb-2012 Jason Evans <je@fb.com> Enable the stats configuration option by default.
/external/jemalloc/src/jemalloc.c
c90ad71237c05473bcb968beddebb0a487c36e75 29-Feb-2012 Jason Evans <je@fb.com> Remove the sysv option.
/external/jemalloc/src/jemalloc.c
f081b88dfbce94c3c7c8faf0b0f91b117fbdfcc6 29-Feb-2012 Jason Evans <je@fb.com> Fix realloc(p, 0) to act like free(p).

Reported by Yoni Londer.
/external/jemalloc/src/jemalloc.c
b172610317babc7f365584ddd7fdaf4eb8d9d04c 29-Feb-2012 Jason Evans <je@fb.com> Simplify small size class infrastructure.

Program-generate small size class tables for all valid combinations of
LG_TINY_MIN, LG_QUANTUM, and PAGE_SHIFT. Use the appropriate table to generate
all relevant data structures, and remove the distinction between
tiny/quantum/cacheline/subpage bins.

Remove --enable-dynamic-page-shift. This option didn't prove useful in
practice, and it prevented optimizations.

Add Tilera architecture support.
/external/jemalloc/src/jemalloc.c
5389146191b279ca3b90028357dd6ad66b283def 14-Feb-2012 Jason Evans <je@fb.com> Remove the opt.lg_prof_bt_max option.

Remove opt.lg_prof_bt_max, and hard code it to 7. The original
intention of this option was to enable faster backtracing by limiting
backtrace depth. However, this makes graphical pprof output very
difficult to interpret. In practice, decreasing sampling frequency is a
better mechanism for limiting profiling overhead.
/external/jemalloc/src/jemalloc.c
0b526ff94da7e59aa947a4d3529b2376794f8b01 14-Feb-2012 Jason Evans <je@fb.com> Remove the opt.lg_prof_tcmax option.

Remove the opt.lg_prof_tcmax option and hard-code a cache size of 1024.
This setting is something that users just shouldn't have to worry about.
If lock contention actually ends up being a problem, the simple solution
available to the user is to reduce sampling frequency.
/external/jemalloc/src/jemalloc.c
6ffbbeb5d60bdf16e15927cb1f173376fe355449 13-Feb-2012 Jason Evans <je@fb.com> Silence compiler warnings.
/external/jemalloc/src/jemalloc.c
4162627757889ea999264c2ddbc3c354768774e2 13-Feb-2012 Jason Evans <je@fb.com> Remove the swap feature.

Remove the swap feature, which enabled per application swap files. In
practice this feature has not proven itself useful to users.
/external/jemalloc/src/jemalloc.c
7372b15a31c63ac5cb9ed8aeabc2a0a3c005e8bf 11-Feb-2012 Jason Evans <je@fb.com> Reduce cpp conditional logic complexity.

Convert configuration-related cpp conditional logic to use static
constant variables, e.g.:

#ifdef JEMALLOC_DEBUG
[...]
#endif

becomes:

if (config_debug) {
[...]
}

The advantage is clearer, more concise code. The main disadvantage is
that data structures no longer have conditionally defined fields, so
they pay the cost of all fields regardless of whether they are used. In
practice, this is only a minor concern; config_stats will go away in an
upcoming change, and config_prof is the only other major feature that
depends on more than a few special-purpose fields.
/external/jemalloc/src/jemalloc.c
30fbef8aeaf65fcd6b265fb9f551e7c2ec8cb22f 06-Nov-2011 Jason Evans <je@fb.com> Fix rallocm() test to support >4KiB pages.
/external/jemalloc/src/jemalloc.c
8e6f8b490dbd4b9ae715267fd401f09a056f92c4 04-Nov-2011 Jason Evans <je@fb.com> Initialize arenas_tsd before setting it.

Reported by: Ethan Burns, Rich Prohaska, Tudor Bosman
/external/jemalloc/src/jemalloc.c
46405e670f9b4831da9c24c15f0f3a537ef2606b 31-Aug-2011 Jason Evans <je@fb.com> Fix a prof-related bug in realloc().

Fix realloc() such that it only records the object passed in as freed if
no OOM error occurs.
/external/jemalloc/src/jemalloc.c
749c2a0ab62089891d8e40840fbf384f12cb8401 13-Aug-2011 Jason Evans <je@fb.com> Add missing prof_malloc() call in allocm().

Add a missing prof_malloc() call in allocm(). Before this fix, negative
object/byte counts could be observed in heap profiles for applications
that use allocm().
/external/jemalloc/src/jemalloc.c
a507004d294ad0c78b4d01559479620ebb272a49 12-Aug-2011 Jason Evans <je@fb.com> Fix off-by-one backtracing issues.

Rewrite prof_alloc_prep() as a cpp macro, PROF_ALLOC_PREP(), in order to
remove any doubt as to whether an additional stack frame is created.
Prior to this change, it was assumed that inlining would reduce the
total number of frames in the backtrace, but in practice behavior wasn't
completely predictable.

Create imemalign() and call it from posix_memalign(), memalign(), and
valloc(), so that all entry points require the same number of stack
frames to be ignored during backtracing.
/external/jemalloc/src/jemalloc.c
b493ce22a4b545c17d5942d0fc65f413dd97743a 12-Aug-2011 Jason Evans <je@fb.com> Conditionalize an isalloc() call in rallocm().

Conditionalize an isalloc() call in rallocm() that be unnecessary.
/external/jemalloc/src/jemalloc.c
183ba50c1940a95080f6cf890ae4ae40200301e7 12-Aug-2011 Jason Evans <je@fb.com> Fix two prof-related bugs in rallocm().

Properly handle boundary conditions for sampled region promotion in
rallocm(). Prior to this fix, some combinations of 'size' and 'extra'
values could cause erroneous behavior. Additionally, size class
recording for promoted regions was incorrect.
/external/jemalloc/src/jemalloc.c
7427525c28d58c423a68930160e3b0fe577fe953 01-Apr-2011 Jason Evans <jasone@canonware.com> Move repo contents in jemalloc/ to top level.
/external/jemalloc/src/jemalloc.c