diff options
author | Micah Elizabeth Scott <beth@torproject.org> | 2023-08-25 10:51:40 -0700 |
---|---|---|
committer | Micah Elizabeth Scott <beth@torproject.org> | 2023-08-28 10:11:00 -0700 |
commit | a3e7e9bda24ff7eff55c87a2b49b3c7442151a76 (patch) | |
tree | e4e001c0b2a230d9c259d6ab3d05e43a83d7852d | |
parent | 95e8ffa97e413c19c7257c9e6dc9511e98347b68 (diff) | |
download | tor-a3e7e9bda24ff7eff55c87a2b49b3c7442151a76.tar.gz tor-a3e7e9bda24ff7eff55c87a2b49b3c7442151a76.zip |
equix: Disable huge page support by default
Equi-X supports optionally allocating its solver memory using huge
pages, to reduce the virtual memory subsystem overhead required to make
the entire solver buffer live.
Tor doesn't use this feature, since it seems to have no noticeable
performance benefit at this time, but we still included code for it at
compile time. To improve portability, this patch disables huge page
support by default and enables it only in the cmake build system used
for equix benchmarks.
With this patch equix-bench still supports huge pages. Verified using
strace that we're making the hugepage allocation.
There's no fallback for huge pages, so Equi-X initialization will fail
if they are requested and we don't support them for any runtime or
compile-time reason.
Addresses #40843 (NetBSD) but also prevents future porting issues
related to huge pages.
-rw-r--r-- | src/ext/equix/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/ext/equix/hashx/src/virtual_memory.c | 2 | ||||
-rw-r--r-- | src/ext/equix/hashx/src/virtual_memory.h | 5 | ||||
-rw-r--r-- | src/ext/equix/src/context.c | 4 |
4 files changed, 11 insertions, 1 deletions
diff --git a/src/ext/equix/CMakeLists.txt b/src/ext/equix/CMakeLists.txt index 3c4606566f..a9d0665408 100644 --- a/src/ext/equix/CMakeLists.txt +++ b/src/ext/equix/CMakeLists.txt @@ -11,6 +11,7 @@ set(EQUIX_VERSION_STR "${EQUIX_VERSION}.${EQUIX_VERSION_MINOR}.${EQUIX_VERSION_P project(equix) add_definitions(-DHASHX_SIZE=8) +add_definitions(-DEQUIX_SUPPORT_HUGEPAGES) add_subdirectory("hashx") diff --git a/src/ext/equix/hashx/src/virtual_memory.c b/src/ext/equix/hashx/src/virtual_memory.c index 564325b641..2dff6f7552 100644 --- a/src/ext/equix/hashx/src/virtual_memory.c +++ b/src/ext/equix/hashx/src/virtual_memory.c @@ -90,6 +90,7 @@ bool hashx_vm_rx(void* ptr, size_t bytes) { return page_protect(ptr, bytes, PAGE_EXECUTE_READ); } +#ifdef EQUIX_SUPPORT_HUGEPAGES void* hashx_vm_alloc_huge(size_t bytes) { void* mem; #ifdef HASHX_WIN @@ -124,6 +125,7 @@ void* hashx_vm_alloc_huge(size_t bytes) { #endif return mem; } +#endif /* EQUIX_SUPPORT_HUGEPAGES */ void hashx_vm_free(void* ptr, size_t bytes) { if (!ptr) { diff --git a/src/ext/equix/hashx/src/virtual_memory.h b/src/ext/equix/hashx/src/virtual_memory.h index 9780d218c2..63633bed3f 100644 --- a/src/ext/equix/hashx/src/virtual_memory.h +++ b/src/ext/equix/hashx/src/virtual_memory.h @@ -14,7 +14,10 @@ HASHX_PRIVATE void* hashx_vm_alloc(size_t size); HASHX_PRIVATE bool hashx_vm_rw(void* ptr, size_t size); HASHX_PRIVATE bool hashx_vm_rx(void* ptr, size_t size); -HASHX_PRIVATE void* hashx_vm_alloc_huge(size_t size); HASHX_PRIVATE void hashx_vm_free(void* ptr, size_t size); +#ifdef EQUIX_SUPPORT_HUGEPAGES +HASHX_PRIVATE void* hashx_vm_alloc_huge(size_t size); +#endif + #endif diff --git a/src/ext/equix/src/context.c b/src/ext/equix/src/context.c index 28edf5e104..3ae4fdf9cf 100644 --- a/src/ext/equix/src/context.c +++ b/src/ext/equix/src/context.c @@ -27,7 +27,11 @@ equix_ctx* equix_alloc(equix_ctx_flags flags) { if (flags & EQUIX_CTX_SOLVE) { if (flags & EQUIX_CTX_HUGEPAGES) { +#ifdef EQUIX_SUPPORT_HUGEPAGES ctx->heap = hashx_vm_alloc_huge(sizeof(solver_heap)); +#else + ctx->heap = NULL; +#endif } else { ctx->heap = malloc(sizeof(solver_heap)); |