M port/fault.c => port/fault.c +13 -6
@@ 65,24 65,27 @@ fixfault(Segment *s, ulong addr, int read, int doputmmu)
switch(type) {
case SG_TEXT:
- if(pagedout(*pg)) /* No data - must demand load */
+ if(pagedout(*pg)) /* Demand load */
pio(s, addr, soff, pg);
mmuphys = PPN((*pg)->pa) | PTERONLY|PTEVALID;
(*pg)->modref = PG_REF;
break;
- case SG_SHARED:
+
+ case SG_SHARED: /* Zero fill on demand */
case SG_BSS:
case SG_STACK:
- /* Zero fill on demand */
if(*pg == 0) {
- if(new == 0 && (new = newpage(1, &s, addr)) && s == 0)
+ if(new == 0)
+ if(new = newpage(1, &s, addr))
+ if(s == 0)
return -1;
*pg = new;
new = 0;
}
/* NO break */
- case SG_DATA:
+
+ case SG_DATA: /* Demand load/page in/copy on write */
if(pagedout(*pg))
pio(s, addr, soff, pg);
@@ 99,7 102,9 @@ fixfault(Segment *s, ulong addr, int read, int doputmmu)
lockpage(lkp);
if(lkp->ref > 1) {
unlockpage(lkp);
- if(new == 0 && (new = newpage(0, &s, addr)) && s == 0)
+ if(new == 0)
+ if(new = newpage(0, &s, addr))
+ if(s == 0)
return -1;
*pg = new;
new = 0;
@@ 117,6 122,7 @@ fixfault(Segment *s, ulong addr, int read, int doputmmu)
mmuphys = PPN((*pg)->pa) | PTEWRITE|PTEVALID;
(*pg)->modref = PG_MOD|PG_REF;
break;
+
case SG_PHYSICAL:
if(*pg == 0)
*pg = (*s->pgalloc)(addr);
@@ 124,6 130,7 @@ fixfault(Segment *s, ulong addr, int read, int doputmmu)
mmuphys = PPN((*pg)->pa) | PTEWRITE|PTEUNCACHED|PTEVALID;
(*pg)->modref = PG_MOD|PG_REF;
break;
+
default:
panic("fault");
}
M port/stil.c => port/stil.c +2 -2
@@ 258,8 258,8 @@ ilrcvmsg(Ipconv *ipc, Block *bp)
if(ilcksum && ptcl_csum(bp, IL_EHSIZE, illen) != 0) {
st = (ih->iltype < 0 || ih->iltype > Ilclose) ? "?" : iltype[ih->iltype];
- print("il: cksum error, pkt(%s id %lud ack %lud %d.%d.%d.%d/%d->%d)\n",
- st, nhgetl(ih->ilid), nhgetl(ih->ilack), fmtaddr(dst), sp, dp);
+/* print("il: cksum error, pkt(%s id %lud ack %lud %d.%d.%d.%d/%d->%d)\n",
+ st, nhgetl(ih->ilid), nhgetl(ih->ilack), fmtaddr(dst), sp, dp); /**/
goto drop;
}
M port/swap.c => port/swap.c +38 -22
@@ 15,13 15,14 @@ int canflush(Proc *p, Segment*);
enum
{
- Maxpages = 300, /* Max number of pageouts per segment pass */
+ Maxpages = 100, /* Max number of pageouts per segment pass */
};
Image swapimage;
static int swopen;
Page *iolist[Maxpages];
int ioptr;
+int scavenge;
void
swapinit(void)
@@ 144,9 145,10 @@ pager(void *junk)
void
pageout(Proc *p, Segment *s)
{
- Pte **sm, **endsm;
- Page **pg, **epg;
+ Pte **sm, **endsm, *l;
+ Page **pg, *entry;
int type;
+extern char *sname[];
if(!canqlock(&s->lk)) /* We cannot afford to wait, we will surely deadlock */
return;
@@ 163,26 165,36 @@ pageout(Proc *p, Segment *s)
return;
}
+ scavenge = 0;
+
/* Pass through the pte tables looking for memory pages to swap out */
type = s->type&SG_TYPE;
endsm = &s->map[SEGMAPSIZE];
- for(sm = s->map; sm < endsm && ioptr < Maxpages; sm++)
- if(*sm) {
- pg = (*sm)->pages;
- for(epg = &pg[PTEPERTAB]; pg < epg && ioptr < Maxpages; pg++)
- if(!pagedout(*pg)) {
- if((*pg)->modref & PG_REF)
- (*pg)->modref &= ~PG_REF;
- else
- if(pagepte(type, s, pg) == 0)
- break;
- }
- }
+ for(sm = s->map; sm < endsm; sm++) {
+ l = *sm;
+ if(l == 0)
+ continue;
+ for(pg = l->first; pg < l->last; pg++) {
+ entry = *pg;
+ if(pagedout(entry))
+ continue;
+ if(entry->modref & PG_REF) {
+ print("MODREF\n");
+ entry->modref &= ~PG_REF;
+ }
+ else
+ pagepte(type, s, pg);
+ if(ioptr >= Maxpages)
+ goto out;
+ }
+ }
+out:
+
+ print("%s: %d: type %s %d pages\n", p->text, p->pid, sname[type], scavenge);
poperror();
qunlock(&s->lk);
putseg(s);
-
wakeup(&palloc.r);
}
@@ 206,12 218,16 @@ canflush(Proc *p, Segment *s)
*/
p = proctab(0);
ep = &p[conf.nproc];
- for(; p < ep; p++)
- if(p->state != Dead)
+ while(p < ep) {
+ if(p->state != Dead) {
for(i = 0; i < NSEG; i++)
if(p->seg[i] == s)
if(!canpage(p))
return 0;
+ }
+ p++;
+ }
+
return 1;
}
@@ 226,12 242,14 @@ pagepte(int type, Segment *s, Page **pg)
KMap *k;
outp = *pg;
-
+print("outp: %lux\n", *pg);
switch(type) {
case SG_TEXT: /* Revert to demand load */
putpage(outp);
*pg = 0;
+ scavenge++;
break;
+
case SG_DATA:
case SG_BSS:
case SG_STACK:
@@ 253,6 271,7 @@ pagepte(int type, Segment *s, Page **pg)
/* Add me to IO transaction list */
iolist[ioptr++] = outp;
+ scavenge++;
}
return 1;
@@ 286,9 305,6 @@ executeio(void)
kaddr = (char*)VA(k);
qlock(&c->wrl);
- /* BUG: what to do ? Nobody to tell, nowhere to go: open to suggestions
- * the problem is I do not know whose page this is.
- */
if(waserror())
panic("executeio: page out I/O error");
M power/boot.c => power/boot.c +2 -0
@@ 157,6 157,8 @@ hotdial(char *arg)
char srvdir[100];
Waitmsg m;
+ return open("#H/hotrod", ORDWR);
+
/*
* The killer: gotta get a hotrodboot running, so dial up
* on datakit and load it.