Well my initial attempt to do this was completely, hmm…how do you put this in
one word? IDIOTIC
I took a look at what uvm_init
in sys/uvm/uvm_init.c
does and tried to
replace the equivament code in sys/rump/librump/rumpkern/vm.c
and boy was it a
clustfuck of spaghetti code. After discussing my lame approach with Cherry
(cherry@) during which he described we do not want to “at the moment” get all of
uvm into Rump, just necessary parts of it so that we can successfully execute
uvm_page_physload()
and to do only necessary modifications especially in the
namespace so that I can get the necessary parts of the uvm to execute.
This made me look into the Build system Makefile
used by Rump specifically in
rumpkern
folder and I found out that Rump does use parts of uvm to achieve
some of it’s necessities.
One of the first problem that happened when I included the file was I was
getting errors on includes espcially those which had the name opt_*
, upon
checking the files which were already included with compile I found out that
these included were put under a #ifdef
macro _KERNEL_OPT
which allowed them
to be ignored during the rump compile.
#ifdef _KERNEL_OPT
...
#endif
Using this technique I was able to segregate parts of the code from the original
uvm files that conflicted with sections in rump or had some sort of stub
implementation in rump. After some hours of trial and error, adding some stub
functionality into vm.c
for functions that could not be imported directly
since they were in the Machine Dependent part of the system, I managed to get a
successful build for librump
. In addition to this before the build I made the
following changes to vm.c
.
@@ -376,6 +380,8 @@ uvm_init(void)
cv_init(&pdaemoncv, "pdaemon");
cv_init(&oomwait, "oomwait");
+ uvm_page_physload(4 * PAGE_SIZE, rump_physmemlimit, 4 * PAGE_SIZE, rump_physmemlimit, 0);
+
module_map = &module_map_store;
kernel_map->pmap = pmap_kernel();
@@ -1244,3 +1250,157 @@ rump_hyperfree(void *what, size_t size)
}
rumpuser_free(what, size);
}
So that I can check if uvm_page_physload()
will execute without causing a
segfault. And to my surprise it ran pretty good.
Here is the ouput of the run logs from a small application that I wrote which
executes rump_init()
function call, the statements marked in **
are debug
statements.
[fox@theta: /home/fox/project/netbsd-current]$ ./mem_consumer
Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016
The NetBSD Foundation, Inc. All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
The Regents of the University of California. All rights reserved.
NetBSD 7.99.28 (RUMP-ROAST)
**We are here uvm_init**
total memory = 896 KB
**entering uvm_pagephysload...**
**exiting uvm_pagephysload...**
timecounter: Timecounters tick every 10.000 msec
timecounter: Timecounter "clockinterrupt" frequency 100 Hz quality 0
cpu0 at thinair0: rump virtual cpu
cpu1 at thinair0: rump virtual cpu
root file system type: rumpfs
kern.module.path=/stand/i386/7.99.28/modules
pdpolicy / reactanon: 0
pdpolicy / reactfile: 0
pdpolicy / reactexec: 0
vmem / static_bt_inuse: 61
vmem / static_bt_count: 200
pserialize / exclusive access: 0
rump biglock / fast: 35
rump biglock / slow: 0
rump biglock / recurse: 8
callout / late/0: 0
callout / wait/0: 0
crosscall / unicast: 0
crosscall / broadcast: 0
callout / late/1: 0
callout / wait/1: 0
rumpblk / I/O reqs: 0
rumpblk / async I/O: 0
rumpblk / bytes read: 0
rumpblk / bytes written: 0
rumpblk / bytes written async: 0
namecache / entries scanned: 0
namecache / entries collected: 0
namecache / over scan target: 0
namecache / under scan target: 0
namecache / forced reclaims: 0
I am from rump, done
[fox@theta: /home/fox/project/netbsd-current]$
Hopefully these baby steps take me a bit closer to my objective of testing out
uvm in rump. More updates coming as I make further progress.