kernel: change active.machs from bitmap to char array to support up to 64 cpus on pc64

This commit is contained in:
cinap_lenrek 2016-01-05 05:32:40 +01:00
parent dd8908cff0
commit 41383ad012
38 changed files with 56 additions and 60 deletions

View file

@ -184,8 +184,8 @@ struct Mach
struct
{
Lock;
short machs;
short exiting;
char machs[MAXMACH];
int exiting;
}active;
/*

View file

@ -156,7 +156,7 @@ machinit(void)
m->machno = n;
active.exiting = 0;
active.machs = 1;
active.machs[0] = 1;
cpu = (Hwcpu*) ((ulong)hwrpb + hwrpb->cpuoff + n*hwrpb->cpulen);
cpu->state &= ~Cpubootinprog;

View file

@ -261,8 +261,8 @@ intr(Ureg *ur)
*/
iprint("cpu%d: spurious interrupt %d, last %d",
m->machno, vno-VectorPIC, m->lastintr);
for(i = 0; i < 32; i++){
if(!(active.machs & (1<<i)))
for(i = 0; i < MAXMACH; i++){
if(active.machs[i] == 0)
continue;
mach = MACHP(i);
if(m->machno == mach->machno)

View file

@ -223,7 +223,7 @@ typedef void KMap;
struct
{
Lock;
int machs; /* bitmap of active CPUs */
char machs[MAXMACH]; /* active CPUs */
int exiting; /* shutdown */
}active;

View file

@ -199,7 +199,7 @@ machinit(void)
conf.nmach = 1;
active.machs = 1;
active.machs[0] = 1;
active.exiting = 0;
up = nil;

View file

@ -178,7 +178,7 @@ typedef void KMap;
struct
{
Lock;
int machs; /* bitmap of active CPUs */
char machs[MAXMACH]; /* active CPUs */
int exiting; /* shutdown */
}active;

View file

@ -26,7 +26,7 @@ main(void)
memset(m, 0, sizeof(Mach));
m->ticks = 1;
active.machs = 1;
active.machs[0] = 1;
rs232power(1);
quotefmtinstall();

View file

@ -194,7 +194,7 @@ typedef void KMap;
struct
{
Lock;
int machs; /* bitmap of active CPUs */
char machs[MAXMACH]; /* active CPUs */
int exiting; /* shutdown */
}active;

View file

@ -349,7 +349,7 @@ machinit(void)
conf.nmach = 1;
active.machs = 1;
active.machs[0] = 1;
active.exiting = 0;
up = nil;

View file

@ -181,8 +181,8 @@ struct Mach
struct
{
Lock;
short machs;
short exiting;
char machs[MAXMACH];
int exiting;
}active;
/*

View file

@ -59,7 +59,7 @@ machinit(void)
/* turn on caches */
puthid0(gethid0() | BIT(16) | BIT(17));
active.machs = 1;
active.machs[0] = 1;
active.exiting = 0;
}

View file

@ -216,7 +216,7 @@ typedef void KMap;
struct
{
Lock;
int machs; /* bitmap of active CPUs */
char machs[MAXMACH]; /* active CPUs */
int exiting; /* shutdown */
}active;

View file

@ -295,7 +295,7 @@ machinit(void)
conf.nmach = 1;
active.machs = 1;
active.machs[0] = 1;
active.exiting = 0;
up = nil;

View file

@ -270,7 +270,7 @@ void kunmap(KMap*);
struct
{
Lock;
int machs; /* bitmap of active CPUs */
char machs[MAXMACH]; /* active CPUs */
int exiting; /* shutdown */
int thunderbirdsarego; /* lets the added processors continue to schedinit */
}active;

View file

@ -181,7 +181,7 @@ mach0init(void)
machinit();
active.machs = 1;
active.machs[0] = 1;
active.exiting = 0;
}

View file

@ -685,7 +685,7 @@ vunmap(void *v, int size)
for(i=0; i<conf.nmach; i++){
nm = MACHP(i);
if(nm != m)
while((active.machs&(1<<nm->machno)) && nm->flushmmu)
while(active.machs[nm->machno] && nm->flushmmu)
;
}
}

View file

@ -198,6 +198,8 @@ mpinit(void)
for(i=0; i<nelem(mpapic); i++){
if((apic = mpapic[i]) == nil)
continue;
if(apic->machno >= MAXMACH)
continue;
if(ncpu <= 1)
break;
if((apic->flags & (PcmpBP|PcmpEN)) == PcmpEN){
@ -574,7 +576,7 @@ mpshutdown(void)
for(;;) idle();
}
print("mpshutdown: active = %#8.8ux\n", active.machs);
print("mpshutdown\n");
delay(1000);
splhi();

View file

@ -30,7 +30,7 @@ squidboy(Apic* apic)
fpoff();
lock(&active);
active.machs |= 1<<m->machno;
active.machs[m->machno] = 1;
unlock(&active);
while(!active.thunderbirdsarego)

View file

@ -400,8 +400,8 @@ trap(Ureg* ureg)
if(0)print("cpu%d: spurious interrupt %d, last %d\n",
m->machno, vno, m->lastintr);
if(0)if(conf.nmach > 1){
for(i = 0; i < 32; i++){
if(!(active.machs & (1<<i)))
for(i = 0; i < MAXMACH; i++){
if(active.machs[i] == 0)
continue;
mach = MACHP(i);
if(m->machno == mach->machno)

View file

@ -233,7 +233,7 @@ typedef void KMap;
struct
{
Lock;
int machs; /* bitmap of active CPUs */
char machs[MAXMACH]; /* bitmap of active CPUs */
int exiting; /* shutdown */
int thunderbirdsarego; /* lets the added processors continue to schedinit */
}active;

View file

@ -326,7 +326,7 @@ mach0init(void)
machinit();
active.machs = 1;
active.machs[0] = 1;
active.exiting = 0;
}

View file

@ -28,7 +28,7 @@
#define BLOCKALIGN 8
#define FPalign 16
#define MAXMACH 32 /* max # cpus system can run */
#define MAXMACH 64 /* max # cpus system can run */
#define KSTACK (16*KiB) /* Size of Proc kernel stack */

View file

@ -24,7 +24,7 @@ squidboy(Apic* apic)
timersinit();
lock(&active);
active.machs |= 1<<m->machno;
active.machs[m->machno] = 1;
unlock(&active);
while(!active.thunderbirdsarego)

View file

@ -394,8 +394,8 @@ trap(Ureg *ureg)
if(0)print("cpu%d: spurious interrupt %d, last %d\n",
m->machno, vno, m->lastintr);
if(0)if(conf.nmach > 1){
for(i = 0; i < 32; i++){
if(!(active.machs & (1<<i)))
for(i = 0; i < MAXMACH; i++){
if(active.machs[i] == 0)
continue;
mach = MACHP(i);
if(m->machno == mach->machno)

View file

@ -568,8 +568,8 @@ consread(Chan *c, void *buf, long n, vlong off)
case Qsysstat:
b = smalloc(conf.nmach*(NUMSIZE*11+1) + 1); /* +1 for NUL */
bp = b;
for(id = 0; id < 32; id++) {
if(active.machs & (1<<id)) {
for(id = 0; id < MAXMACH; id++) {
if(active.machs[id]) {
mp = MACHP(id);
readnum(0, bp, NUMSIZE, id, NUMSIZE);
bp += NUMSIZE;
@ -767,8 +767,8 @@ conswrite(Chan *c, void *va, long n, vlong off)
break;
case Qsysstat:
for(id = 0; id < 32; id++) {
if(active.machs & (1<<id)) {
for(id = 0; id < MAXMACH; id++) {
if(active.machs[id]) {
mp = MACHP(id);
mp->cs = 0;
mp->intr = 0;
@ -1051,8 +1051,8 @@ cpushutdown(void)
int ms, once;
lock(&active);
once = active.machs & (1<<m->machno);
active.machs &= ~(1<<m->machno);
once = active.machs[m->machno];
active.machs[m->machno] = 0;
active.exiting = 1;
unlock(&active);
@ -1063,7 +1063,7 @@ cpushutdown(void)
spllo();
for(ms = 5*1000; ms > 0; ms -= TK2MS(2)){
delay(TK2MS(2));
if(active.machs == 0 && consactive() == 0)
if(memchr(active.machs, 1, MAXMACH) == nil && consactive() == 0)
break;
}
}

View file

@ -145,7 +145,7 @@ hzclock(Ureg *ur)
if(kproftimer != nil)
kproftimer(ur->pc);
if((active.machs&(1<<m->machno)) == 0)
if(active.machs[m->machno] == 0)
return;
if(active.exiting)

View file

@ -189,8 +189,8 @@ struct Mach
struct
{
Lock;
short machs;
short exiting;
char machs[MAXMACH];
int exiting;
}active;
/*

View file

@ -214,7 +214,7 @@ machinit(void)
vco 198
*/
active.machs = 1;
active.machs[0] = 1;
active.exiting = 0;
putmsr(getmsr() | MSR_ME);

View file

@ -140,7 +140,7 @@ machinit(void)
m->cpuhz = 200000000; /* 750FX? */
m->cyclefreq = m->bushz / 4;
active.machs = 1;
active.machs[0] = 1;
active.exiting = 0;
putmsr(getmsr() | MSR_ME);

View file

@ -204,7 +204,7 @@ struct Softtlb
struct
{
Lock;
long machs; /* bitmap of processors */
char machs[MAXMACH]; /* active cpus */
short exiting;
}active;

View file

@ -172,7 +172,7 @@ main(void)
confinit();
machinit(); /* calls clockinit */
active.exiting = 0;
active.machs = 1;
active.machs[0] = 1;
print("\nPlan 9\n");
kmapinit();

View file

@ -676,7 +676,7 @@ cpustart(void)
Power *pwr;
up = nil;
if (active.machs & (1<<m->machno)) {
if (active.machs[m->machno]) {
serialputc('?');
serialputc('r');
panic("cpu%d: resetting after start", m->machno);

View file

@ -246,7 +246,7 @@ typedef void KMap;
struct
{
Lock;
int machs; /* bitmap of active CPUs */
char machs[MAXMACH]; /* active CPUs */
int wfi; /* bitmap of CPUs in WFI state */
int stopped; /* bitmap of CPUs stopped */
int exiting; /* shutdown */

View file

@ -208,13 +208,10 @@ getenv(char* name, char* buf, int n)
void
machon(uint cpu)
{
ulong cpubit;
cpubit = 1 << cpu;
lock(&active);
if ((active.machs & cpubit) == 0) { /* currently off? */
if (active.machs[cpu] == 0) { /* currently off? */
active.machs[cpu] = 1;
conf.nmach++;
active.machs |= cpubit;
}
unlock(&active);
}
@ -223,13 +220,10 @@ machon(uint cpu)
void
machoff(uint cpu)
{
ulong cpubit;
cpubit = 1 << cpu;
lock(&active);
if (active.machs & cpubit) { /* currently on? */
if (active.machs[cpu]) { /* currently on? */
active.machs[cpu] = 0;
conf.nmach--;
active.machs &= ~cpubit;
}
unlock(&active);
}

View file

@ -121,7 +121,7 @@ mach0init(void)
machinit();
active.machs = 1;
active.machs[0] = 1;
active.exiting = 0;
}

View file

@ -393,8 +393,8 @@ trap(Ureg* ureg)
iprint("cpu%d: spurious interrupt %d, last %d\n",
m->machno, vno, m->lastintr);
if(0)if(conf.nmach > 1){
for(i = 0; i < 32; i++){
if(!(active.machs & (1<<i)))
for(i = 0; i < MAXMACH; i++){
if(active.machs[i] == 0)
continue;
mach = MACHP(i);
if(m->machno == mach->machno)

View file

@ -175,7 +175,7 @@ struct ISAConf
struct
{
Lock;
int machs; /* bitmap of active CPUs */
char machs[MAXMACH]; /* active CPUs */
int exiting; /* shutdown */
}active;

View file

@ -385,7 +385,7 @@ mpinit(void)
void
main(void)
{
active.machs |= (1 << m->machno);
active.machs[m->machno] = 1;
if(m->machno != 0){
uartputs("\n", 1);
mmuinit();