Commit Graph

416 Commits

Author SHA1 Message Date
Nathaniel Filardo
4dd77d35ab largealloc: rephrase pointer comparison 2019-11-26 15:50:22 +00:00
Nathaniel Filardo
f7c131e4ac largealloc: use pointer, not address_t, for cursor 2019-11-26 15:50:22 +00:00
Nathaniel Filardo
83c467eb92 ds/address: add pointer diff function
And use it rather than open-coding subtraction of two address_cast-s.
2019-11-26 15:50:22 +00:00
Nathaniel Filardo
eb2d8890de Additional provenance preservation 2019-11-26 15:37:52 +00:00
Nathaniel Filardo
ef7985510c address.h: add pointer alignment functions
More explicit than address_cast and bitwise and
2019-11-26 15:37:52 +00:00
Nathaniel Filardo
20e804728b Move bits::is_aligned_block to address.h
And chase consequences
2019-11-26 15:33:09 +00:00
Nathaniel Filardo
261249d9cb Preserve provenance through pointer offsetting 2019-11-26 14:59:54 +00:00
Nathaniel Filardo
00268fc2ad -Wundef 2019-11-26 14:59:54 +00:00
Nathaniel Filardo
9cdac05e4d portability: platform compiler flags
-mcx16 and -march=native are platform specific.  Leave them out if we
aren't targeting chips that need it.
2019-11-26 14:59:54 +00:00
Nathaniel Filardo
ad96ba05c1 largealloc: don't zero memory twice
If the decommit strategy is DecommitSuperLazy, then both the constexpr
if and the ordinary if would fire; add an else so we only fall into one.
2019-11-26 14:59:54 +00:00
Nathaniel Filardo
6f8623b5d7 Remove spurious store to pagemap
The same operation was just done one the other side of the loop above
and the loop does not modify this location in the map.
2019-11-26 14:59:54 +00:00
Nathaniel Filardo
2af4c64698 Improve commentary 2019-11-26 14:58:47 +00:00
Nathaniel Filardo
7251022e24 superslab: reorder initialization
Setting kind and then immediately testing it seems wrong.
2019-11-26 14:58:08 +00:00
Nathaniel Filardo
cbeeba004b test/externalpointer: ifdef NDEBUG, not if
Reported by Alex Richardson
2019-11-26 14:58:08 +00:00
Nathaniel Filardo
10475f3432 Set linker-language C; prevents linking c++ stdlib
Thanks to Alex Richardson for the suggestion
2019-11-26 14:58:08 +00:00
Nathaniel Filardo
528215e45e clangformat 8 2019-11-26 14:58:08 +00:00
Matthew Parkinson
11923154e8 Merge pull request #100 from CTSRD-CHERI/for-upstream-static-pagemap-slabmap
Deconflate "pagemap"
2019-11-25 16:26:55 +00:00
Nathaniel Filardo
e870960655 Some minor chunkmap commentary 2019-11-25 15:22:53 +00:00
Nathaniel Filardo
7ed80e7244 Report error on pagemap ABI mismatch 2019-11-25 15:22:53 +00:00
Nathaniel Filardo
d5b478ecb3 Deconflate "Pagemap" objects
There are two things calling themselves pagemaps:

- the src/mem/pagemap.h objects of that name

- the SuperslabMap object gets called a PageMap inside the Allocator

Rename the latter to chunkmap, with appropriate case and snake,
everywhere, and pull it out to its own file (chunkmap.h).

The default implementation of a chunkmap is a purely static object, but
we nevertheless instantiate it per allocator, so that other
implementations can use stateful instances when interposing on the
mutation methods.  Note that the "get" method, however, must remain
static to support the interface required by Allocator objects.
2019-11-21 15:35:56 +00:00
Matthew Parkinson
7faefbbb0e Merge pull request #102 from microsoft/cq-free
Code quality for `free`
2019-11-21 12:13:06 +00:00
Matthew Parkinson
1d0c42449e CR feedback 2019-11-21 11:39:55 +00:00
Matthew Parkinson
3f9e63209d Make CI show clangformat failures. 2019-11-21 11:39:55 +00:00
Matthew Parkinson
df1dfa55db improved comments and rename field
Replaced used with needed, the number of objects needed empty this slab.

Some mild improvement to the comments.
2019-11-21 11:39:55 +00:00
Matthew Parkinson
efd5228da6 Store a full pointer in the Metaslab
This improves the codegen.
2019-11-21 11:39:55 +00:00
Matthew Parkinson
cb4b8fa545 Changes the representation in Metaslab Used
Used is now set to 1, when the slab is full.  This means that the test
for
 used - 1 == 0
can be used to detect leaving full, and entering empty, reducing fast
path deallocation branchs by 1.
2019-11-19 16:25:27 +00:00
David Chisnall
093b3cc650 Make the get_reference() method on ThreadAlloc public.
This is required so that we can replace the thread allocator during
setup for the library compartmentalisation case.
2019-11-18 14:44:30 +00:00
David Chisnall
31941eac06 Add explicit qualification.
Calling a superclass method requires explicit qualification when the
superclass is a templated class.
2019-11-18 13:16:51 +00:00
Matthew Parkinson
b889f11d04 Merge pull request #99 from CTSRD-CHERI/for-upstream-stats-underflow
Fix stats underflow
2019-11-15 10:10:06 +00:00
Nathaniel Filardo
3b2f521c46 allocstats: assert count doesn't go negative 2019-11-14 22:59:02 +00:00
Nathaniel Filardo
574700318e debug_is_empty: don't dealloc() free space
We know that these are small objects and that they have already had
their cache friendly offsets applied, so jump in to the dealloc path
futher down, below the stats calls.

Split small_dealloc_offseted into a wrapper around the core to avoid
inlining too much into the debug function.

While here, move the handling of the Remote objects into its own block
so that `p` is out of scope thereafter.

Fixes https://github.com/microsoft/snmalloc/issues/98
2019-11-14 22:59:02 +00:00
Matthew Parkinson
97c87f2e91 Merge pull request #96 from microsoft/usemalloc_fix
Modified pass through
2019-11-14 14:48:58 +00:00
Matthew Parkinson
8853ee701e Merge pull request #97 from microsoft/memory_leak
Memory leak
2019-11-14 14:48:11 +00:00
Matthew Parkinson
7a3f0eb50b Clang format 2019-11-14 14:23:56 +00:00
Matthew Parkinson
4046417f25 Fix cache friendly offset. 2019-11-14 14:02:50 +00:00
Matthew Parkinson
74cc475787 Code review feedback. 2019-11-14 13:34:57 +00:00
Matthew Parkinson
14383614e0 Clang tidy 2019-11-14 13:04:24 +00:00
Matthew Parkinson
c2799f6ec8 Make debug_check_empty not use statistics
Debug_check_empty now empties the free lists, and checks it empties all the
queues in the allocator.  This does not require statistic tracking to
work anymore.

This additionally can check internal regression that cause leaks that
are not the clients fault.
2019-11-14 12:55:23 +00:00
Matthew Parkinson
23b4230f6a Fixed leak in free list.
If the first call to alloc uses the minimum size class, then we end up
leaking a whole page of allocations. We fill the small_fast_free_list,
in a call to build the message_queue. But this means the
small_fast_free_list[0] is not empty.  But the code was staying on the
slow path, and overwriting it.
2019-11-14 12:50:53 +00:00
Matthew Parkinson
3d0ba82b8d Modified pass through
If we are using USE_MALLOC pass through, then ThreadAlloc::get() can
cause an allocation inside snmalloc still, as it builds the thread
local allocator, which allocs a single stub allocator, using
the underlying allocator. This means that ASAN would detect a
leak in a client, even though the client program has none.

This change stops us ever allocating allocators, if we are passing
through calls to an underlying allocator.
2019-11-13 15:34:36 +00:00
Matthew Parkinson
d0a9633421 Merge pull request #95 from microsoft/minor
Typo in assertion.
2019-09-30 15:26:26 +01:00
Matthew Parkinson
f214abde3f Typo in assertion. 2019-09-30 13:43:32 +01:00
David Chisnall
fb9e1423e7 Merge pull request #94 from microsoft/revert_type_safety
Revert type safety
2019-09-12 17:29:46 -07:00
David Chisnall
6188667476 Revert the change to make the pool global type safe.
This adds lazy initialization, which adds a conditional branch on some
hot paths.

Fixes #93
2019-09-12 17:33:59 +01:00
David Chisnall
0b2b4d68a2 Revert "Add type confusion protection to the default memory provider."
This reverts commit d56201e28d.
2019-09-12 17:16:48 +01:00
Matthew Parkinson
dbea595b6e Merge pull request #92 from devnexen/pal_apple_anon_mon
darwin: override zero/non zeroed pages to tag them.
2019-08-27 14:43:42 +01:00
David Carlier
281a88d404 Templatize the Tag ID value 2019-08-27 13:10:50 +00:00
David Carlier
eed50baf8e Little tweaks 2019-08-27 10:42:57 +00:00
David Carlier
c881429e2e Using the macro instead 2019-08-27 10:20:16 +00:00
David Carlier
24ae5d704e darwin: override zero/non zeroed pages to tag them. 2019-08-26 18:57:45 +01:00