summaryrefslogtreecommitdiff
path: root/linker/linker_block_allocator.cpp
AgeCommit message (Collapse)Author
2020-06-10linker: CHECK() or async_safe_fatal() rather than abort().Elliott Hughes
In particular, add the strerror() output if mprotect() fails. Fix the CHECK macro so that you can make assertions involving operator% without that being confused for a printf format specifier. Bug: https://issuetracker.google.com/158645318 Test: treehugger Change-Id: I6817f8ca5f094c52dc2c9067bfac90385a8743f5
2019-03-12Cosmetic changes to linker allocator and configRyan Prichard
Make the num_free_blocks calculation clearer. There are sizeof(page->bytes) bytes available for blocks, which is equal to (kAllocateSize - 16). The previous calculation overestimates the amount of space by 8 or 12 bytes, but that doesn't change the result because both kAllocateSize and block_size_ are multiples of 16. Bug: none Test: boot device, bionic unit tests Change-Id: Ia880cd5abc2a7bb4e9e6a8c0441d985f4df8fdc4
2019-01-30Purge linker block allocators before leaving linkerVic Yang
This is the second attempt to purge linker block allocators. Unlike the previously reverted change which purge allocators whenever all objects are freed, we only purge right before control leaves the linker. This limits the performance impact to one munmap() call per dlopen(), in most cases. Bug: 112073665 Test: Boot and check memory usage with 'showmap'. Test: Run camear cold start performance test. Change-Id: I02c7c44935f768e065fbe7ff0389a84bd44713f0
2019-01-29Revert "linker: Purge block allocator memory when possible"Vic Yang
This reverts commit fb78a4ac1b93218f59aa44089ae5f4dbfababf0d. Reason for revert: Performance regression. Change-Id: Ib12335fc7478dad933da00b8bc525366c9330a17
2019-01-23linker: Reduce number of mmap()/prctl() calls in block allocatorVic Yang
Given that the block allocator does not free allocated memory unless all objects are freed, we can allocate a large chunk of memory at a time. This gives us: 1. Higher space efficiency, especially when the objects being allocated has a large size. 2. Much less mmap()/prctl() calls. 3. Much less vm_area_struct objects. While this increases the size of virtual memory allocated, the number of dirty pages would be unchanged or less. Test result on a Go device: - Zygote starts 24ms faster on average. - Kernel vm_area_struct usage 138KB less, across the entire system. Bug: 112073665 Test: Boot and check the result from 'showmap'. Change-Id: Iece631a5081151dd1e5bf25dbddac9b264bcdcff
2019-01-23linker: Purge block allocator memory when possibleVic Yang
If all allocated memory from a block allocator is freed, it is a good opportunity to purge all the pages allocated to reduce lingering dirty pages. Memory saving varies with the platform and what processes are running. Measuring right after boot, this saves ~1.8MB on cuttelfish and ~1.3MB on a 32-bit ARM device. Bug: 112073665 Test: Boot and check memory usage with 'showmap'. Change-Id: I53769e0ec9699f0b3645cdf281a2c0bbffb98676
2018-08-22Add PR_SET_VMA and PR_SET_VMA_ANON_NAME to <sys/prctl.h>.Elliott Hughes
We've copied & pasted these to too many places. And if we're going to have another go at upstreaming these, that's probably yet another reason to have the *values* in just one place. (Even if upstream wants different names, we'll likely keep the legacy names around for a while for source compatibility.) Bug: http://b/111903542 Test: ran tests Change-Id: I8ccc557453d69530e5b74f865cbe0b458c84e3ba
2017-09-15Always log errno when aborting.Elliott Hughes
(Where errno is relevant.) Also consistently use -1 as the fd for anonymous mmaps. (It doesn't matter, but it's more common, and potentially more intention-revealing.) Bug: http://b/65608572 Test: ran tests Change-Id: Ie9a207632d8242f42086ba3ca862519014c3c102
2017-02-15Unify linker files under one license (BSD)Dimitry Ivanov
Historically we had part of the linker licensed under BSD and another part under Apache 2 license. This commit makes all the linker code licensed under BSD license. Test: m Change-Id: I11b8163ae75966b5768d3fe992679de376106515
2017-02-09Remove unnecessary memsets in linker allocatorsDimitry Ivanov
Test: linker-unit-tests Test: bionic-unit-tests --gtest_filter=dl*:Dl* Change-Id: I96f983dba77c9cb5698a9eb2e51b33bc128c6dd7
2016-01-21linker: align allocated blocks to 16 bytesDimitry Ivanov
C/C++ requires the result of malloc/new to be aligned for any primitive type. Change-Id: I715b7679e738f34b3b409993fb3ef242e1321b7f
2015-03-10Rename LinkerAllocator and LinkerAllocatorPageDmitriy Ivanov
Change-Id: I87d80fbcd4ec26c0ee4f601b9c4c64f600418dd9
2015-03-10Refactoring: rename linker_allocator filesDmitriy Ivanov
Change-Id: Ifc08e64b3a85205f072b7abab1149c7ab71e2f75