From 5bac38ce8b191d625ca2eb00dbc99152108e7255 Mon Sep 17 00:00:00 2001 From: Balazs Gerofi Date: Sat, 31 Dec 2016 17:32:51 +0900 Subject: [PATCH] mmap()/stack/heap: follow user requested NUMA policy --- kernel/process.c | 9 +++++++-- kernel/syscall.c | 8 ++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/kernel/process.c b/kernel/process.c index 187a1b72..1e809fa6 100644 --- a/kernel/process.c +++ b/kernel/process.c @@ -1841,6 +1841,7 @@ int init_process_stack(struct thread *thread, struct program_load_desc *pn, unsigned long minsz; unsigned long at_rand; struct process *proc = thread->proc; + unsigned long __flag; /* create stack range */ end = STACK_TOP(&thread->vm->region); @@ -1863,8 +1864,11 @@ int init_process_stack(struct thread *thread, struct program_load_desc *pn, return rc; } + __flag = (size >= 16777216) ? IHK_MC_AP_USER : 0; /* map physical pages for initial stack frame */ - stack = ihk_mc_alloc_pages(minsz >> PAGE_SHIFT, IHK_MC_AP_NOWAIT); + stack = ihk_mc_alloc_pages(minsz >> PAGE_SHIFT, + IHK_MC_AP_NOWAIT | __flag); + if (!stack) { return -ENOMEM; } @@ -2027,7 +2031,8 @@ unsigned long extend_process_region(struct process_vm *vm, p=0; }else{ - p = ihk_mc_alloc_pages((aligned_new_end - aligned_end) >> PAGE_SHIFT, IHK_MC_AP_NOWAIT); + p = ihk_mc_alloc_pages((aligned_new_end - aligned_end) >> PAGE_SHIFT, + IHK_MC_AP_NOWAIT | IHK_MC_AP_USER); if (!p) { return end; diff --git a/kernel/syscall.c b/kernel/syscall.c index 0f5e5b3a..8b058ef4 100644 --- a/kernel/syscall.c +++ b/kernel/syscall.c @@ -1321,15 +1321,15 @@ do_mmap(const intptr_t addr0, const size_t len0, const int prot, npages = len >> PAGE_SHIFT; /* Small allocations mostly benefit from closest RAM, * otherwise follow user requested policy */ - unsigned long __flag = (len >= 1048576) ? IHK_MC_AP_USER : 0; + unsigned long __flag = (len >= 2097152) ? IHK_MC_AP_USER : 0; p = ihk_mc_alloc_aligned_pages(npages, p2align, IHK_MC_AP_NOWAIT | __flag); if (p == NULL) { - ekprintf("%s: warning: failed to allocate %d contiguous pages" - " (pgshift: %d), enabling demand paging\n", + dkprintf("%s: warning: failed to allocate %d contiguous pages " + " (bytes: %lu, pgshift: %d), enabling demand paging\n", __FUNCTION__, - npages, p2align); + npages, npages * PAGE_SIZE, p2align); /* Give demand paging a chance */ vrflags |= VR_DEMAND_PAGING;