From 2450bfa0a262b6d9b3db49dca73f63a4903d4756 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Mon, 2 Mar 1992 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1992-03-02 --- port/fault.c | 19 +++++++++++------ port/stil.c | 4 ++-- port/swap.c | 60 +++++++++++++++++++++++++++++++++------------------- power/boot.c | 2 ++ 4 files changed, 55 insertions(+), 30 deletions(-) diff --git a/port/fault.c b/port/fault.c index b2b8303cbee020df56958bf34514da7daa0c7568..32399d2a04001a55b9b95dadc75c262d201dcdb7 100644 --- a/port/fault.c +++ b/port/fault.c @@ -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"); } diff --git a/port/stil.c b/port/stil.c index 2b898a4bf27b7d86b7b9cd04b30d47a5138ce426..f71bc3247b29637e8fe8e32cf3e895ae2968e408 100644 --- a/port/stil.c +++ b/port/stil.c @@ -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; } diff --git a/port/swap.c b/port/swap.c index 4a168de3dfe02b4cdd3dfcb2b2796557dceaccd1..7828e1e16823e5af8eafbfbab22a0f94440f00ab 100644 --- a/port/swap.c +++ b/port/swap.c @@ -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"); diff --git a/power/boot.c b/power/boot.c index a1b14132e27e001eb3faff83713a76e1e8924621..26917f53b9c54b46fcda554a4a9b8044949ae63c 100644 --- a/power/boot.c +++ b/power/boot.c @@ -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.