# HG changeset patch # User Francisco J Ballesteros # Date 1316367839 -7200 # Node ID 6320eda391c778a5b5608dfa448e00ac2c659aab # Parent 611b24491ffcbcc98278d16fa6bdc96649c040ae active fix: mask of active cores removed in favor of a counter of the number of active machs. m->online for each one tells if it's active or not. This removes the limit set by the number of bits in the previous bitmask. I tested the kernel still boots ok. R=nix-dev, rminnich, nemo CC=nix-dev http://codereview.appspot.com/5061041 diff -r 611b24491ffc -r 6320eda391c7 sys/src/nix/k10/dat.h --- a/sys/src/nix/k10/dat.h Sun Sep 18 17:44:50 2011 +0200 +++ b/sys/src/nix/k10/dat.h Sun Sep 18 19:43:59 2011 +0200 @@ -351,9 +351,10 @@ struct { Lock; - uint machs; /* bitmap of active CPUs (must go) */ - int exiting; /* shutdown */ - int ispanic; /* shutdown in response to a panic */ + int nonline; /* # of active CPUs */ + int nbooting; /* # of CPUs waiting for the bTC to go */ + int exiting; /* shutdown */ + int ispanic; /* shutdown in response to a panic */ int thunderbirdsarego; /* lets the added processors continue */ }active; diff -r 611b24491ffc -r 6320eda391c7 sys/src/nix/k10/main.c --- a/sys/src/nix/k10/main.c Sun Sep 18 17:44:50 2011 +0200 +++ b/sys/src/nix/k10/main.c Sun Sep 18 19:43:59 2011 +0200 @@ -67,8 +67,6 @@ vflag = dbgflg['v']; } -static Ref squids; - void squidboy(int apicno) { @@ -121,8 +119,9 @@ switch(m->nixtype){ case NIXAC: acmmuswitch(); - decref(&squids); acinit(); + adec(&active.nbooting); +// ainc(&active.nonline); acsched(); panic("squidboy"); break; @@ -134,14 +133,9 @@ */ vsvminit(MACHSTKSZ, NIXTC); - decref(&squids); - /* - * Caution: no clock sync. - */ timersinit(); - lock(&active); - active.machs |= 1<machno; - unlock(&active); + adec(&active.nbooting); + ainc(&active.nonline); ndnr(); schedinit(); break; @@ -172,18 +166,19 @@ print("bootcore: all cores done\n"); } +/* + * Rendezvous with other cores. Set roles for those that came + * up online, and wait until they are initialized. + * We assume other processors that could boot had time to + * set online to 1 by now. + */ static void nixsquids(void) { Mach *mp; int i; + uvlong now, start; - /* - * We assume other processors that could boot had time to - * set online to 1 by now. - * Note that this won't work for a huge number of cores, because - * of the bitmap in active.machs. The bitmap must go. - */ for(i = 1; i < MACHMAX; i++) if((mp = sys->machptr[i]) != nil && mp->online != 0){ /* @@ -194,11 +189,17 @@ mp->icc->fn = nil; if(i < 4) mp->nixtype = NIXTC; - incref(&squids); + ainc(&active.nbooting); } active.thunderbirdsarego = 1; - while(squids.ref > 0) + start = fastticks2us(fastticks(nil)); + do{ + now = fastticks2us(fastticks(nil)); + }while(active.nbooting > 0 && now - start < 1000000) ; + if(active.nbooting > 0) + print("cpu0: %d cores couldn't start\n", active.nbooting); + active.nbooting = 0; } void @@ -239,7 +240,9 @@ m->stack = PTR2UINT(sys->machstk); m->vsvm = sys->vsvmpage; up = nil; - + active.nonline = 1; + active.exiting = 0; + active.nbooting = 0; asminit(); multiboot(ax, bx, 0); options(oargc, oargv); @@ -259,8 +262,6 @@ vsvminit(MACHSTKSZ, NIXTC); conf.nmach = 1; - active.machs = 1; - active.exiting = 0; fmtinit(); print("\nNIX with 2M pages\n"); @@ -496,11 +497,11 @@ lock(&active); if(ispanic) active.ispanic = ispanic; - else if(m->machno == 0 && (active.machs & (1<machno)) == 0) + else if(m->machno == 0 && m->online == 0) active.ispanic = 0; - once = active.machs & (1<machno); + once = m->online; m->online = 0; - active.machs &= ~(1<machno); + adec(&active.nonline); active.exiting = 1; unlock(&active); @@ -509,7 +510,7 @@ spllo(); for(ms = 5*1000; ms > 0; ms -= TK2MS(2)){ delay(TK2MS(2)); - if(active.machs == 0 && consactive() == 0) + if(active.nonline == 0 && consactive() == 0) break; } diff -r 611b24491ffc -r 6320eda391c7 sys/src/nix/k10/mkfile --- a/sys/src/nix/k10/mkfile Sun Sep 18 17:44:50 2011 +0200 +++ b/sys/src/nix/k10/mkfile Sun Sep 18 19:43:59 2011 +0200 @@ -1,6 +1,10 @@ CONF=k8cpu CONFLIST=k8aoe k8cpu k8root k8cpufs +# override with the list of paths where to put extra +# copies of the kernel. for each word $w in OTHERCOPIES, +# the kernel is copied to $w/$objtype/... +OTHERCOPIES='' objtype=amd64 $p$CONF.gz -install:V: $p$CONF $p$CONF.gz - cp $p$CONF /$objtype/$p$CONF - cp $p$CONF.gz /$objtype/$p$CONF.gz +install:QV: $p$CONF $p$CONF.gz + for(d in '' $OTHERCOPIES){ + if(test -d $d/$objtype){ + cp $p$CONF $d/$objtype/$p$CONF + cp $p$CONF.gz $d/$objtype/$p$CONF.gz + ls -l $d/$objtype/$p$CONF $d/$objtype/$p$CONF.gz + } + } + echo done init.out: init9.$O initcode.$O /$objtype/lib/libc.a $LD -l -R1 -s -o init.out init9.$O initcode.$O -lc diff -r 611b24491ffc -r 6320eda391c7 sys/src/nix/port/portclock.c --- a/sys/src/nix/port/portclock.c Sun Sep 18 17:44:50 2011 +0200 +++ b/sys/src/nix/port/portclock.c Sun Sep 18 19:43:59 2011 +0200 @@ -163,7 +163,7 @@ if(kproftimer != nil) kproftimer(pc); - if((active.machs&(1<machno)) == 0) + if(m->online == 0) return; if(active.exiting) {