Use MADV_FREE to reclaim pages of freed regions

In order to release memory consumed by freed regions back to kernel we
use madvise(MADV_DONTNEED) syscall, which synchronously takes away all
the pages of the given memory range. As a side-effect, this also
provides us clean (zeroed-out) pages the next time region is used by
an application thread as a TLAB. The downside is overhead of
MADV_DONTNEED (it has to manipulate all the corresponding page-table
entries). Furthermore, the application thread gets page fault each
time it moves from one page to the next while consuming the TLAB.

MADV_FREE is another madvise option that also advises kernel to take
away the pages, but only when there is memory pressure. It is a much
more light-weight operation than MADV_DONTNEED. Also, the application
thread doesn't get the page fault overhead, if the page is not already
reclaimed. However, a page which is not reclaimed by the kernel will
have stale data on it.

This change uses MADV_FREE for region-space's reclamation and ensures
that pages about to be used for new allocations are properly cleared.

Bug: 74447417
Bug: 140130889
Test: Golem, mpts/greenday tests
Change-Id: I1e4a75abed51844d5062685bf77871f609af5a65
9 files changed