Skip to content

Commit e4d1a35

Browse files
authored
Merge pull request #227 from devnexen/nothp
adding THP_PAGES option to disable transparent huge pages.
2 parents eb1f3f2 + 2cdac95 commit e4d1a35

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ MALLOC_HOOK = -DMALLOC_HOOK=1
8383
## Use Huge pages for any allocation that is a multiple
8484
## of 2 megabytes. See PERFORMANCE.md for additional info
8585
HUGE_PAGES = -DHUGE_PAGES=1
86+
THP_PAGES = -DTHP_PAGES=1
8687

8788
## Enable the built-in heap profiler. When this is enabled
8889
## IsoAlloc will write a file to disk upon exit of the
@@ -316,7 +317,7 @@ endif
316317
CFLAGS += $(COMMON_CFLAGS) $(DISABLE_CANARY) $(BUILD_ERROR_FLAGS) $(HOOKS) $(HEAP_PROFILER) -fvisibility=hidden \
317318
-std=$(STDC) $(SANITIZER_SUPPORT) $(ALLOC_SANITY) $(MEMCPY_SANITY) $(UNINIT_READ_SANITY) $(CPU_PIN) $(SCHED_GETCPU) \
318319
$(EXPERIMENTAL) $(UAF_PTR_PAGE) $(VERIFY_FREE_BIT_SLOTS) $(NAMED_MAPPINGS) $(ABORT_ON_NULL) $(NO_ZERO_ALLOCATIONS) \
319-
$(ABORT_NO_ENTROPY) $(ISO_DTOR_CLEANUP) $(RANDOMIZE_FREELIST) $(USE_SPINLOCK) $(HUGE_PAGES) $(USE_MLOCK) \
320+
$(ABORT_NO_ENTROPY) $(ISO_DTOR_CLEANUP) $(RANDOMIZE_FREELIST) $(USE_SPINLOCK) $(HUGE_PAGES) ${THP_PAGES} $(USE_MLOCK) \
320321
$(MEMORY_TAGGING) $(STRONG_SIZE_ISOLATION) $(MEMSET_SANITY) $(AUTO_CTOR_DTOR) $(SIGNAL_HANDLER) \
321322
$(BIG_ZONE_META_DATA_GUARD) $(BIG_ZONE_GUARD) $(PROTECT_UNUSED_BIG_ZONE) $(MASK_PTRS) $(SANITIZE_CHUNKS) $(FUZZ_MODE) \
322323
$(PERM_FREE_REALLOC) $(ARM_MTE) $(DONT_USE_NEON)

src/iso_alloc_util.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ void *mmap_pages(size_t size, bool populate, const char *name, int32_t prot) {
157157
LOG_AND_ABORT("Failed to mmap rw pages");
158158
}
159159

160-
#if __linux__ && MAP_HUGETLB && HUGE_PAGES && MADV_HUGEPAGE
160+
#if __linux__ && MAP_HUGETLB && HUGE_PAGES && THP_PAGES && MADV_HUGEPAGE
161161
if(sz == ZONE_USER_SIZE || sz == (ZONE_USER_SIZE >> 1)) {
162162
madvise(p, sz, MADV_HUGEPAGE);
163163
}

0 commit comments

Comments
 (0)