kernel: return error from sysrfork instead of waiting and retrying

The old strategy of wait and retry doesnt seem to
work very well as it keeps all the forking parents
stuck waiting in the kernel worsening the situation.

The idea with this change is to have rfork() return
error quickly; and without whining; as most callers
would just react with a sysfatal() which might be
better for surviving this.
This commit is contained in:
cinap_lenrek 2021-10-12 11:30:42 +00:00
parent b3c3c3e63d
commit 03d870e028
3 changed files with 8 additions and 12 deletions

View file

@ -268,7 +268,7 @@ resrcwait(char *reason)
char *p;
if(up == nil)
panic("resrcwait");
panic("resrcwait: %s", reason);
p = up->psstate;
if(reason != nil) {

View file

@ -630,19 +630,13 @@ canpage(Proc *p)
Proc*
newproc(void)
{
char msg[64];
Proc *p;
lock(&procalloc);
for(;;) {
if((p = procalloc.free) != nil)
break;
snprint(msg, sizeof msg, "no procs; %s forking",
up != nil ? up->text: "kernel");
p = procalloc.free;
if(p == nil){
unlock(&procalloc);
resrcwait(msg);
lock(&procalloc);
return nil;
}
procalloc.free = p->qnext;
p->qnext = nil;
@ -1409,7 +1403,8 @@ kproc(char *name, void (*func)(void *), void *arg)
static Pgrp *kpgrp;
Proc *p;
p = newproc();
while((p = newproc()) == nil)
resrcwait("no procs for kproc");
qlock(&p->debug);
if(up != nil){

View file

@ -84,7 +84,8 @@ sysrfork(va_list list)
return 0;
}
p = newproc();
if((p = newproc()) == nil)
error("no procs");
qlock(&p->debug);