remove the union. just use Mpl pl. Reference: /n/atom/patch/applied/nixmcscleanup Date: Sun Jun 8 10:17:50 CES 2014 Signed-off-by: quanstro@quanstro.net --- /sys/src/nix/port/mcslock.c Sun Jun 8 10:17:37 2014 +++ /sys/src/nix/port/mcslock.c Sun Jun 8 10:17:37 2014 @@ -21,7 +21,7 @@ ql->locked = 1; sfence(); /* ensure reader sees updated value */ pred->next = ql; - while(monmwait32(&ql->locked, 1) == 1) + while(monmwait(&ql->locked, 1) == 1) {} } } @@ -146,14 +146,14 @@ ilock(Lock *l) { uintptr pc; - Mreg s; + Mpl pl; LockEntry *ql; pc = getcallerpc(&l); - s = splhi(); + pl = splhi(); ql = allocle(l, pc); ql->isilock = 1; - ql->sr = s; + ql->pl = pl; /* the old taslock code would splx(s) to allow interrupts while waiting (if not nested) */ mcslock(l, ql); l->e = ql; @@ -166,7 +166,7 @@ void iunlock(Lock *l) { - Mreg s; + Mpl pl; LockEntry *ql; if(islo()) @@ -175,16 +175,16 @@ if(!ql->isilock) panic("iunlock of lock: pc %#p\n", getcallerpc(&l)); if(ql->m != m){ - panic("iunlock by cpu%d, locked by cpu%d: pc %#p\n", + panic("iunlock by mach%d, locked by mach%d: pc %#p\n", m->machno, ql->m->machno, getcallerpc(&l)); } mcsunlock(l, ql); - s = ql->sr; + pl = ql->pl; ql->used = nil; m->ilockdepth--; if(up != nil) up->lastilock = nil; - splx(s); + splx(pl); } int --- /sys/src/nix/port/portdat.h Sun Jun 8 10:17:37 2014 +++ /sys/src/nix/port/portdat.h Sun Jun 8 10:17:37 2014 @@ -110,10 +110,7 @@ uint locked; Lock* used; int isilock; - union { /* GAK */ - Mpl pl; - Mreg sr; - }; + Mpl pl; /* for debugging */ uintptr pc; Proc* p; @@ -705,7 +702,8 @@ uint delayedscheds; /* statistics */ uint skipscheds; uint preempts; - uint balancetime; + uint loop; + ulong balancetime; Schedq runq[Nrq]; uint runvec; int nmach; /* # of cores with this color */ @@ -1082,6 +1080,7 @@ extern char* statename[]; extern Lockstats lockstats; extern QLockstats qlockstats; +extern Waitstats waitstats; extern struct { char* n; void (*f)(Ar0*, va_list);