openwrt: allocator: Fix recommitted pages not being zeroed when madvise is not available.

Support kernels built without CONFIG_ADVISE_SYSCALLS on small
embedded devices.
This commit is contained in:
klzgrad 2022-11-12 15:13:24 +08:00
parent 685e44418a
commit 8cb5b51c5b
2 changed files with 5 additions and 0 deletions

View File

@ -271,6 +271,8 @@ constexpr PA_COMPONENT_EXPORT(
PARTITION_ALLOC) bool DecommittedMemoryIsAlwaysZeroed() { PARTITION_ALLOC) bool DecommittedMemoryIsAlwaysZeroed() {
#if PA_BUILDFLAG(IS_APPLE) #if PA_BUILDFLAG(IS_APPLE)
return false; return false;
#elif defined(NO_MADVISE_SYSCALL)
return false;
#else #else
return true; return true;
#endif #endif

View File

@ -419,6 +419,9 @@ void DiscardSystemPagesInternal(uintptr_t address, size_t length) {
ret = madvise(ptr, length, MADV_DONTNEED); ret = madvise(ptr, length, MADV_DONTNEED);
} }
PA_PCHECK(ret == 0); PA_PCHECK(ret == 0);
#elif defined(NO_MADVISE_SYSCALL)
static_cast<void>(ptr);
static_cast<void>(length);
#else // PA_BUILDFLAG(IS_APPLE) #else // PA_BUILDFLAG(IS_APPLE)
// We have experimented with other flags, but with suboptimal results. // We have experimented with other flags, but with suboptimal results.
// //