base_chunk_dealloc transitively re-enters BaseAlloc::alloc via chunk_record's
extent_node_t allocation. Since Mutex is non-recursive (Linux pthread adaptive,
macOS os_unfair_lock), this self-deadlocks on Linux and traps with SIGILL on
macOS. Capture the chunk under the lock and dealloc after dropping it; the
alloc path already takes the symmetric precaution via base_chunk_alloc.
Differential Revision: https://phabricator.services.mozilla.com/D299319
Introduce base_chunk_alloc and arena_chunk_alloc for base/arena chunk
allocations respectively. base_chunk_alloc skips the chunk recycling and
gChunkRTree insertion code paths as before.
Split up chunk deallocation into arena_chunk_dealloc and base_chunk_dealloc.
base_chunk_dealloc is used for both base chunks and arena chunks that have been
removed from gChunkRTree.
Differential Revision: https://phabricator.services.mozilla.com/D292238
Introduce base_chunk_alloc and arena_chunk_alloc for base/arena chunk
allocations respectively. base_chunk_alloc skips the chunk recycling and
gChunkRTree insertion code paths as before.
Split up chunk deallocation into arena_chunk_dealloc and base_chunk_dealloc.
base_chunk_dealloc is used for both base chunks and arena chunks that have been
removed from gChunkRTree.
Differential Revision: https://phabricator.services.mozilla.com/D292238
When freeing cells, if the cell has no neighbours after merging then it
is an entire chunk. Release the whole chunk to the OS.
Differential Revision: https://phabricator.services.mozilla.com/D287069
When cells are freed they are merged with their free neighbours, unless
those neighbours are decommitted which can lead to fragmentation.
Merging these cells during free() would mean committing one or
decommitting the other. Instead if an allocation can't be satisfied by
the normal or oversize free lists, process the decommited free list (a
tree) to commit then merge small decommitted cells with their neighbours
until a cell large enough to satisfy the allocation is made available.
This solves a test failure on Windows.
Differential Revision: https://phabricator.services.mozilla.com/D287068
When decommitting memory split cells of the beginning and end of the
decommitted region so that the maximum amount of committed memory is
available.
Differential Revision: https://phabricator.services.mozilla.com/D270990
Instead when BaseAlloc needs more memory from the system it converts a
whole chunk into a cell then splits it. This will make it easier to
release whole chunks later without needing to manage "wilderness".
This has the side-effect of always keeping all memory committed. A
later patch will add the ability to decommit memory.
Differential Revision: https://phabricator.services.mozilla.com/D270988
+ The internal allocation functions now return BaseAllocCell pointers.
* The alloc size checks and allocation state are now done in one
place, when alloc_cell() returns control to alloc().
+ The old wilderness_alloc function is removed and
wilderness_alloc_inplace is renamed to wilderness_alloc
+ Add log messages to alloc and free functions.
Differential Revision: https://phabricator.services.mozilla.com/D270987
Introduce a "quantum" cell size so that free lists only ever contain
objects of the same size which improves cell reuse.
Differential Revision: https://phabricator.services.mozilla.com/D268991
The next patch will need to access some of these structures from
BaseAlloc.h, rather than adding them there and making the interface less
obvious, create a new header.
Differential Revision: https://phabricator.services.mozilla.com/D268989
This reverts commit cf54ef3dc5.
Revert "Bug 1976184 - pt 21. Try to satisfy an allocation by merging decommitted cells r=glandium"
This reverts commit 0b7c5bbd1d.
Revert "Bug 1976184 - pt 20. Add internal validation to BaseAlloc r=sergesanspaille"
This reverts commit ab036c4f66.
Revert "Bug 1976184 - pt 19. Make more memory around decommitted memory usable r=glandium"
This reverts commit c5b9d10995.
Revert "Bug 1976184 - pt 18. Decommit remainder of new chunks in BaseAlloc r=glandium"
This reverts commit 052329bd73.
Revert "Bug 1976184 - pt 17. Implement BaseAlloc::realloc r=glandium"
This reverts commit 519a7c6a97.
Revert "Bug 1976184 - pt 16. Remove wilderness allocation from BaseAlloc r=glandium"
This reverts commit 0941744917.
Revert "Bug 1976184 - pt 15. Refactor alloc path r=glandium"
This reverts commit e6ce068881.
Revert "Bug 1976184 - pt 14. Add logging to the BaseAllocator r=glandium"
This reverts commit 0378eddc45.
Revert "Bug 1976184 - pt 13. Support cell splitting r=glandium"
This reverts commit b8db220858.
Revert "Bug 1976184 - pt 12. Support cell merging r=glandium"
This reverts commit 18e891f9de.
Revert "Bug 1976184 - pt 11. Add the previous cells size to the metadata r=glandium"
This reverts commit 44abe2e601.
Revert "Bug 1976184 - pt 10. Make the size to free list mapping more efficient r=glandium"
This reverts commit b7acd4f76a.
Revert "Bug 1976184 - pt 9. Improve free list organisation r=glandium"
This reverts commit bef5da84f5.
Revert "Bug 1976184 - pt 8. Use a RB tree for the oversize free list r=glandium"
This reverts commit ca4532ff0e.
Revert "Bug 1976184 - pt 7. Move some BaseAlloc structures to a new header r=glandium"
This reverts commit f193759d4d.
Revert "Bug 1976184 - pt 6. Refactor RedBlackTree::Search r=glandium"
This reverts commit 790777fb8d.
Revert "Bug 1976184 - pt 5. Add an allocated bit r=glandium"
This reverts commit 440d0b6667.
Revert "Bug 1976184 - pt 4. Add a test case for the base allocator r=glandium"
This reverts commit 10a579aedf.
Revert "Bug 1976184 - pt 3. Add a usable_size() function r=glandium"
This reverts commit fc1e6c1372.
Revert "Bug 1976184 - pt 2. Remove the type based free list r=glandium"
This reverts commit 2d3867161e.
Revert "Bug 1976184 - pt 1. Add free list allocation to the base allocator r=glandium"
This reverts commit 53cda19c58.
When freeing cells, if the cell has no neighbours after merging then it
is an entire chunk. Release the whole chunk to the OS.
Differential Revision: https://phabricator.services.mozilla.com/D287069
When cells are freed they are merged with their free neighbours, unless
those neighbours are decommitted which can lead to fragmentation.
Merging these cells during free() would mean committing one or
decommitting the other. Instead if an allocation can't be satisfied by
the normal or oversize free lists, process the decommited free list (a
tree) to commit then merge small decommitted cells with their neighbours
until a cell large enough to satisfy the allocation is made available.
This solves a test failure on Windows.
Differential Revision: https://phabricator.services.mozilla.com/D287068
When decommitting memory split cells of the beginning and end of the
decommitted region so that the maximum amount of committed memory is
available.
Differential Revision: https://phabricator.services.mozilla.com/D270990
Instead when BaseAlloc needs more memory from the system it converts a
whole chunk into a cell then splits it. This will make it easier to
release whole chunks later without needing to manage "wilderness".
This has the side-effect of always keeping all memory committed. A
later patch will add the ability to decommit memory.
Differential Revision: https://phabricator.services.mozilla.com/D270988
+ The internal allocation functions now return BaseAllocCell pointers.
* The alloc size checks and allocation state are now done in one
place, when alloc_cell() returns control to alloc().
+ The old wilderness_alloc function is removed and
wilderness_alloc_inplace is renamed to wilderness_alloc
+ Add log messages to alloc and free functions.
Differential Revision: https://phabricator.services.mozilla.com/D270987
Introduce a "quantum" cell size so that free lists only ever contain
objects of the same size which improves cell reuse.
Differential Revision: https://phabricator.services.mozilla.com/D268991
The next patch will need to access some of these structures from
BaseAlloc.h, rather than adding them there and making the interface less
obvious, create a new header.
Differential Revision: https://phabricator.services.mozilla.com/D268989
This reverts commit a8cc298882.
Revert "Bug 1976184 - pt 21. Try to satisfy an allocation by merging decommitted cells r=glandium"
This reverts commit 10498cc042.
Revert "Bug 1976184 - pt 20. Add internal validation to BaseAlloc r=sergesanspaille"
This reverts commit 2cb726424d.
Revert "Bug 1976184 - pt 19. Make more memory around decommitted memory usable r=glandium"
This reverts commit 7fa3a3781f.
Revert "Bug 1976184 - pt 18. Decommit remainder of new chunks in BaseAlloc r=glandium"
This reverts commit 8b9666721b.
Revert "Bug 1976184 - pt 17. Implement BaseAlloc::realloc r=glandium"
This reverts commit 698f760cfa.
Revert "Bug 1976184 - pt 16. Remove wilderness allocation from BaseAlloc r=glandium"
This reverts commit dd68acf2ee.
Revert "Bug 1976184 - pt 15. Refactor alloc path r=glandium"
This reverts commit 552670ac4b.
Revert "Bug 1976184 - pt 14. Add logging to the BaseAllocator r=glandium"
This reverts commit 447fc0e66e.
Revert "Bug 1976184 - pt 13. Support cell splitting r=glandium"
This reverts commit 92cc0dd6ad.
Revert "Bug 1976184 - pt 12. Support cell merging r=glandium"
This reverts commit 89c64d1ec2.
Revert "Bug 1976184 - pt 11. Add the previous cells size to the metadata r=glandium"
This reverts commit d5c17f0234.
Revert "Bug 1976184 - pt 10. Make the size to free list mapping more efficient r=glandium"
This reverts commit f120dda336.
Revert "Bug 1976184 - pt 9. Improve free list organisation r=glandium"
This reverts commit 891183bd4f.
Revert "Bug 1976184 - pt 8. Use a RB tree for the oversize free list r=glandium"
This reverts commit bd7857f56e.
Revert "Bug 1976184 - pt 7. Move some BaseAlloc structures to a new header r=glandium"
This reverts commit 0933ec0ea4.
Revert "Bug 1976184 - pt 6. Refactor RedBlackTree::Search r=glandium"
This reverts commit 60ce51a113.
Revert "Bug 1976184 - pt 5. Add an allocated bit r=glandium"
This reverts commit 34f1ceb178.
Revert "Bug 1976184 - pt 4. Add a test case for the base allocator r=glandium"
This reverts commit d5c2faca9f.
Revert "Bug 1976184 - pt 3. Add a usable_size() function r=glandium"
This reverts commit bb06068462.
Revert "Bug 1976184 - pt 2. Remove the type based free list r=glandium"
This reverts commit e4c837ddf7.
Revert "Bug 1976184 - pt 1. Add free list allocation to the base allocator r=glandium"
This reverts commit 5ae2c9e2c8.
When freeing cells, if the cell has no neighbours after merging then it
is an entire chunk. Release the whole chunk to the OS.
Differential Revision: https://phabricator.services.mozilla.com/D287069
When cells are freed they are merged with their free neighbours, unless
those neighbours are decommitted which can lead to fragmentation.
Merging these cells during free() would mean committing one or
decommitting the other. Instead if an allocation can't be satisfied by
the normal or oversize free lists, process the decommited free list (a
tree) to commit then merge small decommitted cells with their neighbours
until a cell large enough to satisfy the allocation is made available.
This solves a test failure on Windows.
Differential Revision: https://phabricator.services.mozilla.com/D287068
When decommitting memory split cells of the beginning and end of the
decommitted region so that the maximum amount of committed memory is
available.
Differential Revision: https://phabricator.services.mozilla.com/D270990