Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(691)

Unified Diff: base/allocator/partition_allocator/page_allocator.cc

Issue 2609553002: Gracefully handle MADV_FREE available at compile time but not run time (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/allocator/partition_allocator/page_allocator.cc
diff --git a/base/allocator/partition_allocator/page_allocator.cc b/base/allocator/partition_allocator/page_allocator.cc
index 9678488e340e30e78daf86f88a1601b51fd81c0d..5b1ef8ba2f8b1993be61ab7565b1122f5003d47f 100644
--- a/base/allocator/partition_allocator/page_allocator.cc
+++ b/base/allocator/partition_allocator/page_allocator.cc
@@ -216,6 +216,12 @@ void decommitSystemPages(void* addr, size_t len) {
DCHECK(!(len & kSystemPageOffsetMask));
#if defined(OS_POSIX)
int ret = madvise(addr, len, MADV_FREE);
+ if (ret != 0 && errno == EINVAL) {
+ // MADV_FREE only works on Linux 4.5+ . If request failed,
+ // retry with older MADV_DONTNEED . Note that MADV_FREE
+ // being defined at compile time doesn't imply runtime support.
+ ret = madvise(addr, len, MADV_DONTNEED);
+ }
CHECK(!ret);
#else
setSystemPagesInaccessible(addr, len);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698