aboutsummaryrefslogtreecommitdiff
path: root/linker/linker_block_allocator.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Change default block size alignment to be 4 for memory saving on 32-bit archEric Miao2022-02-031-11/+8
| | | | | | | | | | | For a 32-bit userspace, `struct LinkedListEntry` takes 8 bytes for storing the two pointers, a default block allocator size alignment of 16-bytes would waste 50% of memory. By changing the alignment to size of a pointer, it saves >1MB memory postboot on wembley device. Bug: http://b/206889551 Test: bionic-unit-tests Change-Id: Ie92399c9bb3971f631396ee09bbbfd7eb17dc1a7
* linker: CHECK() or async_safe_fatal() rather than abort().Elliott Hughes2020-06-101-17/+9
| | | | | | | | | | | 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
* Cosmetic changes to linker allocator and configRyan Prichard2019-03-121-1/+1
| | | | | | | | | | | | 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
* Purge linker block allocators before leaving linkerVic Yang2019-01-301-1/+21
| | | | | | | | | | | | | 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
* Revert "linker: Purge block allocator memory when possible"Vic Yang2019-01-291-24/+1
| | | | | | | | This reverts commit fb78a4ac1b93218f59aa44089ae5f4dbfababf0d. Reason for revert: Performance regression. Change-Id: Ib12335fc7478dad933da00b8bc525366c9330a17
* linker: Reduce number of mmap()/prctl() calls in block allocatorVic Yang2019-01-231-8/+11
| | | | | | | | | | | | | | | | | | | | 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
* linker: Purge block allocator memory when possibleVic Yang2019-01-231-1/+24
| | | | | | | | | | | | | | 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
* Add PR_SET_VMA and PR_SET_VMA_ANON_NAME to <sys/prctl.h>.Elliott Hughes2018-08-221-2/+1
| | | | | | | | | | | | 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
* Always log errno when aborting.Elliott Hughes2017-09-151-1/+1
| | | | | | | | | | | (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
* Unify linker files under one license (BSD)Dimitry Ivanov2017-02-151-10/+22
| | | | | | | | | 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
* Remove unnecessary memsets in linker allocatorsDimitry Ivanov2017-02-091-2/+0
| | | | | | Test: linker-unit-tests Test: bionic-unit-tests --gtest_filter=dl*:Dl* Change-Id: I96f983dba77c9cb5698a9eb2e51b33bc128c6dd7
* linker: align allocated blocks to 16 bytesDimitry Ivanov2016-01-211-2/+11
| | | | | | | C/C++ requires the result of malloc/new to be aligned for any primitive type. Change-Id: I715b7679e738f34b3b409993fb3ef242e1321b7f
* Rename LinkerAllocator and LinkerAllocatorPageDmitriy Ivanov2015-03-101-10/+11
| | | | Change-Id: I87d80fbcd4ec26c0ee4f601b9c4c64f600418dd9
* Refactoring: rename linker_allocator filesDmitriy Ivanov2015-03-101-0/+134
Change-Id: Ifc08e64b3a85205f072b7abab1149c7ab71e2f75