summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitch Phillips <31459023+hctim@users.noreply.github.com>2021-05-13 01:25:12 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2021-05-13 01:25:12 +0000
commitd79b4bb5996dcffeb2401582530cf8ddfbd70cb0 (patch)
tree6adf2c969f3f544947f40a18067cddd520e183ef
parentee07b680b15bea333f9ab36cd73c5ff5b2da906a (diff)
parent6583baa3f259137a11d48eef7e7c88799bc8af82 (diff)
downloadscudo-d79b4bb5996dcffeb2401582530cf8ddfbd70cb0.tar.gz
[scudo] [GWP-ASan] Add GWP-ASan variant of scudo benchmarks. am: 6583baa3f2
Original change: https://android-review.googlesource.com/c/platform/external/scudo/+/1705746 Change-Id: Ie1c04cb59d4f0201e1a4a9deb23b86f8a892fdfb
-rw-r--r--standalone/benchmarks/malloc_benchmark.cpp14
-rw-r--r--standalone/combined.h4
2 files changed, 13 insertions, 5 deletions
diff --git a/standalone/benchmarks/malloc_benchmark.cpp b/standalone/benchmarks/malloc_benchmark.cpp
index ce48dc02f7a..661fff45a8d 100644
--- a/standalone/benchmarks/malloc_benchmark.cpp
+++ b/standalone/benchmarks/malloc_benchmark.cpp
@@ -13,15 +13,22 @@
#include "benchmark/benchmark.h"
#include <memory>
+#include <vector>
+
+void *CurrentAllocator;
+template <typename Config> void PostInitCallback() {
+ reinterpret_cast<scudo::Allocator<Config> *>(CurrentAllocator)->initGwpAsan();
+}
template <typename Config> static void BM_malloc_free(benchmark::State &State) {
- using AllocatorT = scudo::Allocator<Config>;
+ using AllocatorT = scudo::Allocator<Config, PostInitCallback<Config>>;
auto Deleter = [](AllocatorT *A) {
A->unmapTestOnly();
delete A;
};
std::unique_ptr<AllocatorT, decltype(Deleter)> Allocator(new AllocatorT,
Deleter);
+ CurrentAllocator = Allocator.get();
Allocator->reset();
const size_t NBytes = State.range(0);
@@ -55,18 +62,19 @@ BENCHMARK_TEMPLATE(BM_malloc_free, scudo::FuchsiaConfig)
template <typename Config>
static void BM_malloc_free_loop(benchmark::State &State) {
- using AllocatorT = scudo::Allocator<Config>;
+ using AllocatorT = scudo::Allocator<Config, PostInitCallback<Config>>;
auto Deleter = [](AllocatorT *A) {
A->unmapTestOnly();
delete A;
};
std::unique_ptr<AllocatorT, decltype(Deleter)> Allocator(new AllocatorT,
Deleter);
+ CurrentAllocator = Allocator.get();
Allocator->reset();
const size_t NumIters = State.range(0);
size_t PageSize = scudo::getPageSizeCached();
- void *Ptrs[NumIters];
+ std::vector<void *> Ptrs(NumIters);
for (auto _ : State) {
size_t SizeLog2 = 0;
diff --git a/standalone/combined.h b/standalone/combined.h
index 146408a26bf..03a85ec3310 100644
--- a/standalone/combined.h
+++ b/standalone/combined.h
@@ -51,8 +51,7 @@ public:
typedef typename Params::template TSDRegistryT<ThisT> TSDRegistryT;
void callPostInitCallback() {
- static pthread_once_t OnceControl = PTHREAD_ONCE_INIT;
- pthread_once(&OnceControl, PostInitCallback);
+ pthread_once(&PostInitNonce, PostInitCallback);
}
struct QuarantineCallback {
@@ -952,6 +951,7 @@ private:
SecondaryT Secondary;
QuarantineT Quarantine;
TSDRegistryT TSDRegistry;
+ pthread_once_t PostInitNonce = PTHREAD_ONCE_INIT;
#ifdef GWP_ASAN_HOOKS
gwp_asan::GuardedPoolAllocator GuardedAlloc;