Added Config.hs flag for morecore pagesize.
authorSimon Gerber <simon.gerber@hp.com>
Mon, 4 Aug 2014 21:41:31 +0000 (14:41 -0700)
committerSimon Gerber <simon.gerber@inf.ethz.ch>
Mon, 4 May 2015 09:28:13 +0000 (11:28 +0200)
Conflicts:
lib/barrelfish/init.c
lib/barrelfish/morecore.c

Signed-off-by: Simon Gerber <simon.gerber@hp.com>

hake/Config.hs.template
include/barrelfish/morecore.h
lib/barrelfish/Hakefile
lib/barrelfish/init.c
lib/barrelfish/morecore.c

index 438ec59..e2a417b 100644 (file)
@@ -1,5 +1,6 @@
 --------------------------------------------------------------------------
 -- Copyright (c) 2007-2010, 2012, ETH Zurich.
+-- Copyright (c) 2014, HP Labs.
 -- All rights reserved.
 --
 -- This file is distributed under the terms in the attached LICENSE file.
@@ -43,6 +44,13 @@ newlib_malloc :: String
 --newlib_malloc = "dlmalloc" -- use dlmalloc
 newlib_malloc = "oldmalloc"
 
+-- Configure pagesize for libbarrelfish's morecore implementation
+-- x86_64 accepts "small", "large", and "huge" for 4kB, 2MB and 1GB pages
+-- respectively. x86_32 accepts "small" and "large" for 4kB and 2MB/4MB pages
+-- respectively. All other architectures default to their default page size.
+morecore_pagesize :: String
+morecore_pagesize = "large"
+
 -- Use a frame pointer
 use_fp :: Bool
 use_fp = True
index 2c49b22..5c957f1 100644 (file)
@@ -20,7 +20,7 @@
 
 __BEGIN_DECLS
 
-errval_t morecore_init(void);
+errval_t morecore_init(size_t alignment);
 void morecore_use_optimal(void);
 errval_t morecore_reinit(void);
 
index 930a833..15a9470 100644 (file)
@@ -1,5 +1,6 @@
 --------------------------------------------------------------------------
 -- Copyright (c) 2007-2012, ETH Zurich
+-- Copyright (c) 2014, HP Labs.
 -- All rights reserved.
 --
 -- This file is distributed under the terms in the attached LICENSE file.
             getsrcs "multihop" = [ "multihop_chan.c" ]
             getsrcs _ = []
 
+      morecore_pagesize "x86_64" = case Config.morecore_pagesize of
+          "large" -> "LARGE_PAGE_SIZE"
+          "huge"  -> "HUGE_PAGE_SIZE"
+          _       -> "BASE_PAGE_SIZE"
+      morecore_pagesize "x86_32" = case Config.morecore_pagesize of
+          "large" -> "LARGE_PAGE_SIZE"
+          _       -> "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" ,
                               "arch/x86_32/dispatch.c" , "arch/x86_32/syscalls.c" ,
                                               ("mem", ["rpcclient"]),
                                               ("octopus", ["rpcclient"]),
                                               ("spawn", ["rpcclient"])],
+                    addCFlags = [ "-DMORECORE_PAGESIZE="++(morecore_pagesize arch),
+                                  "-DMORECORE_VREGION_FLAGS="++(morecore_vregion_flags arch)
+                                ],
                     addIncludes = [ "include", "include" ./. arch_dir ],
                     addGeneratedDependencies = [ "/include/asmoffsets.h" ]
                   }
index c82eadc..3131f92 100644 (file)
@@ -193,7 +193,14 @@ errval_t barrelfish_init_onthread(struct spawn_domain_params *params)
         // TODO: the kernel boots us with a deterministic pmap structure: use it
     }
 
-    err = morecore_init();
+    if (init_domain) {
+        // we cannot use large pages in the init domains because we are not
+        // connected to the memory server and need to work with the 4k pages
+        // in the base cn.
+        err = morecore_init(BASE_PAGE_SIZE);
+    } else {
+        err = morecore_init(MORECORE_PAGESIZE);
+    }
     if (err_is_fail(err)) {
         return err_push(err, LIB_ERR_MORECORE_INIT);
     }
index 84f217a..de81db2 100644 (file)
@@ -108,7 +108,7 @@ Header *get_malloc_freep(void)
     return get_morecore_state()->header_freep;
 }
 
-errval_t morecore_init(void)
+errval_t morecore_init(size_t alignment)
 {
     errval_t err;
     struct morecore_state *state = get_morecore_state();
@@ -116,7 +116,7 @@ errval_t morecore_init(void)
     thread_mutex_init(&state->mutex);
 
     err = vspace_mmu_aware_init_aligned(&state->mmu_state, HEAP_REGION,
-            BASE_PAGE_SIZE, VREGION_FLAGS_READ_WRITE);
+            alignment, VREGION_FLAGS_READ_WRITE | MORECORE_VREGION_FLAGS);
     if (err_is_fail(err)) {
         return err_push(err, LIB_ERR_VSPACE_MMU_AWARE_INIT);
     }