various port bits. - make taslock and tiklock compatable with MACHP() stuff. (ick!) - don't claim races are ok! - mach not cpu etc. Reference: /n/atom/patch/applied/nixportbits Date: Thu Jun 12 04:02:42 CES 2014 Signed-off-by: quanstro@quanstro.net --- /sys/src/nix/port/pager.c Thu Jun 12 04:01:50 2014 +++ /sys/src/nix/port/pager.c Thu Jun 12 04:01:52 2014 @@ -62,7 +62,7 @@ s->ref++; unlock(s); - /* Now we must do hardwork to ensure all processes which have tlb + /* Now we must do hard work to ensure all processes which have tlb * entries for this segment will be flushed if we succeed in paging it out */ for(x = 0; (p = psincref(x)) != nil; x++){ @@ -135,31 +135,22 @@ return n; } -static void +static int pageouttext(int pgszi, int color) { - Proc *p; Pgsza *pa; int i, n, np, x; Segment *s; - int prepaged; USED(color); pa = &pga.pgsza[pgszi]; n = x = 0; - prepaged = 0; - /* - * Try first to steal text pages from non-prepaged processes, - * then from anyone. - */ -Again: do{ if((p = psincref(x)) == nil) break; np = 0; - if(/*p->prepagemem == 0 ||*/ prepaged != 0) if(p->state != Dead && p->noswap == 0 && canqlock(&p->seglock)){ for(i = 0; i < NSEG; i++){ if((s = p->seg[i]) == nil) @@ -179,8 +170,7 @@ x++; }while(pa->freecount < Minpages); - if(pa->freecount < Minpages && prepaged++ == 0) - goto Again; + return n; } static void --- /sys/src/nix/port/proc.c Thu Jun 12 04:01:55 2014 +++ /sys/src/nix/port/proc.c Thu Jun 12 04:01:58 2014 @@ -46,7 +46,6 @@ static void rebalance(void); int schedsteals = 1; -int scheddonates = 0; char *statename[Nprocstate] = { /* BUG: generate automatically */ @@ -73,7 +72,7 @@ color = machcolor(mp); if(color < 0){ - iprint("cpu%d: unknown color\n", mp->machno); + iprint("mach%d: unknown color\n", mp->machno); color = 0; } mp->sch = &run[color%Nsched]; @@ -162,7 +161,7 @@ p = &dummy; if(p < up->kstack + 4*KiB || p > up->kstack + KSTACK) - panic("cpu%d: up->stack bounds %s:%s %#p %#p", + panic("mach%d: up->stack bounds %s:%s %#p %#p", m->machno, up->text, statename[up->state], p, up->kstack); } @@ -178,7 +177,7 @@ sch = m->sch; if(m->ilockdepth) - panic("cpu%d: ilockdepth %d, last lock %#p at %#p, sched called from %#p", + panic("mach%d: ilockdepth %d, last lock %#p at %#p, sched called from %#p", m->machno, m->ilockdepth, up? up->lastilock: nil, --- /sys/src/nix/port/devusb.c Thu Jun 12 04:02:01 2014 +++ /sys/src/nix/port/devusb.c Thu Jun 12 04:02:04 2014 @@ -294,7 +294,7 @@ else s = seprint(s, se, " idle"); if(all){ - s = seprint(s, se, " load %uld", ep->load); + s = seprint(s, se, " load %ud", ep->load); s = seprint(s, se, " ref %d addr %#p", ep->ref, ep); s = seprint(s, se, " idx %d", ep->idx); if(ep->name != nil) --- /sys/src/nix/port/usb.h Thu Jun 12 04:02:05 2014 +++ /sys/src/nix/port/usb.h Thu Jun 12 04:02:07 2014 @@ -160,7 +160,7 @@ char* info; /* for humans to read */ long maxpkt; /* maximum packet size */ int ttype; /* tranfer type */ - ulong load; /* in µs, for a fransfer of maxpkt bytes */ + uint load; /* in µs, for a fransfer of maxpkt bytes */ void* aux; /* for controller specific info */ int rhrepl; /* fake root hub replies */ int toggle[2]; /* saved toggles (while ep is not in use) */ --- /sys/src/nix/port/tiklock.c Thu Jun 12 04:02:09 2014 +++ /sys/src/nix/port/tiklock.c Thu Jun 12 04:02:10 2014 @@ -149,7 +149,7 @@ break; if(!g->shown){ g->shown = 0; - iprint("cpu%d: %d: l=%#p lpc=%#p pc=%#p n=%ud ok=%d\n", + iprint("mach%d: %d: l=%#p lpc=%#p pc=%#p n=%ud ok=%d\n", machno, i, g->l, g->lpc, g->pc, g->n, g->ok); } p++; @@ -172,7 +172,7 @@ dumpaproc(p); } showlockloops(); - panic("cpu%d: %s lock %#p key %#p pc %#p proc %ud held by pc %#p proc %ud\n", + panic("mach%d: %s lock %#p key %#p pc %#p proc %ud held by pc %#p proc %ud\n", m->machno, why, l, tqkey(l), pc, up->pid, l->pc, p? p->pid: 0); } @@ -229,7 +229,7 @@ mg->total++; splx(s); if(islo() && up != nil) - print("cpu%d: pid %d slow locks: %d\n", m->machno, up->pid, glares[m->machno].total); + print("mach%d: pid %d slow locks: %d\n", m->machno, up->pid, glares[m->machno].total); if(lockdebug) lockcrash(l, pc, "stuck"); return g; --- /sys/src/nix/port/taslock.c Thu Jun 12 04:02:13 2014 +++ /sys/src/nix/port/taslock.c Thu Jun 12 04:02:14 2014 @@ -49,7 +49,7 @@ l->pc = pc; l->p = up; l->isilock = 0; - l->m = m; + l->m = MACHP(m->machno); if(LOCKCYCLES) cycles(&l->lockcycles); @@ -87,7 +87,7 @@ l->pc = pc; l->p = up; l->isilock = 0; - l->m = m; + l->m = MACHP(m->machno); if(LOCKCYCLES) cycles(&l->lockcycles); if(l != &waitstatslk) @@ -107,6 +107,8 @@ uvlong t0; pc = getcallerpc(&l); + if(l == nil) + panic("ilock nil %#p", pc); lockstats.locks++; pl = splhi(); @@ -159,7 +161,7 @@ up->lastlock = l; l->pc = getcallerpc(&l); l->p = up; - l->m = m; + l->m = MACHP(m->machno); l->isilock = 0; if(LOCKCYCLES) cycles(&l->lockcycles); --- /sys/src/nix/port/sysseg.c Thu Jun 12 04:02:16 2014 +++ /sys/src/nix/port/sysseg.c Thu Jun 12 04:02:17 2014 @@ -206,7 +206,7 @@ } static uintptr -segattach(Proc* p, int attr, char* name, uintptr va, usize len) +segattach(Proc* p, int attr, char* name, uintptr va, uintptr len) { int sno; uintmem pgsz; /* should be usize */ --- /sys/src/nix/port/devws.c Thu Jun 12 04:02:19 2014 +++ /sys/src/nix/port/devws.c Thu Jun 12 04:02:20 2014 @@ -55,8 +55,8 @@ if((s = waitstats.stat + i)->pc == pc){ ainc(&s->count); if(w > s->maxwait) - s->maxwait = w; /* race but ok */ - s->cumwait += w; /* race but ok */ + s->maxwait = w; /* race */ + s->cumwait += w; /* race */ return; } @@ -68,7 +68,7 @@ if((s = waitstats.stat + i)->pc == pc){ ainc(&s->count); if(w > s->maxwait) - s->maxwait = w; /* race but ok */ + s->maxwait = w; /* race */ s->cumwait += w; unlock(&waitstatslk); return; @@ -89,15 +89,6 @@ unlock(&waitstatslk); } - - -/* - * reported times can be translated to a more readable format by - * using something like: - * awk '{printf("print(\"%s: %s times; %s us worst; %s ws total\");\nsrc(%s)\n", - * $1, $3, $4, $5, $2); }' | acid ../k10/9cpu - * on the wsdata file, after doing a sort +2nr on it. - */ enum{ WSdirqid,