changelog shortlog tags branches files raw gz bz2 help

Mercurial > hg > plan9front / changeset: bcm kernel: add *kernelpercent option for cmdline.txt

changeset 3401: 69064e032a3e
parent 3400: fb0983c703a7
child 3402: ba8b8f4c7306
child 3403: f911ce883e4a
author: stanley.lieber@gmail.com
date: Fri, 28 Feb 2014 00:27:32 -0500
files: sys/src/9/bcm/main.c
description: bcm kernel: add *kernelpercent option for cmdline.txt
     1.1--- a/sys/src/9/bcm/main.c
     1.2+++ b/sys/src/9/bcm/main.c
     1.3@@ -425,11 +425,16 @@ userinit(void)
     1.4 void
     1.5 confinit(void)
     1.6 {
     1.7-	int i;
     1.8+	int i, userpcnt;
     1.9 	ulong kpages;
    1.10 	uintptr pa;
    1.11 	char *p;
    1.12 
    1.13+	if(p = getconf("*kernelpercent"))
    1.14+		userpcnt = 100 - strtol(p, 0, 0);
    1.15+	else
    1.16+		userpcnt = 0;
    1.17+
    1.18 	if(0 && (p = getconf("service")) != nil){
    1.19 		if(strcmp(p, "cpu") == 0)
    1.20 			cpuserver = 1;
    1.21@@ -465,8 +470,19 @@ confinit(void)
    1.22 		conf.npage += conf.mem[i].npage;
    1.23 	}
    1.24 
    1.25-	conf.upages = (conf.npage*80)/100;
    1.26-	conf.ialloc = ((conf.npage-conf.upages)/2)*BY2PG;
    1.27+	if(userpcnt < 10)
    1.28+		userpcnt = 60 + cpuserver*10;
    1.29+	kpages = conf.npage - (conf.npage*userpcnt)/100;
    1.30+
    1.31+	/*
    1.32+	 * can't go past the end of virtual memory
    1.33+	 * (ulong)-KZERO is 2^32 - KZERO
    1.34+	 */
    1.35+	if(kpages > ((ulong)-KZERO)/BY2PG)
    1.36+		kpages = ((ulong)-KZERO)/BY2PG;
    1.37+
    1.38+	conf.upages = conf.npage - kpages;
    1.39+	conf.ialloc = (kpages/2)*BY2PG;
    1.40 
    1.41 	/* only one processor */
    1.42 	conf.nmach = 1;
    1.43@@ -494,7 +510,7 @@ confinit(void)
    1.44 		+ conf.nproc*sizeof(Proc)
    1.45 		+ conf.nimage*sizeof(Image)
    1.46 		+ conf.nswap
    1.47-		+ conf.nswppo*sizeof(Page);
    1.48+		+ conf.nswppo*sizeof(Page*);
    1.49 	mainmem->maxsize = kpages;
    1.50 	if(!cpuserver)
    1.51 		/*