ref: d8035a86f77b7351ebdea9bad0ba77593b84ed76
parent: fd112b949f8843146ba40bc7c95688acc97bd899
author: stanley lieber <stanley.lieber@gmail.com>
date: Thu Feb 27 19:27:32 EST 2014
bcm kernel: add *kernelpercent option for cmdline.txt
--- a/sys/src/9/bcm/main.c
+++ b/sys/src/9/bcm/main.c
@@ -425,11 +425,16 @@
void
confinit(void)
{
- int i;
+ int i, userpcnt;
ulong kpages;
uintptr pa;
char *p;
+ if(p = getconf("*kernelpercent"))
+ userpcnt = 100 - strtol(p, 0, 0);
+ else
+ userpcnt = 0;
+
if(0 && (p = getconf("service")) != nil){
if(strcmp(p, "cpu") == 0)
cpuserver = 1;
@@ -465,9 +470,20 @@
conf.npage += conf.mem[i].npage;
}
- conf.upages = (conf.npage*80)/100;
- conf.ialloc = ((conf.npage-conf.upages)/2)*BY2PG;
+ if(userpcnt < 10)
+ userpcnt = 60 + cpuserver*10;
+ kpages = conf.npage - (conf.npage*userpcnt)/100;
+ /*
+ * can't go past the end of virtual memory
+ * (ulong)-KZERO is 2^32 - KZERO
+ */
+ if(kpages > ((ulong)-KZERO)/BY2PG)
+ kpages = ((ulong)-KZERO)/BY2PG;
+
+ conf.upages = conf.npage - kpages;
+ conf.ialloc = (kpages/2)*BY2PG;
+
/* only one processor */
conf.nmach = 1;
@@ -494,7 +510,7 @@
+ conf.nproc*sizeof(Proc)
+ conf.nimage*sizeof(Image)
+ conf.nswap
- + conf.nswppo*sizeof(Page);
+ + conf.nswppo*sizeof(Page*);
mainmem->maxsize = kpages;
if(!cpuserver)
/*