Commit 07f4d1a5 authored by Sonny Rao's avatar Sonny Rao Committed by Commit Bot

chromeos_hugepage: mlock in the area covered by huge pages

We are putting our most used text into a region that can be backed by
huge pages, however we can lose those pages when we encounter memory
pressure, so we should be locking them into place to avoid that.

R=llozano@chromium.org

Bug: 913700
Change-Id: If9ae32ae046a21d5bf7af4e43624323b3429d9f8
Reviewed-on: https://chromium-review.googlesource.com/c/1371206Reviewed-by: default avatarGeorge Burgess <gbiv@chromium.org>
Commit-Queue: Sonny Rao <sonnyrao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#615724}
parent e348d7bf
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
#include <link.h> #include <link.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <sys/resource.h>
#include <sys/time.h>
#include "base/bit_cast.h" #include "base/bit_cast.h"
#include "base/logging.h" #include "base/logging.h"
...@@ -61,6 +63,10 @@ static void* GetTransparentHugepageMapping(const size_t hsize) { ...@@ -61,6 +63,10 @@ static void* GetTransparentHugepageMapping(const size_t hsize) {
munmap(haddr, hsize); munmap(haddr, hsize);
return NULL; return NULL;
} }
if (mlock(haddr, hsize)) {
PLOG(INFO) << "Mlocking text pages failed";
}
return haddr; return haddr;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment