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;
|
||||
lock(lkp);
|
||||
if(lkp->ref <= 0)
|
||||
panic("fault: lkp->ref %d <= 0", lkp->ref);
|
||||
if(lkp->ref < 1)
|
||||
panic("fault: lkp->ref %d < 1", lkp->ref);
|
||||
if(lkp->image == &swapimage)
|
||||
ref = lkp->ref + swapcount(lkp->daddr);
|
||||
else
|
||||
|
@ -149,7 +149,6 @@ fixfault(Segment *s, ulong addr, int read, int doputmmu)
|
|||
if(ref == 1 && lkp->image){
|
||||
/* save a copy of the original for the image cache */
|
||||
duppage(lkp);
|
||||
|
||||
ref = lkp->ref;
|
||||
}
|
||||
unlock(lkp);
|
||||
|
@ -246,7 +245,7 @@ retry:
|
|||
}
|
||||
n = devtab[c->type]->read(c, kaddr, ask, daddr);
|
||||
if(n != ask)
|
||||
faulterror(Eioload, c, 0);
|
||||
error(Eioload);
|
||||
if(ask < BY2PG)
|
||||
memset(kaddr+ask, 0, BY2PG-ask);
|
||||
|
||||
|
|
|
@ -266,7 +266,7 @@ auxpage(void)
|
|||
|
||||
static int dupretries = 15000;
|
||||
|
||||
int
|
||||
void
|
||||
duppage(Page *p) /* Always call with p locked */
|
||||
{
|
||||
Page *np;
|
||||
|
@ -275,32 +275,27 @@ duppage(Page *p) /* Always call with p locked */
|
|||
|
||||
retries = 0;
|
||||
retry:
|
||||
/* don't dup shared page */
|
||||
if(p->ref != 1){
|
||||
print("duppage: p->ref %d != 1\n", p->ref);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* don't dup pages with no image */
|
||||
if(p->image == nil || p->image->notext){
|
||||
print("duppage: noimage\n");
|
||||
return 0;
|
||||
}
|
||||
/* don't dup pages that are shared or have no image */
|
||||
if(p->ref != 1 || p->image == nil || p->image->notext)
|
||||
return;
|
||||
|
||||
if(retries++ > dupretries){
|
||||
print("duppage %d, up %p\n", retries, up);
|
||||
dupretries += 100;
|
||||
if(dupretries > 100000)
|
||||
panic("duppage\n");
|
||||
panic("duppage");
|
||||
uncachepage(p);
|
||||
return 1;
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* normal lock ordering is to call
|
||||
* lock(&palloc) before lock(p).
|
||||
* 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)){
|
||||
unlock(p);
|
||||
|
@ -314,7 +309,7 @@ retry:
|
|||
if(palloc.freecount < swapalloc.highwater) {
|
||||
unlock(&palloc);
|
||||
uncachepage(p);
|
||||
return 1;
|
||||
return;
|
||||
}
|
||||
|
||||
color = getpgcolor(p->va);
|
||||
|
@ -326,7 +321,7 @@ retry:
|
|||
if(np == 0) {
|
||||
unlock(&palloc);
|
||||
uncachepage(p);
|
||||
return 1;
|
||||
return;
|
||||
}
|
||||
|
||||
pageunchain(np);
|
||||
|
@ -344,7 +339,7 @@ retry:
|
|||
*/
|
||||
lock(np);
|
||||
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);
|
||||
|
||||
/* Cache the new version */
|
||||
|
@ -355,8 +350,6 @@ retry:
|
|||
cachepage(np, p->image);
|
||||
unlock(np);
|
||||
uncachepage(p);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -82,7 +82,7 @@ void dumpaproc(Proc*);
|
|||
void dumpregs(Ureg*);
|
||||
void dumpstack(void);
|
||||
Fgrp* dupfgrp(Fgrp*);
|
||||
int duppage(Page*);
|
||||
void duppage(Page*);
|
||||
void dupswap(Page*);
|
||||
void edfinit(Proc*);
|
||||
char* edfadmit(Proc*);
|
||||
|
|
Loading…
Reference in New Issue