shithub: 9ferno

Download patch

ref: 0cb5f1d1ba2e5570e22f00039bdc9c7006e7158b
parent: e647395ad25e6ca08a81a78303c6f4209335d8cf
author: joe9 <joe9mail@gmail.com>
date: Thu Jul 29 23:13:22 EDT 2021

added missing conf.ialloc

conf.ialloc is the limit for kernel memory allocation (at interrupt time)

--- a/os/pc64/main.c	Thu Jul 29 08:25:43 2021
+++ b/os/pc64/main.c	Thu Jul 29 23:13:22 2021
@@ -286,6 +286,7 @@
 confinit(void)
 {
 	char *p;
+	int pcnt;
 	u64 maxmem;
 	int i;
 
@@ -293,13 +294,21 @@
 		maxmem = strtoull(p, 0, 0);
 	else
 		maxmem = 0;
+	if(p = getconf("*kernelpercent"))
+		pcnt = 100 - strtol(p, 0, 0);
+	else
+		pcnt = 0;
 
 	conf.npage = 0;
 	for(i=0; i<nelem(conf.mem); i++)
 		conf.npage += conf.mem[i].npage;
-	print("conf.npage %d\n", conf.npage);
 
+	if(pcnt < 10)
+		pcnt = 70;
+	conf.ialloc = (((conf.npage*(100-pcnt))/100)/2)*BY2PG;
 	conf.nproc = 100 + ((conf.npage*BY2PG)/MiB)*5;
+	print("conf.npage %d conf.ialloc %d conf.nproc %d\n",
+			conf.npage, conf.ialloc, conf.nproc);
 }
 
 void
--- a/os/port/allocb.c	Thu Jul 29 08:25:43 2021
+++ b/os/port/allocb.c	Thu Jul 29 23:13:22 2021
@@ -73,13 +73,13 @@
 	Block *b;
 
 	if(ialloc.bytes > conf.ialloc){
-		//print("iallocb: limited %lud/%lud\n", ialloc.bytes, conf.ialloc);
+		print("iallocb: limited %lud/%lud\n", ialloc.bytes, conf.ialloc);
 		return nil;
 	}
 
 	b = _allocb(size);
 	if(b == nil){
-		//print("iallocb: no memory %lud/%lud\n", ialloc.bytes, conf.ialloc);
+		print("iallocb: no memory %lud/%lud\n", ialloc.bytes, conf.ialloc);
 		return nil;
 	}
 	setmalloctag(b, getcallerpc(&size));
--- a/os/port/dis.c	Thu Jul 29 08:25:43 2021
+++ b/os/port/dis.c	Thu Jul 29 23:13:22 2021
@@ -288,16 +288,23 @@
 tellsomeone(Prog *p, char *buf)
 {
 	Osenv *o;
+	int ret;
 
 	DP("tellsomeone pid %d buf %s\n", p->pid, buf);
 	if(waserror())
 		return;
 	DP("tellsomeone after waserror() pid %d buf %s\n", p->pid, buf);
 	o = p->osenv;
-	if(o->childq != nil)
+	if(o->childq != nil){
 		qproduce(o->childq, buf, strlen(buf));
-	if(o->waitq != nil)
-		qproduce(o->waitq, buf, strlen(buf));
+		if(ret != strlen(buf))
+			print("tellsomeone qproduce on childq sent %d bytes out of %d\n", ret, strlen(buf));
+	}
+	if(o->waitq != nil){
+		ret = qproduce(o->waitq, buf, strlen(buf));
+		if(ret != strlen(buf))
+			print("tellsomeone qproduce on waitq sent %d bytes out of %d\n", ret, strlen(buf));
+	}
 	poperror();
 }