kernel: remove duppage debug, add comments, cleanup
parent
083612b34e
commit
77c21a062c
|
@ -140,8 +140,8 @@ fixfault(Segment *s, ulong addr, int read, int doputmmu)
|
||||||
|
|
||||||
lkp = *pg;
|
lkp = *pg;
|
||||||
lock(lkp);
|
lock(lkp);
|
||||||
if(lkp->ref <= 0)
|
if(lkp->ref < 1)
|
||||||
panic("fault: lkp->ref %d <= 0", lkp->ref);
|
panic("fault: lkp->ref %d < 1", lkp->ref);
|
||||||
if(lkp->image == &swapimage)
|
if(lkp->image == &swapimage)
|
||||||
ref = lkp->ref + swapcount(lkp->daddr);
|
ref = lkp->ref + swapcount(lkp->daddr);
|
||||||
else
|
else
|
||||||
|
@ -149,7 +149,6 @@ fixfault(Segment *s, ulong addr, int read, int doputmmu)
|
||||||
if(ref == 1 && lkp->image){
|
if(ref == 1 && lkp->image){
|
||||||
/* save a copy of the original for the image cache */
|
/* save a copy of the original for the image cache */
|
||||||
duppage(lkp);
|
duppage(lkp);
|
||||||
|
|
||||||
ref = lkp->ref;
|
ref = lkp->ref;
|
||||||
}
|
}
|
||||||
unlock(lkp);
|
unlock(lkp);
|
||||||
|
@ -246,7 +245,7 @@ retry:
|
||||||
}
|
}
|
||||||
n = devtab[c->type]->read(c, kaddr, ask, daddr);
|
n = devtab[c->type]->read(c, kaddr, ask, daddr);
|
||||||
if(n != ask)
|
if(n != ask)
|
||||||
faulterror(Eioload, c, 0);
|
error(Eioload);
|
||||||
if(ask < BY2PG)
|
if(ask < BY2PG)
|
||||||
memset(kaddr+ask, 0, BY2PG-ask);
|
memset(kaddr+ask, 0, BY2PG-ask);
|
||||||
|
|
||||||
|
|
|
@ -266,7 +266,7 @@ auxpage(void)
|
||||||
|
|
||||||
static int dupretries = 15000;
|
static int dupretries = 15000;
|
||||||
|
|
||||||
int
|
void
|
||||||
duppage(Page *p) /* Always call with p locked */
|
duppage(Page *p) /* Always call with p locked */
|
||||||
{
|
{
|
||||||
Page *np;
|
Page *np;
|
||||||
|
@ -275,32 +275,27 @@ duppage(Page *p) /* Always call with p locked */
|
||||||
|
|
||||||
retries = 0;
|
retries = 0;
|
||||||
retry:
|
retry:
|
||||||
/* don't dup shared page */
|
/* don't dup pages that are shared or have no image */
|
||||||
if(p->ref != 1){
|
if(p->ref != 1 || p->image == nil || p->image->notext)
|
||||||
print("duppage: p->ref %d != 1\n", p->ref);
|
return;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* don't dup pages with no image */
|
|
||||||
if(p->image == nil || p->image->notext){
|
|
||||||
print("duppage: noimage\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(retries++ > dupretries){
|
if(retries++ > dupretries){
|
||||||
print("duppage %d, up %p\n", retries, up);
|
print("duppage %d, up %p\n", retries, up);
|
||||||
dupretries += 100;
|
dupretries += 100;
|
||||||
if(dupretries > 100000)
|
if(dupretries > 100000)
|
||||||
panic("duppage\n");
|
panic("duppage");
|
||||||
uncachepage(p);
|
uncachepage(p);
|
||||||
return 1;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* normal lock ordering is to call
|
* normal lock ordering is to call
|
||||||
* lock(&palloc) before lock(p).
|
* lock(&palloc) before lock(p).
|
||||||
* To avoid deadlock, we have to drop
|
* To avoid deadlock, we have to drop
|
||||||
* our locks and try again.
|
* our locks and try again. as the page
|
||||||
|
* is from the image cache, this might
|
||||||
|
* let someone else come in and grab it
|
||||||
|
* so we check page ref above.
|
||||||
*/
|
*/
|
||||||
if(!canlock(&palloc)){
|
if(!canlock(&palloc)){
|
||||||
unlock(p);
|
unlock(p);
|
||||||
|
@ -314,7 +309,7 @@ retry:
|
||||||
if(palloc.freecount < swapalloc.highwater) {
|
if(palloc.freecount < swapalloc.highwater) {
|
||||||
unlock(&palloc);
|
unlock(&palloc);
|
||||||
uncachepage(p);
|
uncachepage(p);
|
||||||
return 1;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
color = getpgcolor(p->va);
|
color = getpgcolor(p->va);
|
||||||
|
@ -326,7 +321,7 @@ retry:
|
||||||
if(np == 0) {
|
if(np == 0) {
|
||||||
unlock(&palloc);
|
unlock(&palloc);
|
||||||
uncachepage(p);
|
uncachepage(p);
|
||||||
return 1;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pageunchain(np);
|
pageunchain(np);
|
||||||
|
@ -344,7 +339,7 @@ retry:
|
||||||
*/
|
*/
|
||||||
lock(np);
|
lock(np);
|
||||||
if(np->ref != 0) /* should never happen */
|
if(np->ref != 0) /* should never happen */
|
||||||
panic("duppage: np->ref %d != 0\n", np->ref);
|
panic("duppage: np->ref %d != 0", np->ref);
|
||||||
unlock(&palloc);
|
unlock(&palloc);
|
||||||
|
|
||||||
/* Cache the new version */
|
/* Cache the new version */
|
||||||
|
@ -355,8 +350,6 @@ retry:
|
||||||
cachepage(np, p->image);
|
cachepage(np, p->image);
|
||||||
unlock(np);
|
unlock(np);
|
||||||
uncachepage(p);
|
uncachepage(p);
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -82,7 +82,7 @@ void dumpaproc(Proc*);
|
||||||
void dumpregs(Ureg*);
|
void dumpregs(Ureg*);
|
||||||
void dumpstack(void);
|
void dumpstack(void);
|
||||||
Fgrp* dupfgrp(Fgrp*);
|
Fgrp* dupfgrp(Fgrp*);
|
||||||
int duppage(Page*);
|
void duppage(Page*);
|
||||||
void dupswap(Page*);
|
void dupswap(Page*);
|
||||||
void edfinit(Proc*);
|
void edfinit(Proc*);
|
||||||
char* edfadmit(Proc*);
|
char* edfadmit(Proc*);
|
||||||
|
|
Loading…
Reference in New Issue