From 97be7f162ae720ed93c50cca5045d1d2b06d72e9 Mon Sep 17 00:00:00 2001 From: klzgrad Date: Sat, 12 Nov 2022 15:13:24 +0800 Subject: [PATCH] allocator: Ignore madvise ENOSYS error Support kernels built without CONFIG_ADVISE_SYSCALLS on small embedded devices. --- .../partition_allocator/page_allocator_internals_posix.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 8bf4a64926..798f0af0ac 100644 --- a/src/base/allocator/partition_allocator/page_allocator_internals_posix.h +++ b/src/base/allocator/partition_allocator/page_allocator_internals_posix.h @@ -410,7 +410,12 @@ void DiscardSystemPagesInternal(uintptr_t address, size_t length) { // performance benefits unclear. // // Therefore, we just do the simple thing: MADV_DONTNEED. - PA_PCHECK(0 == madvise(ptr, length, MADV_DONTNEED)); + int ret = madvise(ptr, length, MADV_DONTNEED); + if (ret && errno == ENOSYS) { + // Ignores when the kernel is built without CONFIG_ADVISE_SYSCALLS + return; + } + PA_PCHECK(ret == 0); #endif // BUILDFLAG(IS_APPLE) }