Use MAP_SHARED for 1G huge pages
commit70c08ab51f15cd44267ccbe504734a03a526780d
authorBin Liu <binliu@fb.com>
Tue, 8 Nov 2016 00:26:43 +0000 (7 16:26 -0800)
committerHhvm Bot <hhvm-bot-bot@fb.com>
Tue, 8 Nov 2016 00:37:01 +0000 (7 16:37 -0800)
tree8b7a72817585af1b4490eef6eba636f3b60ce59a
parent17ab9bc08111277d4e488b00d76a706b032b55ab
Use MAP_SHARED for 1G huge pages

Summary:
In order to avoid copy-on-write (which results in additional copies of huge pages), we mark 1G pages SHARED.

The understanding here is that child processes of HHVM shouldn't really write to the pages, so we forbid it just to be safe.
Maybe we can forbid reads as well, or simply use madvise DONTFORK.
While we test these, only forbidding writes feels a bit safer.

If we need to fork() and execute php code, fail if 1G pages are not used.

Differential Revision: D4099950

fbshipit-source-id: e9b6632786e66a611cafbd2084c83d0563c46ac0
hphp/runtime/vm/repo.cpp
hphp/util/hugetlb.cpp
hphp/util/hugetlb.h
hphp/util/light-process.cpp