do_mmap: don't pre-populate the whole file when asked for smaller segment

The linker maps parts of libs with different access flags,
so we cannot prepopulate the whole file.

[dominique.martinet@cea.fr: moved min and friends in compiler.h]
Change-Id: Ifbeddc0908699099cfae5ce9cc2adc578221db31
This commit is contained in:
Masamichi Takagi
2019-02-07 10:42:27 +09:00
committed by Dominique Martinet
parent 641d9f1b39
commit e828398c8b
3 changed files with 37 additions and 38 deletions

View File

@ -1925,13 +1925,12 @@ do_mmap(const uintptr_t addr0, const size_t len0, const int prot,
}
/* Determine pre-populated size */
populate_len = len;
populate_len = memobj ? min(len, memobj->size) : len;
if (!(flags & MAP_ANONYMOUS)) {
if (atomic_cmpxchg4(&memobj->status, MEMOBJ_TO_BE_PREFETCHED,
MEMOBJ_READY)) {
populated_mapping = 1;
populate_len = memobj->size;
}
/* Update PTEs for pre-mapped memory object */