diff --git a/src/pal/pal_openbsd.h b/src/pal/pal_openbsd.h index fa157509b..3f7714d24 100644 --- a/src/pal/pal_openbsd.h +++ b/src/pal/pal_openbsd.h @@ -22,6 +22,28 @@ namespace snmalloc * should add any required features. */ static constexpr uint64_t pal_features = PALBSD::pal_features; + + /** + * + * On OpenBSD, pages seem not discarded in due time + * despite normally MADV_FREE is normally fast enough + * in other platforms, thus some unit tests are failing. + * + * Notifying by discarding access instead. + */ + + static void notify_not_using(void* p, size_t size) noexcept + { + SNMALLOC_ASSERT(is_aligned_block(p, size)); + mprotect(p, size, PROT_NONE); + } + + template + static void notify_using(void* p, size_t size) + { + SNMALLOC_ASSERT(is_aligned_block(p, size)); + mprotect(p, size, PROT_READ | PROT_WRITE); + } }; } // namespace snmalloc #endif