From 80dc5a3f80351b67da7e7d81bfb83584758c631f Mon Sep 17 00:00:00 2001 From: Simon Gerber Date: Mon, 4 Aug 2014 15:50:23 -0700 Subject: [PATCH] Added command line arg for overriding default heap pagesize. Also removed the vregion flags #define for the heap region as we can infer the necessary flags from the alignment argument to morecore_init(). We now choose the pagesize that matches the alignment or 4kB if no match found. Signed-off-by: Simon Gerber --- lib/barrelfish/Hakefile | 14 ++------------ lib/barrelfish/init.c | 32 +++++++++++++++++++++++++++++++- lib/barrelfish/morecore.c | 9 ++++++++- 3 files changed, 41 insertions(+), 14 deletions(-) diff --git a/lib/barrelfish/Hakefile b/lib/barrelfish/Hakefile index 15a9470..3d005e8 100644 --- a/lib/barrelfish/Hakefile +++ b/lib/barrelfish/Hakefile @@ -37,6 +37,7 @@ getsrcs "multihop" = [ "multihop_chan.c" ] getsrcs _ = [] + -- configure default morecore pagesize based on Config.hs morecore_pagesize "x86_64" = case Config.morecore_pagesize of "large" -> "LARGE_PAGE_SIZE" "huge" -> "HUGE_PAGE_SIZE" @@ -46,15 +47,6 @@ _ -> "BASE_PAGE_SIZE" morecore_pagesize _ = "BASE_PAGE_SIZE" - morecore_vregion_flags "x86_64" = case Config.morecore_pagesize of - "large" -> "VREGION_FLAGS_LARGE" - "huge" -> "VREGION_FLAGS_HUGE" - _ -> "" - morecore_vregion_flags "x86_32" = case Config.morecore_pagesize of - "large" -> "VREGION_FLAGS_LARGE" - _ -> "" - morecore_vregion_flags _ = "" - -- sources specific to the architecture family archfam_srcs "x86_32" = [ "arch/x86_32/debug.c" , @@ -105,9 +97,7 @@ ("mem", ["rpcclient"]), ("octopus", ["rpcclient"]), ("spawn", ["rpcclient"])], - addCFlags = [ "-DMORECORE_PAGESIZE="++(morecore_pagesize arch), - "-DMORECORE_VREGION_FLAGS="++(morecore_vregion_flags arch) - ], + addCFlags = [ "-DMORECORE_PAGESIZE="++(morecore_pagesize arch) ], addIncludes = [ "include", "include" ./. arch_dir ], addGeneratedDependencies = [ "/include/asmoffsets.h" ] } diff --git a/lib/barrelfish/init.c b/lib/barrelfish/init.c index 3131f92..dc60c4b 100644 --- a/lib/barrelfish/init.c +++ b/lib/barrelfish/init.c @@ -199,7 +199,37 @@ errval_t barrelfish_init_onthread(struct spawn_domain_params *params) // in the base cn. err = morecore_init(BASE_PAGE_SIZE); } else { - err = morecore_init(MORECORE_PAGESIZE); + // grab pagesize config from argv if available + size_t morecore_pagesize = MORECORE_PAGESIZE; + int i = 1; + bool found = false; + for (; i < params->argc; i++) { + if (!found) { + if (!strncmp(params->argv[i], "morecore=", 9)) { + morecore_pagesize = atoi(params->argv[i]+9); + // check for valid page size + switch (morecore_pagesize) { +#ifdef __x86_64__ + case HUGE_PAGE_SIZE: +#endif + case BASE_PAGE_SIZE: + case LARGE_PAGE_SIZE: + break; + default: + morecore_pagesize = MORECORE_PAGESIZE; + } + found = true; + } + } else { + // found so move all other args one to the front + params->argv[i-1] = params->argv[i]; + } + } + if (found) { + params->argc -= 1; + } + + err = morecore_init(morecore_pagesize); } if (err_is_fail(err)) { return err_push(err, LIB_ERR_MORECORE_INIT); diff --git a/lib/barrelfish/morecore.c b/lib/barrelfish/morecore.c index de81db2..1a9eba0 100644 --- a/lib/barrelfish/morecore.c +++ b/lib/barrelfish/morecore.c @@ -115,8 +115,15 @@ errval_t morecore_init(size_t alignment) thread_mutex_init(&state->mutex); + // setup flags that match the alignment + vregion_flags_t morecore_flags = VREGION_FLAGS_READ_WRITE; +#if __x86_64__ + morecore_flags |= (alignment == HUGE_PAGE_SIZE ? VREGION_FLAGS_HUGE : 0); +#endif + morecore_flags |= (alignment == LARGE_PAGE_SIZE ? VREGION_FLAGS_LARGE : 0); + err = vspace_mmu_aware_init_aligned(&state->mmu_state, HEAP_REGION, - alignment, VREGION_FLAGS_READ_WRITE | MORECORE_VREGION_FLAGS); + alignment, morecore_flags); if (err_is_fail(err)) { return err_push(err, LIB_ERR_VSPACE_MMU_AWARE_INIT); } -- 1.7.2.5