about summary refs log tree commit diff
path: root/malloc/malloc.c
Commit message (Collapse)AuthorAgeFilesLines
* Consolidate arena_lookup and arena_lock into a single arena_getSiddhesh Poyarekar2015-02-181-2/+1
| | | | | | | | | | | | | | | | This seems to have been left behind as an artifact of some old changes and can now be merged. Verified that the only generated code change on x86_64 is that of line numbers in asserts, like so: @@ -27253,7 +27253,7 @@ Disassembly of section .text: 416f09: 48 89 42 20 mov %rax,0x20(%rdx) 416f0d: e9 7e f6 ff ff jmpq 416590 <_int_free+0x230> 416f12: b9 3f 9f 4a 00 mov $0x4a9f3f,%ecx - 416f17: ba d5 0f 00 00 mov $0xfd5,%edx + 416f17: ba d6 0f 00 00 mov $0xfd6,%edx 416f1c: be a8 9b 4a 00 mov $0x4a9ba8,%esi 416f21: bf 6a 9c 4a 00 mov $0x4a9c6a,%edi 416f26: e8 45 e8 ff ff callq 415770 <__malloc_assert>
* Use alignment macros, pagesize and powerof2.Carlos O'Donell2015-02-171-20/+22
| | | | | | | | | | | | | | We are replacing all of the bespoke alignment code with ALIGN_UP, ALIGN_DOWN, PTR_ALIGN_UP, and PTR_ALIGN_DOWN. This cleans up malloc/malloc.c, malloc/arena.c, and elf/dl-reloc.c. It also makes all the code consistently use pagesize, and powerof2 as required. Code size is reduced with the removal of precomputed pagemask, and use of pagesize instead. No measurable difference in performance. No regressions on x86_64.
* Update copyright dates with scripts/update-copyrights.Joseph Myers2015-01-021-1/+1
|
* Remove explicit inline on malloc perturb functions.Roland McGrath2014-12-171-2/+2
|
* 2014-12-11 Steve Ellcey <sellcey@imgtec.com>Steve Ellcey2014-12-111-1/+1
| | | | * malloc/malloc.c: Fix powerof2 check.
* Fix malloc_info namespace (bug 17570).Joseph Myers2014-11-121-1/+2
| | | | | | | | | | | | | malloc_info is defined in the same file as malloc and free, but is not an ISO C function, so should be a weak symbol. This patch makes it so. Tested for x86_64 (testsuite, and that disassembly of installed shared libraries is unchanged by the patch). [BZ #17570] * malloc/malloc.c (malloc_info): Rename to __malloc_info and define as weak alias of __malloc_info.
* malloc: additional unlink hardening for non-small bins [BZ #17344]Florian Weimer2014-09-111-2/+4
| | | | | | Turn two asserts into a conditional call to malloc_printerr. The memory locations are accessed later anyway, so the performance impact is minor.
* malloc: fix comment typoSean Anderson2014-08-121-1/+1
|
* malloc/malloc.c: Avoid calling sbrk unnecessarily with zeroWill Newton2014-06-191-0/+3
| | | | | | | | | | | | | Due to my bad review suggestion for the fix for BZ #15089 a check was removed from systrim to prevent sbrk being called with a zero argument. Add the check back to avoid this useless work. ChangeLog: 2014-06-19 Will Newton <will.newton@linaro.org> * malloc/malloc.c (systrim): If extra is zero then return early.
* Fix format specifier for n_mmapsSiddhesh Poyarekar2014-06-021-1/+1
|
* Fix formatting in malloc_infoSiddhesh Poyarekar2014-05-301-10/+10
|
* Add mmap usage in malloc_info outputSiddhesh Poyarekar2014-05-301-0/+2
| | | | | | The current malloc_info xml output only has information about allocations on the heap. Display information about number of mappings and total mmapped size to this to complete the picture.
* Remove mi_arena nested function.Ondřej Bílka2014-05-301-121/+117
|
* revert commit fdfd175d46ac6a810ebdeb2a2936e6d7d13995abOndřej Bílka2014-05-301-135/+125
|
* Remove nested function mi_arena from malloc_info.Carlos O'Donell2014-05-261-125/+135
| | | | | | | | | | The nested function mi_arena was removed from malloc_info and made into a non-nested static inline function of the same name with the correct set of arguments passed from malloc_info. This enables building glibc with compilers that don't support nested functions. Future work on malloc_info should remove these functions entirely to support JSON format output. Therefore we do the minimum required to remove the nested function.
* malloc: Fix MALLOC_DEBUG -Wundef warningWill Newton2014-04-111-1/+5
| | | | | | | | | | | | | | | MALLOC_DEBUG is set optionally on the command line. Default the value to zero if it is not set on the command line, and test its value with #if rather than #ifdef. Verified the code is identical before and after this change apart from line numbers. ChangeLog: 2014-04-11 Will Newton <will.newton@linaro.org> * malloc/malloc.c [!MALLOC_DEBUG]: #define MALLOC_DEBUG to zero if it is not defined elsewhere. (mtrim): Test the value of MALLOC_DEBUG with #if rather than #ifdef.
* Revert 4248f0da6ff9e7dd63464cdecec2dec332dfc2f0.Carlos O'Donell2014-03-031-6/+109
| | | | | | | Objections were raised surrounding the calloc simplification and it is better to revert the patch, continue discussions and then submit a new patch for inclusion with all issues fully addressed.
* Simplify calloc implementation.Ondřej Bílka2014-02-261-109/+6
| | | | | | To make future improvements of allocator simpler we could for now calloc just call malloc and memset. With that we could omit a changes that would duplicate malloc changes anyway.
* Use glibc_likely instead __builtin_expect.Ondřej Bílka2014-02-101-7/+7
|
* Remove THREAD_STATS.Ondřej Bílka2014-02-101-40/+0
| | | | | A THREAD_STATS macro duplicates gathering information that could be obtained by systemtap probes instead.
* Reformat malloc to gnu style.Ondřej Bílka2014-01-021-2069/+2214
|
* Update copyright notices with scripts/update-copyrightsAllan McRae2014-01-011-1/+1
|
* Fix race in free() of fastbin chunk: BZ #15073Maxim Kuvyrkov2013-12-241-8/+12
| | | | | | | | | | | | Perform sanity check only if we have_lock. Due to lockless nature of fastbins we need to be careful derefencing pointers to fastbin entries (chunksize(old) in this case) in multithreaded environments. The fix is to add have_lock to the if-condition checks. The rest of the patch only makes code more readable. * malloc/malloc.c (_int_free): Perform sanity check only if we have_lock.
* Expand MALLOC_COPY and MALLOC_ZERO to memcpy and memset.Ondřej Bílka2013-12-101-18/+5
|
* Drop PER_THREAD conditionals from malloc.Ondřej Bílka2013-12-101-15/+0
|
* Simplify perturb_byte logic.Ondřej Bílka2013-12-091-21/+24
|
* Replace malloc force_reg by atomic_forced_read.Ondřej Bílka2013-12-091-15/+8
|
* Fix BZ #15089: malloc_trim always trim for large padding.Fernando J. V. da Silva2013-12-061-33/+35
|
* Make memset in calloc a tail call.Ondřej Bílka2013-11-281-2/+2
|
* Add missing #include for malloc/hooks.c code.Roland McGrath2013-11-211-2/+3
|
* Consolidate valloc/pvalloc code.Ondřej Bílka2013-11-201-109/+26
| | | | | To make malloc code more maintainable we make malloc and pvalloc share logic with memalign.
* Fix malloc_info statistic. Fixes bug 16112Ondřej Bílka2013-11-011-16/+4
|
* malloc: Fix for infinite loop in memalign/posix_memalign.Will Newton2013-10-301-0/+8
| | | | | | | | | | | | | | | | | | | A very large alignment argument passed to mealign/posix_memalign causes _int_memalign to enter an infinite loop. Limit the maximum alignment value to the maximum representable power of two to prevent this from happening. Changelog: 2013-10-30 Will Newton <will.newton@linaro.org> [BZ #16038] * malloc/hooks.c (memalign_check): Limit alignment to the maximum representable power of two. * malloc/malloc.c (__libc_memalign): Likewise. * malloc/tst-memalign.c (do_test): Add test for very large alignment values. * malloc/tst-posix_memalign.c (do_test): Likewise.
* Use atomic operations to track memory. Fixes bug 11087Ondřej Bílka2013-10-301-12/+11
|
* Remove assert in malloc statistic. Fixes bug 12486.Ondřej Bílka2013-10-181-9/+0
|
* Add malloc probes for sbrk and heap resizing.Alexandre Oliva2013-09-201-1/+5
| | | | | | | | | | | | for ChangeLog * malloc/arena.c (new_heap): New memory_heap_new probe. (grow_heap): New memory_heap_more probe. (shrink_heap): New memory_heap_less probe. (heap_trim): New memory_heap_free probe. * malloc/malloc.c (sysmalloc): New memory_sbrk_more probe. (systrim): New memory_sbrk_less probe. * manual/probes.texi: Document them.
* Add probes for malloc retries.Alexandre Oliva2013-09-201-0/+6
| | | | | | | | | | | | for ChangeLog * malloc/malloc.c (__libc_malloc): Add memory_malloc_retry probe. (__libc_realloc): Add memory_realloc_retry probe. (__libc_memalign): Add memory_memalign_retry probe. (__libc_valloc): Add memory_valloc_retry probe. (__libc_pvalloc): Add memory_pvalloc_retry probe. (__libc_calloc): Add memory_calloc_retry probe. * manual/probes.texi: Document them.
* Add probes for malloc arena changes.Alexandre Oliva2013-09-201-0/+1
| | | | | | | | | | | | | for ChangeLog * malloc/arena.c (get_free_list): Add probe memory_arena_reuse_free_list. (reused_arena) [PER_THREAD]: Add probes memory_arena_reuse_wait and memory_arena_reuse. (arena_get2) [!PER_THREAD]: Likewise. * malloc/malloc.c (__libc_realloc) [!PER_THREAD]: Add probe memory_arena_reuse_realloc. * manual/probes.texi: Document them.
* Add probes for all changes to malloc options.Alexandre Oliva2013-09-201-5/+25
| | | | | | | | | for ChangeLog * malloc/malloc.c (__libc_free): Add memory_mallopt_free_dyn_thresholds probe. (__libc_mallopt): Add multiple memory_mallopt probes. * manual/probes.texi: Document them.
* Add first set of memory probes.Alexandre Oliva2013-09-201-0/+4
| | | | | | | | | | | for ChangeLog * malloc/malloc.c: Include stap-probe.h. (__libc_mallopt): Add memory_mallopt probe. * malloc/arena.c (_int_new_arena): Add memory_arena_new probe. * manual/probes.texi: New. * manual/Makefile (chapters): Add probes. * manual/threads.texi: Set next node.
* malloc: Check for integer overflow in memalign.Will Newton2013-09-111-0/+7
| | | | | | | | | | | | | | A large bytes parameter to memalign could cause an integer overflow and corrupt allocator internals. Check the overflow does not occur before continuing with the allocation. ChangeLog: 2013-09-11 Will Newton <will.newton@linaro.org> [BZ #15857] * malloc/malloc.c (__libc_memalign): Check the value of bytes does not overflow.
* malloc: Check for integer overflow in valloc.Will Newton2013-09-111-0/+7
| | | | | | | | | | | | | | A large bytes parameter to valloc could cause an integer overflow and corrupt allocator internals. Check the overflow does not occur before continuing with the allocation. ChangeLog: 2013-09-11 Will Newton <will.newton@linaro.org> [BZ #15856] * malloc/malloc.c (__libc_valloc): Check the value of bytes does not overflow.
* malloc: Check for integer overflow in pvalloc.Will Newton2013-09-111-0/+7
| | | | | | | | | | | | | | A large bytes parameter to pvalloc could cause an integer overflow and corrupt allocator internals. Check the overflow does not occur before continuing with the allocation. ChangeLog: 2013-09-11 Will Newton <will.newton@linaro.org> [BZ #15855] * malloc/malloc.c (__libc_pvalloc): Check the value of bytes does not overflow.
* Fix typos.Ondřej Bílka2013-08-291-1/+1
|
* Use (void) in no-arguments function definitions.Joseph Myers2013-06-081-1/+1
|
* Remove __malloc_ptr_t.Joseph Myers2013-03-081-19/+19
|
* Add HAVE_MREMAP for mremap usagePino Toscano2013-01-171-8/+4
| | | | | | | | | Introduce (only on Linux) and use a HAVE_MREMAP symbol to advertize mremap availability. Move the malloc-sysdep.h include from arena.c to malloc.c, since what is provided by malloc-sysdep.h is needed earlier in malloc.c, before the inclusion of arena.c.
* Clean up __MALLOC_* macros.Joseph Myers2013-01-071-15/+11
|
* Update copyright notices with scripts/update-copyrights.Joseph Myers2013-01-021-1/+1
|
* Name space hygeine for madvise.Roland McGrath2012-10-041-1/+1
|