summaryrefslogtreecommitdiffstats
path: root/src/ctl.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix a few mallctl() documentation errors.Jason Evans2013-12-201-121/+124
| | | | Normalize mallctl() order (code and documentation).
* Consistently use malloc_mutex_prefork().Jason Evans2013-10-211-1/+1
| | | | | Consistently use malloc_mutex_prefork() instead of malloc_mutex_lock() in all prefork functions.
* Fix a race condition in the "arenas.extend" mallctl.Jason Evans2013-10-201-36/+44
| | | | | | | | Fix a race condition in the "arenas.extend" mallctl that could lead to internal data structure corruption. The race could be hit if one thread called the "arenas.extend" mallctl while another thread concurrently triggered initialization of one of the lazily created arenas.
* Silence an unused variable warning.Jason Evans2013-10-201-1/+1
| | | | Reported by Ricardo Nabinger Sanchez.
* Fix "arenas.extend" mallctl to return the number of arenas.Jason Evans2012-11-301-9/+11
| | | | Reported by Mike Hommey.
* Fix deadlock in the arenas.purge mallctl.Jason Evans2012-11-041-26/+22
| | | | | Fix deadlock in the arenas.purge mallctl due to recursive mutex acquisition.
* Add ctl_mutex proection to arena_i_dss_ctl().Jason Evans2012-10-151-0/+2
| | | | | Add ctl_mutex proection to arena_i_dss_ctl(), since ctl_stats.narenas is accessed.
* Add arena-specific and selective dss allocation.Jason Evans2012-10-131-53/+287
| | | | | | | | | | | | | | | | | | | 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.
* Fix fork(2)-related deadlocks.Jason Evans2012-10-091-0/+21
| | | | | | | | | | | | | | | | | 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 error return value in thread_tcache_enabled_ctl().Jason Evans2012-10-081-1/+1
| | | | Reported by Corey Richardson.
* Add the --enable-mremap option.Jason Evans2012-05-091-0/+3
| | | | | | 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.
* Remove the VOID macroMike Hommey2012-04-301-6/+2
| | | | Windows headers define a VOID macro.
* Avoid variable length arrays and remove declarations within codeMike Hommey2012-04-291-2/+2
| | | | | | | | | | | | MSVC doesn't support C99, and building as C++ to be able to use them is dangerous, as C++ and C99 are incompatible. Introduce a VARIABLE_ARRAY macro that either uses VLA when supported, or alloca() otherwise. Note that using alloca() inside loops doesn't quite work like VLAs, thus the use of VARIABLE_ARRAY there is discouraged. It might be worth investigating ways to check whether VARIABLE_ARRAY is used in such context at runtime in debug builds and bail out if that happens.
* Fix the "epoch" mallctl.Jason Evans2012-04-251-12/+11
| | | | | Fix the "epoch" mallctl to update cached stats even if the passed in epoch is 0.
* Fix two CHILD() macro calls in the ctl tree.Jason Evans2012-04-241-2/+2
|
* Fix ctl regression.Jason Evans2012-04-241-24/+26
| | | | | Fix ctl to correctly compute the number of children at each level of the ctl tree.
* Avoid using a union for ctl_node_sMike Hommey2012-04-231-69/+99
| | | | | | | MSVC doesn't support C99, and as such doesn't support designated initialization of structs and unions. As there is never a mix of indexed and named nodes, it is pretty straightforward to use a different type for each.
* Update prof defaults to match common usage.Jason Evans2012-04-171-0/+3
| | | | | | | | | 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.
* Add the --disable-munmap option.Jason Evans2012-04-171-0/+3
| | | | | | Add the --disable-munmap option, remove the configure test that attempted to detect the VM allocation quirk known to exist on Linux x86[_64], and make --disable-munmap implicit on Linux.
* Implement Valgrind support, redzones, and quarantine.Jason Evans2012-04-111-1/+14
| | | | | | | | | | | | | 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.
* Rename labels.Jason Evans2012-04-101-46/+46
| | | | | | | 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.
* Add utrace(2)-based tracing (--enable-utrace).Jason Evans2012-04-051-0/+6
|
* Add missing "opt.lg_tcache_max" mallctl implementation.Jason Evans2012-04-041-0/+3
|
* Add a0malloc(), a0calloc(), and a0free().Jason Evans2012-04-041-1/+1
| | | | | Add a0malloc(), a0calloc(), and a0free(), which are used by FreeBSD's libc to allocate/deallocate TLS in static binaries.
* Clean up *PAGE* macros.Jason Evans2012-04-021-8/+5
| | | | | | | | | | | 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".
* Add the "thread.tcache.enabled" mallctl.Jason Evans2012-03-271-8/+28
|
* Port to FreeBSD.Jason Evans2012-02-031-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* Implement tsd.Jason Evans2012-03-231-18/+24
| | | | | | | | | | | | | 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.
* Rename the "tcache.flush" mallctl to "thread.tcache.flush".Jason Evans2012-03-171-6/+6
|
* Remove the lg_tcache_gc_sweep option.Jason Evans2012-03-051-4/+0
| | | | | | | 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.
* Remove the sysv option.Jason Evans2012-02-291-6/+0
|
* Simplify small size class infrastructure.Jason Evans2012-02-291-63/+6
| | | | | | | | | | | | 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.
* Remove the opt.lg_prof_bt_max option.Jason Evans2012-02-141-3/+0
| | | | | | | | 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.
* Remove the opt.lg_prof_tcmax option.Jason Evans2012-02-141-4/+1
| | | | | | | 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.
* Remove highruns statistics.Jason Evans2012-02-131-10/+0
|
* Make 8-byte tiny size class non-optional.Jason Evans2012-02-131-7/+2
| | | | | | | | | | | When tiny size class support was first added, it was intended to support truly tiny size classes (even 2 bytes). However, this wasn't very useful in practice, so the minimum tiny size class has been limited to sizeof(void *) for a long time now. This is too small to be standards compliant, but other commonly used malloc implementations do not even bother using a 16-byte quantum on systems with vector units (SSE2+, AltiVEC, etc.). As such, it is safe in practice to support an 8-byte tiny size class on 64-bit systems that support 16-byte types.
* Remove the swap feature.Jason Evans2012-02-131-110/+1
| | | | | Remove the swap feature, which enabled per application swap files. In practice this feature has not proven itself useful to users.
* Reduce cpp conditional logic complexity.Jason Evans2012-02-111-367/+231
| | | | | | | | | | | | | | | | | | | | | | 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.
* Move repo contents in jemalloc/ to top level.Jason Evans2011-04-011-0/+1670