Commit Graph

1230 Commits

Author SHA1 Message Date
Matthew Parkinson
32495fd42d Multiple Pals could return spuriously from wake on address (#739)
* Add stress test benchmark

Co-authored-by: Alexander Nadeau <wareya@gmail.com>

* Add defensive code against spurious wakeup

This commit checks that wait_on_address has not returned spuriously.

* pal: spurious wake up.

The code in the Pal for wake on address was incorrectly assuming the operation returning success meant it had actually changed.  The specification allows for spurious wake ups.

This change makes the Pals recheck for a change.

---------

Co-authored-by: Alexander Nadeau <wareya@gmail.com>
2025-02-04 18:44:02 +00:00
Matthew Parkinson
e3e558472d Update CMakeLists.txt (#734)
* Handle platforms that have `_GLIBCXX_ASSERTIONS`, which require the stdlib++ to be included.
* Stop override of memcpy with FORTIFY_SOURCE enabled
* Add to .gitignore
* Add data for graphs in release notes.
* Minor tidy on CMake.
2025-01-23 13:36:08 +00:00
Jean-Michaël Celerier
aa07749f46 pal_windows.h: missing <cerrno> for ENOMEM on MinGW (#733)
Co-authored-by: Matthew Parkinson <mjp41@users.noreply.github.com>
2025-01-21 09:25:11 +00:00
Schrodinger ZHU Yifan
229c6d04fe remove extra puts definitions (#731)
LGTM, thanks.
2025-01-16 10:31:31 +00:00
Matthew Parkinson
0fbc325a0a Fix merge issue for out of data CI run. (#730) 2025-01-10 08:37:33 +00:00
Matthew Parkinson
9e632047de Add Windows Support for Lazy Commit of page map (#727)
The Pagemap can potentially be accessed where there is no direct
knowledge of the location.  On platforms with lazy commit this can
be handled by the OS faulting in a zero page.  Here we modify the
Windows PAL to add an exception handler that will commit pages
in the read only range, i.e. the page map.  We still require explicit
notify_using to be able to modify the pagemap.
2025-01-09 17:57:52 +00:00
Schrodinger ZHU Yifan
0111a410a2 [proxy](7/n) self vendor array and algorithm headers (#722)
* [proxy](7/n) proxy array and algorithm headers

* [wip] address CRs

* undo comment

* format

* fix build

* simplify macro dispatching
2025-01-09 13:49:22 +00:00
Schrodinger ZHU Yifan
0027f02396 [proxy](6/n) self-vendor utility headers (#721) 2025-01-09 10:25:35 +00:00
Schrodinger ZHU Yifan
e874617d8e [proxy](5/n) use c headers instead of c++ headers (#720) 2025-01-09 09:45:24 +00:00
Neil Monday
6a3c5750bd Changing DEBUG constexpr to Debug to avoid collision with any #define DEBUG that may exist in other projects. (#729)
Co-authored-by: Neil Monday <neil.monday@amd.com>
2025-01-08 17:13:26 +00:00
Schrodinger ZHU Yifan
d1c65c2852 [proxy](4/n) use customised placement-new (#719)
* [proxy](4/n) use customized placement-new

* fix
2025-01-08 06:38:23 +00:00
Matthew Parkinson
046c5ac766 Limit remote batch size (#724)
When processing a remote batch, the system will process every single message that was available at the start of processing.
This can lead to a long pause time if there have been a considerable number of frees to this thread.

This commit introduces a new mechanism to only process messages up to a limit of 1MiB. The limit is configurable using CMake.

Choosing too small a limit can cause freeing to never catch up with the incoming messages.
2025-01-07 14:29:34 +00:00
Matthew Parkinson
35c5c6038c Remove dependencies from Singleton and FlagLock (#725)
* Move get_tid() to ds_core.

* Rewrite Singleton to only use Aal.

* Move data structure to be usable from the Pal.
2025-01-07 14:28:57 +00:00
Schrodinger ZHU Yifan
8c6474d05a [proxy](3/n) remove chrono dependency for windows (#718)
* [proxy](3/n) remove chrono dependency for windows

* minor fixes
2025-01-07 13:40:57 +00:00
Schrodinger ZHU Yifan
2cc74eac10 [proxy](2/n) provide proxy layers for type traits (#717)
* [proxy](2/n) provide proxy layers for type traits

* fix after rebasing
2025-01-06 17:07:49 +00:00
Matthew Parkinson
7db1f243cc CI issues (#726)
* Remove unneeded workaround.

* Update Clang version in cross compile for latest

* Explicitly install libc++ in CI
2025-01-06 08:53:28 +00:00
Schrodinger ZHU Yifan
feff2e8151 [proxy](1/n) start self-vendored STL with atomic (#715)
* [proxy] start self-vendored STL

* address CR
2025-01-03 07:49:32 +00:00
David CARLIER
fb29a5e085 PALSolaris AlignedAllocation feature implementation attempt. (#723) 2025-01-02 14:11:58 +00:00
David CARLIER
515b97d996 PALOpenBSD implement WaitOnAddress feature attempt. (#716) 2025-01-02 09:07:46 +00:00
Schrodinger ZHU Yifan
141cdd9361 [ds_core] simplify MessageBuilder construction (#713)
* [ds_core] simplify MessageBuilder construction

* remove special handling of zero case

* select latest xcode
2024-12-18 15:18:04 +00:00
David CARLIER
6952683692 memcpy test fix build warning on openbsd. (#714)
* memcpy test fix build warning on openbsd.

* enabling TEST_LIMITED for openbsd too.
2024-12-18 12:42:26 +00:00
Neil Monday
57c88efccb The _msize function has a non-const void* parameter in the msvc CRT. (#708)
Co-authored-by: Neil Monday <neil.monday@amd.com>
2024-12-17 11:37:44 +00:00
Schrodinger ZHU Yifan
cbc3018e1a remove string_view STL dependency (#703)
* remove string_view STL dependency

* fix

* inline string literal handling directly

* simplify dispatch
2024-12-15 07:46:49 +00:00
Schrodinger ZHU Yifan
1250ee002f [ds_core] remove TrivialInitAtomic (#711) 2024-12-14 07:10:06 +00:00
Matthew Parkinson
d4405df368 Update README.md (#710)
No longer have a Morello CI, so the badge no longer makes sense.
2024-12-12 13:40:08 +00:00
Matthew Parkinson
f57e27de19 Fixes: Sets _HAS_EXCEPTIONS=0 globally #701 (#707)
This makes the `_HAS_EXCEPTIONS` flag on windows only apply to libraries, and not if the library is used header only.
2024-12-12 09:36:12 +00:00
Matthew Parkinson
35cda3d1fd CI updates (#706)
* Add a TRACING build to CI

* Update MacOS version
2024-12-11 19:13:17 +00:00
Neil Monday
eca2b93c02 Updating the build doc (#705)
Co-authored-by: Neil Monday <neil.monday@amd.com>
2024-12-11 18:35:26 +00:00
Jean-Michaël Celerier
d6ad197d3c cmake: look for rdynamic instead of hardcoding it (#699) 2024-12-01 07:45:23 +00:00
Matthew Parkinson
564c88b07c Update README.md (#698) 2024-11-28 13:53:08 +00:00
Matthew Parkinson
4efc0e7d02 Update README.md 2024-11-28 13:38:23 +00:00
Matthew Parkinson
4272126343 Releasedocs0 7 (#693)
Co-authored-by: Nathaniel Wesley Filardo <VP331RHQ115POU58JFRLKB7OPA0L18E3@cmx.ietfng.org>
2024-11-28 13:20:49 +00:00
Schrodinger ZHU Yifan
cd91793def avoid chrono inclusion when clock_gettime is available (#695)
* avoid chrono inclusion when clock_gettime is available

* fix build
2024-11-26 21:04:45 +00:00
David CARLIER
33b7f656ab neasing netbsd build. (#696)
all 3rd party packages are located in /usr/pkg so we lessen the burden
to set these.
2024-11-25 08:29:09 +00:00
Matthew Parkinson
69e280c331 Minor update to clangformat file. (#694) 2024-11-22 12:40:16 +00:00
Schrodinger ZHU Yifan
45dbdb00af clean up Result and make Result move-only (#691) 2024-11-20 20:47:22 +00:00
David CARLIER
fd560d472b Revert "custom memmove implementation proposal. (#593)" (#692)
* Revert "custom memmove implementation proposal. (#593)"

This reverts commit 01885f5a04.

* disable memmove fuzzing
2024-11-20 10:36:42 +00:00
Matthew Parkinson
e343232611 Add fuzz to CI (#690)
* Add fuzz to CI

* Change compiler to clang++

* Fix flag name

* Remove fuzzing from a requirement.

* Update to checkout v4
2024-11-19 14:28:55 +00:00
Schrodinger ZHU Yifan
0b53b9301e fuzzing test and detect the memmove error (#688)
* fuzzing

* add an additional random walk test
2024-11-19 13:48:18 +00:00
David CARLIER
01885f5a04 custom memmove implementation proposal. (#593)
mostly like memcpy with optional bound checking but
capable of handling overlapping cases thus using
reverse copy instead.
2024-11-16 07:39:38 +00:00
Schrodinger ZHU Yifan
f7fe702f77 implement polite waiting (#685)
* implement polite waiting

* Update src/snmalloc/pal/pal_linux.h

Co-authored-by: Matthew Parkinson <mjp41@users.noreply.github.com>

* fix build issues

* fix more build issues

* support _umtx_op for freebsd

* unify waiting style

* fix

* address CR

Co-authored-by: Matthew Parkinson <mjp41@users.noreply.github.com>

* support macos

* static dispatch os APIs for apple

* make wait_on_address configurable via cmake

* undo extra include

* fix macos build

* fix clang-tidy build

---------

Co-authored-by: Matthew Parkinson <mjp41@users.noreply.github.com>
2024-11-16 07:33:11 +00:00
Matthew Parkinson
fe3fed4414 Remove unneeded template. (#687) 2024-11-12 19:56:14 +00:00
David CARLIER
43ad730c29 PAL::haiku finally supports getentropy. (#684)
Also fixing the build with PAL::posix assuming the intent is
to avoid using std namespace for max but rather using the in-house
implementation.
2024-10-31 11:54:27 +00:00
Matthew Parkinson
97b7675670 Remove some unneeded headers (#680)
* Removed unneeded headers

This removes some unneeded headers from the headers.

* Remove use of std::string

This stack allocates and copies a c-string to replace the calls to std::string.
2024-10-06 09:14:56 +01:00
Matthew Parkinson
c77076983d Add documentation for the combining lock (#683)
This adds some documentation to make the combining lock easier to understand.
This is working towards documenting the changes for the 0.7 release.
2024-10-05 07:31:00 +01:00
David CARLIER
f1df3d43bb override malloc, aligned_alloc calling libc::aligned_alloc (#681) 2024-09-28 22:02:40 +01:00
Matthew Parkinson
ab4fe84804 Provide option to CMake for Page Size (#664)
* Pickup page size from unistd.h

This uses the PAGESIZE constant from the unistd.h on POSIX.
This should make the code more resilient to being compiled on platforms with
different page sizes.

* Allow pagesize to come from cmake.

* Update src/snmalloc/pal/pal_posix.h

Co-authored-by: Nathaniel Filardo <105816689+nwf-msr@users.noreply.github.com>

---------

Co-authored-by: Nathaniel Filardo <105816689+nwf-msr@users.noreply.github.com>
2024-09-25 11:27:31 +01:00
Nathaniel Wesley Filardo
fb776da909 WIP: BatchIt (#677)
* Rename dealloc_local_object_slower to _meta

Unlike its brethren, `dealloc_local_object` and
`dealloc_local_object_slow`, the `dealloc_local_object_slower` method
does not take a pointer to free space.  Make this slightly more apparent
by renaming it and adding some commentary to both definition and call
site.

* corealloc: get meta in dealloc_local_object

Make both _fast() and _slow() arms take the meta as an argument; _meta()
already did.

* Introduce RemoteMessage structure

Plumb its use around remoteallocator and remotecache

* NFC: Plumb metadata to remotecache dealloc

* Initial steps in batched remote messages

This prepares the recipient to process a batched message.

* Initial dealloc-side batching machinery

Exercise recipient machinery by having the senders collect adjacent frees to
the same slab into a batch.

* Match free batch keying to slab freelist keying

* freelist: add append_segment

* SlabMetadata: machinery for returning multiple objects

This might involve multiple (I think at most two, at the moment) transitions in
the slab lifecycle state machine.  Towards that end, return indicators to the
caller that the slow path must be taken and how many objects of the original
set have not yet been counted as returned.

* corealloc: operate ring-at-a-time on remote queues

* RemoteCache associative cache of rings

* RemoteCache: N-set caching

* Initial CHERI support for free rings

* Matt's fix for slow-path codegen

* Try: remotecache: don't store allocator IDs

We can, as Matt so kindly reminds me, go get them from the pagemap.  Since we
need this value only when closing a ring, the read from over there is probably
not very onerous.  (We could also get the slab pointer from an object in the
ring, but we need that whenever inserting into the cache, so it's probably more
sensible to store that locally?)

* Make BatchIt optional

Move ring set bits and associativity knobs to allocconfig and expose them via
CMake.  If associtivity is zero, use non-batched implementations of the
`RemoteMessage` and `RemoteDeallocCacheBatching` classes.

By default, kick BatchIt on when we have enough room in the minimum allocation
size to do it.  Exactly how much space is enough is a function of which
mitigations we have enabled and whether or not we are compiling with C++20.

This commit reverts the change to `MIN_ALLOC_SIZE` made in "Introduce
RemoteMessage structure" now that we have multiple types, and zies, of
remote messages to choose from.

* RemoteDeallocCacheBatching: store metas as address

There's no need for a full pointer here, it'd just make the structure larger on
CHERI.

* NFC: plumb entropy from LocalAlloc to BatchIt

* BatchIt random eviction

In order not to thwart `mitigations(random_preserve)` too much, if it's on in
combination with BatchIt, roll the dice every time we append to a batch to
decide if we should stochastically evict this batch.  By increasing the number
of batches, we allow the recipient allocator increased opportunity to randomly
stripe batches across the two `freelist::Builder` segments associated with each
slab.

---------

Co-authored-by: Nathaniel Wesley Filardo <nfilardo@microsoft.com>
Co-authored-by: Matthew Parkinson <mattpark@microsoft.com>
2024-09-23 19:18:09 +01:00
Nathaniel Wesley Filardo
416fd39f6a gcc UAF warning in test/perf/singlethread -malloc
When building test/perf/singlethread to use the system allocator, gcc
(Debian 14.2.0-3) correctly sees that we were using the value of a
pointer after it had been passed to the privileged free(), which is UB.

Flip the check and dealloc, so that we query the set of pointers we're
tracking first, using the pointer while the allocation is still live.
2024-09-21 14:48:04 +00:00
Nathaniel Wesley Filardo
19259095c6 Further gcc -Werror=array-bounds fix
In test/perf/startup, gcc (Debian 14.2.0-3) seems to get confused about
the size of the counters vector as the code was written.  Rewrite the
code to pass the same value (`std::thread::hardware_concurrency()`, but
in a local) to both `counters.resize()` and the `ParallelTest` ctor.
2024-09-21 10:32:28 +00:00