mmap and fileobj: handle MF_ZEROFILL properly
Change-Id: I6ee52b4cab212b1973339bc8d49065c1ec9263b0
This commit is contained in:
committed by
Masamichi Takagi
parent
d15a396d5a
commit
c0c80b71ca
@ -398,8 +398,9 @@ static void fileobj_free(struct memobj *memobj)
|
||||
}
|
||||
}
|
||||
|
||||
/* Pre-mapped? */
|
||||
if (to_memobj(obj)->flags & MF_PREMAP) {
|
||||
/* Pre-mapped zerofilled? */
|
||||
if (to_memobj(obj)->flags & MF_PREMAP &&
|
||||
to_memobj(obj)->flags & MF_ZEROFILL) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < to_memobj(obj)->nr_pages; ++i) {
|
||||
@ -440,7 +441,7 @@ static void fileobj_free(struct memobj *memobj)
|
||||
|
||||
error = syscall_generic_forwarding(__NR_mmap, &ctx);
|
||||
if (error) {
|
||||
kprintf("%s(%p %lx): free failed. %d\n", __func__,
|
||||
dkprintf("%s(%p %lx): free failed. %d\n", __func__,
|
||||
obj, obj->handle, error);
|
||||
/* through */
|
||||
}
|
||||
@ -570,7 +571,8 @@ static int fileobj_get_page(struct memobj *memobj, off_t off,
|
||||
profile_event_add(PROFILE_page_fault_file, PAGE_SIZE);
|
||||
#endif // PROFILE_ENABLE
|
||||
|
||||
if (memobj->flags & MF_PREMAP) {
|
||||
if (memobj->flags & MF_PREMAP &&
|
||||
memobj->flags & MF_ZEROFILL) {
|
||||
int page_ind = off >> PAGE_SHIFT;
|
||||
|
||||
if (!memobj->pages[page_ind]) {
|
||||
|
||||
@ -2001,28 +2001,33 @@ do_mmap(const uintptr_t addr0, const size_t len0, const int prot,
|
||||
/* Update PTEs for pre-mapped memory object */
|
||||
if ((memobj->flags & MF_PREMAP) &&
|
||||
(proc->mpol_flags & MPOL_SHM_PREMAP)) {
|
||||
int i;
|
||||
enum ihk_mc_pt_attribute ptattr;
|
||||
ptattr = arch_vrflag_to_ptattr(range->flag, PF_POPULATE, NULL);
|
||||
if (memobj->flags & MF_ZEROFILL) {
|
||||
int i;
|
||||
enum ihk_mc_pt_attribute ptattr;
|
||||
ptattr = arch_vrflag_to_ptattr(range->flag, PF_POPULATE, NULL);
|
||||
|
||||
for (i = 0; i < memobj->nr_pages; ++i) {
|
||||
error = ihk_mc_pt_set_range(proc->vm->address_space->page_table,
|
||||
proc->vm,
|
||||
(void *)range->start + (i * PAGE_SIZE),
|
||||
(void *)range->start + (i * PAGE_SIZE) +
|
||||
PAGE_SIZE,
|
||||
virt_to_phys(memobj->pages[i]),
|
||||
ptattr,
|
||||
PAGE_SHIFT,
|
||||
range,
|
||||
0);
|
||||
if (error) {
|
||||
kprintf("%s: ERROR: mapping %d page of pre-mapped file\n",
|
||||
__FUNCTION__, i);
|
||||
for (i = 0; i < memobj->nr_pages; ++i) {
|
||||
error = ihk_mc_pt_set_range(proc->vm->address_space->page_table,
|
||||
proc->vm,
|
||||
(void *)range->start + (i * PAGE_SIZE),
|
||||
(void *)range->start + (i * PAGE_SIZE) +
|
||||
PAGE_SIZE,
|
||||
virt_to_phys(memobj->pages[i]),
|
||||
ptattr,
|
||||
PAGE_SHIFT,
|
||||
range,
|
||||
0);
|
||||
if (error) {
|
||||
kprintf("%s: ERROR: mapping %d page of pre-mapped file\n",
|
||||
__FUNCTION__, i);
|
||||
}
|
||||
}
|
||||
dkprintf("%s: memobj 0x%lx pre-mapped\n", __FUNCTION__, memobj);
|
||||
// fileobj && MF_PREMAP && MPOL_SHM_PREMAP case: memory_stat_rss_add() is called in fileobj_create()
|
||||
}
|
||||
else {
|
||||
populated_mapping = 1;
|
||||
}
|
||||
dkprintf("%s: memobj 0x%lx pre-mapped\n", __FUNCTION__, memobj);
|
||||
// fileobj && MF_PREMAP && MPOL_SHM_PREMAP case: memory_stat_rss_add() is called in fileobj_create()
|
||||
}
|
||||
/*
|
||||
else if (memobj->flags & MF_REG_FILE) {
|
||||
|
||||
Reference in New Issue
Block a user