From c3a4999c6af88a8851a4a0e47300d4659f07d776 Mon Sep 17 00:00:00 2001 From: klzgrad Date: Sat, 12 Nov 2022 15:13:24 +0800 Subject: [PATCH] base/allocator: Fix recommitted pages not being zeroed when madvise is not available. Support kernels built without CONFIG_ADVISE_SYSCALLS on small embedded devices. --- .../partition_allocator/src/partition_alloc/page_allocator.h | 2 ++ .../src/partition_alloc/page_allocator_internals_posix.h | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/base/allocator/partition_allocator/src/partition_alloc/page_allocator.h b/src/base/allocator/partition_allocator/src/partition_alloc/page_allocator.h index b3326ce056..d3585b6051 100644 --- a/src/base/allocator/partition_allocator/src/partition_alloc/page_allocator.h +++ b/src/base/allocator/partition_allocator/src/partition_alloc/page_allocator.h @@ -271,6 +271,8 @@ constexpr PA_COMPONENT_EXPORT( PARTITION_ALLOC) bool DecommittedMemoryIsAlwaysZeroed() { #if PA_BUILDFLAG(IS_APPLE) return false; +#elif defined(NO_MADVISE_SYSCALL) + return false; #else return true; #endif diff --git a/src/base/allocator/partition_allocator/src/partition_alloc/page_allocator_internals_posix.h b/src/base/allocator/partition_allocator/src/partition_alloc/page_allocator_internals_posix.h index 7b907af2a3..7423413278 100644 --- a/src/base/allocator/partition_allocator/src/partition_alloc/page_allocator_internals_posix.h +++ b/src/base/allocator/partition_allocator/src/partition_alloc/page_allocator_internals_posix.h @@ -418,6 +418,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 // PA_BUILDFLAG(IS_APPLE) // We have experimented with other flags, but with suboptimal results. //