From 60ae4c62d3b7136f05641cf8989330a1881c8d58 Mon Sep 17 00:00:00 2001 From: klzgrad Date: Sat, 12 Nov 2022 15:13:24 +0800 Subject: [PATCH] allocator: Fix recommitted pages not being zeroed when madvise is not available. Support kernels built without CONFIG_ADVISE_SYSCALLS on small embedded devices. --- src/base/allocator/partition_allocator/page_allocator.h | 2 ++ .../partition_allocator/page_allocator_internals_posix.h | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/base/allocator/partition_allocator/page_allocator.h b/src/base/allocator/partition_allocator/page_allocator.h index 8e366cc168..d2fc8d28d3 100644 --- a/src/base/allocator/partition_allocator/page_allocator.h +++ b/src/base/allocator/partition_allocator/page_allocator.h @@ -260,6 +260,8 @@ constexpr PA_COMPONENT_EXPORT( PARTITION_ALLOC) bool DecommittedMemoryIsAlwaysZeroed() { #if BUILDFLAG(IS_APPLE) return false; +#elif defined(NO_MADVISE_SYSCALL) + return false; #else return true; #endif diff --git a/src/base/allocator/partition_allocator/page_allocator_internals_posix.h b/src/base/allocator/partition_allocator/page_allocator_internals_posix.h index 906cdde069..9916dabfba 100644 --- a/src/base/allocator/partition_allocator/page_allocator_internals_posix.h +++ b/src/base/allocator/partition_allocator/page_allocator_internals_posix.h @@ -410,6 +410,9 @@ void DiscardSystemPagesInternal(uintptr_t address, size_t length) { ret = madvise(ptr, length, MADV_DONTNEED); } PA_PCHECK(ret == 0); +#elif defined(NO_MADVISE_SYSCALL) + static_cast(ptr); + static_cast(length); #else // BUILDFLAG(IS_APPLE) // We have experimented with other flags, but with suboptimal results. //