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? */
|
/* Pre-mapped zerofilled? */
|
||||||
if (to_memobj(obj)->flags & MF_PREMAP) {
|
if (to_memobj(obj)->flags & MF_PREMAP &&
|
||||||
|
to_memobj(obj)->flags & MF_ZEROFILL) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < to_memobj(obj)->nr_pages; ++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);
|
error = syscall_generic_forwarding(__NR_mmap, &ctx);
|
||||||
if (error) {
|
if (error) {
|
||||||
kprintf("%s(%p %lx): free failed. %d\n", __func__,
|
dkprintf("%s(%p %lx): free failed. %d\n", __func__,
|
||||||
obj, obj->handle, error);
|
obj, obj->handle, error);
|
||||||
/* through */
|
/* 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);
|
profile_event_add(PROFILE_page_fault_file, PAGE_SIZE);
|
||||||
#endif // PROFILE_ENABLE
|
#endif // PROFILE_ENABLE
|
||||||
|
|
||||||
if (memobj->flags & MF_PREMAP) {
|
if (memobj->flags & MF_PREMAP &&
|
||||||
|
memobj->flags & MF_ZEROFILL) {
|
||||||
int page_ind = off >> PAGE_SHIFT;
|
int page_ind = off >> PAGE_SHIFT;
|
||||||
|
|
||||||
if (!memobj->pages[page_ind]) {
|
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 */
|
/* Update PTEs for pre-mapped memory object */
|
||||||
if ((memobj->flags & MF_PREMAP) &&
|
if ((memobj->flags & MF_PREMAP) &&
|
||||||
(proc->mpol_flags & MPOL_SHM_PREMAP)) {
|
(proc->mpol_flags & MPOL_SHM_PREMAP)) {
|
||||||
int i;
|
if (memobj->flags & MF_ZEROFILL) {
|
||||||
enum ihk_mc_pt_attribute ptattr;
|
int i;
|
||||||
ptattr = arch_vrflag_to_ptattr(range->flag, PF_POPULATE, NULL);
|
enum ihk_mc_pt_attribute ptattr;
|
||||||
|
ptattr = arch_vrflag_to_ptattr(range->flag, PF_POPULATE, NULL);
|
||||||
|
|
||||||
for (i = 0; i < memobj->nr_pages; ++i) {
|
for (i = 0; i < memobj->nr_pages; ++i) {
|
||||||
error = ihk_mc_pt_set_range(proc->vm->address_space->page_table,
|
error = ihk_mc_pt_set_range(proc->vm->address_space->page_table,
|
||||||
proc->vm,
|
proc->vm,
|
||||||
(void *)range->start + (i * PAGE_SIZE),
|
(void *)range->start + (i * PAGE_SIZE),
|
||||||
(void *)range->start + (i * PAGE_SIZE) +
|
(void *)range->start + (i * PAGE_SIZE) +
|
||||||
PAGE_SIZE,
|
PAGE_SIZE,
|
||||||
virt_to_phys(memobj->pages[i]),
|
virt_to_phys(memobj->pages[i]),
|
||||||
ptattr,
|
ptattr,
|
||||||
PAGE_SHIFT,
|
PAGE_SHIFT,
|
||||||
range,
|
range,
|
||||||
0);
|
0);
|
||||||
if (error) {
|
if (error) {
|
||||||
kprintf("%s: ERROR: mapping %d page of pre-mapped file\n",
|
kprintf("%s: ERROR: mapping %d page of pre-mapped file\n",
|
||||||
__FUNCTION__, i);
|
__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) {
|
else if (memobj->flags & MF_REG_FILE) {
|
||||||
|
|||||||
Reference in New Issue
Block a user