Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ jobs:
- name: Test libmimalloc-sys crate bindings (v2, extended)
run: cargo run --features libmimalloc-sys-test/v2,libmimalloc-sys-test/extended -p libmimalloc-sys-test

- name: Test libmimalloc-sys (no_thp)
if: ${{ contains(matrix.os, 'ubuntu') }}
run: cargo test --features libmimalloc-sys/no_thp -p libmimalloc-sys

- name: Test libmimalloc-sys (v2, no_thp)
if: ${{ contains(matrix.os, 'ubuntu') }}
run: cargo test --features libmimalloc-sys/v2,libmimalloc-sys/no_thp -p libmimalloc-sys

- name: Test override dylib
if: ${{ !contains(matrix.os, 'windows') }}
run: cargo run -ptest-override-with-dylib --features override
Expand Down
2 changes: 1 addition & 1 deletion libmimalloc-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ fn main() {
if (target_os == "linux" || target_os == "android")
&& env::var_os("CARGO_FEATURE_NO_THP").is_some()
{
build.define("MI_NO_THP", "1");
build.define("MI_DEFAULT_ALLOW_THP", "0");
}

if debug_enabled {
Expand Down
11 changes: 11 additions & 0 deletions libmimalloc-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,15 @@ mod tests {
let ptr = unsafe { mi_malloc(42) };
unsafe { libc::free(ptr) };
}

#[cfg(all(feature = "no_thp", target_os = "linux"))]
#[test]
fn no_thp_disables_transparent_huge_pages() {
// mimalloc disables THP when it initializes
unsafe { mi_free(mi_malloc(8)) };
assert_eq!(
unsafe { libc::prctl(libc::PR_GET_THP_DISABLE, 0, 0, 0, 0) },
1
);
}
}