From 7dfeb8e7ce678c63944ef1671f8e5c1920f6a087 Mon Sep 17 00:00:00 2001 From: NAKAMURA Gou Date: Wed, 16 Sep 2015 20:32:06 +0900 Subject: [PATCH] create demand-paging mapping in case of MAP_SHARED On current McKernel, only mappings for demand paging can be shared. Therefore, if MAP_SHARED and MAP_ANONYMOUS are specified and anon_on_demand is disabled, then mmap(2) should create a mapping which is for demand paging and is entirely populated with physical pages. --- kernel/syscall.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/kernel/syscall.c b/kernel/syscall.c index d4a69ec2..a49f095b 100644 --- a/kernel/syscall.c +++ b/kernel/syscall.c @@ -988,6 +988,7 @@ SYSCALL_DECLARE(mmap) int denied; int ro_vma_mapped = 0; struct shmid_ds ads; + int populated_mapping = 0; dkprintf("[%d]sys_mmap(%lx,%lx,%x,%x,%d,%lx)\n", ihk_mc_get_processor_id(), @@ -1078,8 +1079,9 @@ SYSCALL_DECLARE(mmap) } #endif else { - if (anon_on_demand) { - vrflags |= VR_DEMAND_PAGING; + vrflags |= VR_DEMAND_PAGING; + if (!anon_on_demand) { + populated_mapping = 1; } } } @@ -1087,6 +1089,10 @@ SYSCALL_DECLARE(mmap) vrflags |= VR_DEMAND_PAGING; } + if (flags & (MAP_POPULATE | MAP_LOCKED)) { + populated_mapping = 1; + } + if (!(prot & PROT_WRITE)) { error = set_host_vma(addr, len, PROT_READ); if (error) { @@ -1202,7 +1208,7 @@ out: } ihk_mc_spinlock_unlock_noirq(&proc->vm->memory_range_lock); - if (!error && (flags & (MAP_POPULATE) || flags & (MAP_LOCKED))) { + if (!error && populated_mapping) { error = populate_process_memory(proc, (void *)addr, len); if (error) { ekprintf("sys_mmap:populate_process_memory"