changelog shortlog tags branches files raw gz bz2 help

Mercurial > hg > plan9front / changeset: kernel: change active.machs from bitmap to char array to support up to 64 cpus on pc64

changeset 5034: 8d305ed78c96
parent 5033: a72fe65839df
child 5035: 395fa6284258
author: cinap_lenrek@felloff.net
date: Tue, 05 Jan 2016 05:32:40 +0100
files: sys/src/9/alphapc/dat.h sys/src/9/alphapc/main.c sys/src/9/alphapc/trap.c sys/src/9/bcm/dat.h sys/src/9/bcm/main.c sys/src/9/bitsy/dat.h sys/src/9/bitsy/main.c sys/src/9/kw/dat.h sys/src/9/kw/main.c sys/src/9/mtx/dat.h sys/src/9/mtx/main.c sys/src/9/omap/dat.h sys/src/9/omap/main.c sys/src/9/pc/dat.h sys/src/9/pc/main.c sys/src/9/pc/mmu.c sys/src/9/pc/mp.c sys/src/9/pc/squidboy.c sys/src/9/pc/trap.c sys/src/9/pc64/dat.h sys/src/9/pc64/main.c sys/src/9/pc64/mem.h sys/src/9/pc64/squidboy.c sys/src/9/pc64/trap.c sys/src/9/port/devcons.c sys/src/9/port/portclock.c sys/src/9/ppc/dat.h sys/src/9/ppc/m8260.c sys/src/9/ppc/msaturn.c sys/src/9/sgi/dat.h sys/src/9/sgi/main.c sys/src/9/teg2/archtegra.c sys/src/9/teg2/dat.h sys/src/9/teg2/main.c sys/src/9/xen/main.c sys/src/9/xen/trap.c sys/src/9/zynq/dat.h sys/src/9/zynq/main.c
description: kernel: change active.machs from bitmap to char array to support up to 64 cpus on pc64
     1.1--- a/sys/src/9/alphapc/dat.h
     1.2+++ b/sys/src/9/alphapc/dat.h
     1.3@@ -184,8 +184,8 @@ struct Mach
     1.4 struct
     1.5 {
     1.6 	Lock;
     1.7-	short	machs;
     1.8-	short	exiting;
     1.9+	char	machs[MAXMACH];
    1.10+	int	exiting;
    1.11 }active;
    1.12 
    1.13 /*
     2.1--- a/sys/src/9/alphapc/main.c
     2.2+++ b/sys/src/9/alphapc/main.c
     2.3@@ -156,7 +156,7 @@ machinit(void)
     2.4 	m->machno = n;
     2.5 
     2.6 	active.exiting = 0;
     2.7-	active.machs = 1;
     2.8+	active.machs[0] = 1;
     2.9 
    2.10 	cpu = (Hwcpu*) ((ulong)hwrpb + hwrpb->cpuoff + n*hwrpb->cpulen);
    2.11 	cpu->state &= ~Cpubootinprog;
     3.1--- a/sys/src/9/alphapc/trap.c
     3.2+++ b/sys/src/9/alphapc/trap.c
     3.3@@ -261,8 +261,8 @@ intr(Ureg *ur)
     3.4 		 */
     3.5 		iprint("cpu%d: spurious interrupt %d, last %d",
     3.6 			m->machno, vno-VectorPIC, m->lastintr);
     3.7-		for(i = 0; i < 32; i++){
     3.8-			if(!(active.machs & (1<<i)))
     3.9+		for(i = 0; i < MAXMACH; i++){
    3.10+			if(active.machs[i] == 0)
    3.11 				continue;
    3.12 			mach = MACHP(i);
    3.13 			if(m->machno == mach->machno)
     4.1--- a/sys/src/9/bcm/dat.h
     4.2+++ b/sys/src/9/bcm/dat.h
     4.3@@ -223,7 +223,7 @@ typedef void		KMap;
     4.4 struct
     4.5 {
     4.6 	Lock;
     4.7-	int	machs;			/* bitmap of active CPUs */
     4.8+	char	machs[MAXMACH];		/* active CPUs */
     4.9 	int	exiting;		/* shutdown */
    4.10 }active;
    4.11 
     5.1--- a/sys/src/9/bcm/main.c
     5.2+++ b/sys/src/9/bcm/main.c
     5.3@@ -199,7 +199,7 @@ machinit(void)
     5.4 
     5.5 	conf.nmach = 1;
     5.6 
     5.7-	active.machs = 1;
     5.8+	active.machs[0] = 1;
     5.9 	active.exiting = 0;
    5.10 
    5.11 	up = nil;
     6.1--- a/sys/src/9/bitsy/dat.h
     6.2+++ b/sys/src/9/bitsy/dat.h
     6.3@@ -178,7 +178,7 @@ typedef void		KMap;
     6.4 struct
     6.5 {
     6.6 	Lock;
     6.7-	int	machs;			/* bitmap of active CPUs */
     6.8+	char	machs[MAXMACH];		/* active CPUs */
     6.9 	int	exiting;		/* shutdown */
    6.10 }active;
    6.11 
     7.1--- a/sys/src/9/bitsy/main.c
     7.2+++ b/sys/src/9/bitsy/main.c
     7.3@@ -26,7 +26,7 @@ main(void)
     7.4 	memset(m, 0, sizeof(Mach));
     7.5 	m->ticks = 1;
     7.6 
     7.7-	active.machs = 1;
     7.8+	active.machs[0] = 1;
     7.9 
    7.10 	rs232power(1);
    7.11 	quotefmtinstall();
     8.1--- a/sys/src/9/kw/dat.h
     8.2+++ b/sys/src/9/kw/dat.h
     8.3@@ -194,7 +194,7 @@ typedef void		KMap;
     8.4 struct
     8.5 {
     8.6 	Lock;
     8.7-	int	machs;			/* bitmap of active CPUs */
     8.8+	char	machs[MAXMACH];		/* active CPUs */
     8.9 	int	exiting;		/* shutdown */
    8.10 }active;
    8.11 
     9.1--- a/sys/src/9/kw/main.c
     9.2+++ b/sys/src/9/kw/main.c
     9.3@@ -349,7 +349,7 @@ machinit(void)
     9.4 
     9.5 	conf.nmach = 1;
     9.6 
     9.7-	active.machs = 1;
     9.8+	active.machs[0] = 1;
     9.9 	active.exiting = 0;
    9.10 
    9.11 	up = nil;
    10.1--- a/sys/src/9/mtx/dat.h
    10.2+++ b/sys/src/9/mtx/dat.h
    10.3@@ -181,8 +181,8 @@ struct Mach
    10.4 struct
    10.5 {
    10.6 	Lock;
    10.7-	short	machs;
    10.8-	short	exiting;
    10.9+	char	machs[MAXMACH];
   10.10+	int	exiting;
   10.11 }active;
   10.12 
   10.13 /*
    11.1--- a/sys/src/9/mtx/main.c
    11.2+++ b/sys/src/9/mtx/main.c
    11.3@@ -59,7 +59,7 @@ machinit(void)
    11.4 	/* turn on caches */
    11.5 	puthid0(gethid0() | BIT(16) | BIT(17));
    11.6 
    11.7-	active.machs = 1;
    11.8+	active.machs[0] = 1;
    11.9 	active.exiting = 0;
   11.10 }
   11.11 
    12.1--- a/sys/src/9/omap/dat.h
    12.2+++ b/sys/src/9/omap/dat.h
    12.3@@ -216,7 +216,7 @@ typedef void		KMap;
    12.4 struct
    12.5 {
    12.6 	Lock;
    12.7-	int	machs;			/* bitmap of active CPUs */
    12.8+	char	machs[MAXMACH];		/* active CPUs */
    12.9 	int	exiting;		/* shutdown */
   12.10 }active;
   12.11 
    13.1--- a/sys/src/9/omap/main.c
    13.2+++ b/sys/src/9/omap/main.c
    13.3@@ -295,7 +295,7 @@ machinit(void)
    13.4 
    13.5 	conf.nmach = 1;
    13.6 
    13.7-	active.machs = 1;
    13.8+	active.machs[0] = 1;
    13.9 	active.exiting = 0;
   13.10 
   13.11 	up = nil;
    14.1--- a/sys/src/9/pc/dat.h
    14.2+++ b/sys/src/9/pc/dat.h
    14.3@@ -270,7 +270,7 @@ void	kunmap(KMap*);
    14.4 struct
    14.5 {
    14.6 	Lock;
    14.7-	int	machs;			/* bitmap of active CPUs */
    14.8+	char	machs[MAXMACH];		/* active CPUs */
    14.9 	int	exiting;		/* shutdown */
   14.10 	int	thunderbirdsarego;	/* lets the added processors continue to schedinit */
   14.11 }active;
    15.1--- a/sys/src/9/pc/main.c
    15.2+++ b/sys/src/9/pc/main.c
    15.3@@ -181,7 +181,7 @@ mach0init(void)
    15.4 
    15.5 	machinit();
    15.6 
    15.7-	active.machs = 1;
    15.8+	active.machs[0] = 1;
    15.9 	active.exiting = 0;
   15.10 }
   15.11 
    16.1--- a/sys/src/9/pc/mmu.c
    16.2+++ b/sys/src/9/pc/mmu.c
    16.3@@ -685,7 +685,7 @@ vunmap(void *v, int size)
    16.4 	for(i=0; i<conf.nmach; i++){
    16.5 		nm = MACHP(i);
    16.6 		if(nm != m)
    16.7-			while((active.machs&(1<<nm->machno)) && nm->flushmmu)
    16.8+			while(active.machs[nm->machno] && nm->flushmmu)
    16.9 				;
   16.10 	}
   16.11 }
    17.1--- a/sys/src/9/pc/mp.c
    17.2+++ b/sys/src/9/pc/mp.c
    17.3@@ -198,6 +198,8 @@ mpinit(void)
    17.4 	for(i=0; i<nelem(mpapic); i++){
    17.5 		if((apic = mpapic[i]) == nil)
    17.6 			continue;
    17.7+		if(apic->machno >= MAXMACH)
    17.8+			continue;
    17.9 		if(ncpu <= 1)
   17.10 			break;
   17.11 		if((apic->flags & (PcmpBP|PcmpEN)) == PcmpEN){
   17.12@@ -574,7 +576,7 @@ mpshutdown(void)
   17.13 		for(;;) idle();
   17.14 	}
   17.15 
   17.16-	print("mpshutdown: active = %#8.8ux\n", active.machs);
   17.17+	print("mpshutdown\n");
   17.18 	delay(1000);
   17.19 	splhi();
   17.20 
    18.1--- a/sys/src/9/pc/squidboy.c
    18.2+++ b/sys/src/9/pc/squidboy.c
    18.3@@ -30,7 +30,7 @@ squidboy(Apic* apic)
    18.4 	fpoff();
    18.5 
    18.6 	lock(&active);
    18.7-	active.machs |= 1<<m->machno;
    18.8+	active.machs[m->machno] = 1;
    18.9 	unlock(&active);
   18.10 
   18.11 	while(!active.thunderbirdsarego)
    19.1--- a/sys/src/9/pc/trap.c
    19.2+++ b/sys/src/9/pc/trap.c
    19.3@@ -400,8 +400,8 @@ trap(Ureg* ureg)
    19.4 		if(0)print("cpu%d: spurious interrupt %d, last %d\n",
    19.5 			m->machno, vno, m->lastintr);
    19.6 		if(0)if(conf.nmach > 1){
    19.7-			for(i = 0; i < 32; i++){
    19.8-				if(!(active.machs & (1<<i)))
    19.9+			for(i = 0; i < MAXMACH; i++){
   19.10+				if(active.machs[i] == 0)
   19.11 					continue;
   19.12 				mach = MACHP(i);
   19.13 				if(m->machno == mach->machno)
    20.1--- a/sys/src/9/pc64/dat.h
    20.2+++ b/sys/src/9/pc64/dat.h
    20.3@@ -233,7 +233,7 @@ typedef void KMap;
    20.4 struct
    20.5 {
    20.6 	Lock;
    20.7-	int	machs;			/* bitmap of active CPUs */
    20.8+	char	machs[MAXMACH];		/* bitmap of active CPUs */
    20.9 	int	exiting;		/* shutdown */
   20.10 	int	thunderbirdsarego;	/* lets the added processors continue to schedinit */
   20.11 }active;
    21.1--- a/sys/src/9/pc64/main.c
    21.2+++ b/sys/src/9/pc64/main.c
    21.3@@ -326,7 +326,7 @@ mach0init(void)
    21.4 
    21.5 	machinit();
    21.6 
    21.7-	active.machs = 1;
    21.8+	active.machs[0] = 1;
    21.9 	active.exiting = 0;
   21.10 }
   21.11 
    22.1--- a/sys/src/9/pc64/mem.h
    22.2+++ b/sys/src/9/pc64/mem.h
    22.3@@ -28,7 +28,7 @@
    22.4 #define	BLOCKALIGN	8
    22.5 #define	FPalign		16
    22.6 
    22.7-#define	MAXMACH		32			/* max # cpus system can run */
    22.8+#define	MAXMACH		64			/* max # cpus system can run */
    22.9 
   22.10 #define KSTACK		(16*KiB)		/* Size of Proc kernel stack */
   22.11 
    23.1--- a/sys/src/9/pc64/squidboy.c
    23.2+++ b/sys/src/9/pc64/squidboy.c
    23.3@@ -24,7 +24,7 @@ squidboy(Apic* apic)
    23.4 	timersinit();
    23.5 
    23.6 	lock(&active);
    23.7-	active.machs |= 1<<m->machno;
    23.8+	active.machs[m->machno] = 1;
    23.9 	unlock(&active);
   23.10 
   23.11 	while(!active.thunderbirdsarego)
    24.1--- a/sys/src/9/pc64/trap.c
    24.2+++ b/sys/src/9/pc64/trap.c
    24.3@@ -394,8 +394,8 @@ trap(Ureg *ureg)
    24.4 		if(0)print("cpu%d: spurious interrupt %d, last %d\n",
    24.5 			m->machno, vno, m->lastintr);
    24.6 		if(0)if(conf.nmach > 1){
    24.7-			for(i = 0; i < 32; i++){
    24.8-				if(!(active.machs & (1<<i)))
    24.9+			for(i = 0; i < MAXMACH; i++){
   24.10+				if(active.machs[i] == 0)
   24.11 					continue;
   24.12 				mach = MACHP(i);
   24.13 				if(m->machno == mach->machno)
    25.1--- a/sys/src/9/port/devcons.c
    25.2+++ b/sys/src/9/port/devcons.c
    25.3@@ -568,8 +568,8 @@ consread(Chan *c, void *buf, long n, vlo
    25.4 	case Qsysstat:
    25.5 		b = smalloc(conf.nmach*(NUMSIZE*11+1) + 1);	/* +1 for NUL */
    25.6 		bp = b;
    25.7-		for(id = 0; id < 32; id++) {
    25.8-			if(active.machs & (1<<id)) {
    25.9+		for(id = 0; id < MAXMACH; id++) {
   25.10+			if(active.machs[id]) {
   25.11 				mp = MACHP(id);
   25.12 				readnum(0, bp, NUMSIZE, id, NUMSIZE);
   25.13 				bp += NUMSIZE;
   25.14@@ -767,8 +767,8 @@ conswrite(Chan *c, void *va, long n, vlo
   25.15 		break;
   25.16 
   25.17 	case Qsysstat:
   25.18-		for(id = 0; id < 32; id++) {
   25.19-			if(active.machs & (1<<id)) {
   25.20+		for(id = 0; id < MAXMACH; id++) {
   25.21+			if(active.machs[id]) {
   25.22 				mp = MACHP(id);
   25.23 				mp->cs = 0;
   25.24 				mp->intr = 0;
   25.25@@ -1051,8 +1051,8 @@ cpushutdown(void)
   25.26 	int ms, once;
   25.27 
   25.28 	lock(&active);
   25.29-	once = active.machs & (1<<m->machno);
   25.30-	active.machs &= ~(1<<m->machno);
   25.31+	once = active.machs[m->machno];
   25.32+	active.machs[m->machno] = 0;
   25.33 	active.exiting = 1;
   25.34 	unlock(&active);
   25.35 
   25.36@@ -1063,7 +1063,7 @@ cpushutdown(void)
   25.37 	spllo();
   25.38 	for(ms = 5*1000; ms > 0; ms -= TK2MS(2)){
   25.39 		delay(TK2MS(2));
   25.40-		if(active.machs == 0 && consactive() == 0)
   25.41+		if(memchr(active.machs, 1, MAXMACH) == nil && consactive() == 0)
   25.42 			break;
   25.43 	}
   25.44 }
    26.1--- a/sys/src/9/port/portclock.c
    26.2+++ b/sys/src/9/port/portclock.c
    26.3@@ -145,7 +145,7 @@ hzclock(Ureg *ur)
    26.4 	if(kproftimer != nil)
    26.5 		kproftimer(ur->pc);
    26.6 
    26.7-	if((active.machs&(1<<m->machno)) == 0)
    26.8+	if(active.machs[m->machno] == 0)
    26.9 		return;
   26.10 
   26.11 	if(active.exiting)
    27.1--- a/sys/src/9/ppc/dat.h
    27.2+++ b/sys/src/9/ppc/dat.h
    27.3@@ -189,8 +189,8 @@ struct Mach
    27.4 struct
    27.5 {
    27.6 	Lock;
    27.7-	short	machs;
    27.8-	short	exiting;
    27.9+	char	machs[MAXMACH];
   27.10+	int	exiting;
   27.11 }active;
   27.12 
   27.13 /*
    28.1--- a/sys/src/9/ppc/m8260.c
    28.2+++ b/sys/src/9/ppc/m8260.c
    28.3@@ -214,7 +214,7 @@ machinit(void)
    28.4 	vco		198
    28.5 */
    28.6 
    28.7-	active.machs = 1;
    28.8+	active.machs[0] = 1;
    28.9 	active.exiting = 0;
   28.10 
   28.11 	putmsr(getmsr() | MSR_ME);
    29.1--- a/sys/src/9/ppc/msaturn.c
    29.2+++ b/sys/src/9/ppc/msaturn.c
    29.3@@ -140,7 +140,7 @@ machinit(void)
    29.4 		m->cpuhz = 200000000;		/* 750FX? */
    29.5 	m->cyclefreq = m->bushz / 4;
    29.6 
    29.7-	active.machs = 1;
    29.8+	active.machs[0] = 1;
    29.9 	active.exiting = 0;
   29.10 
   29.11 	putmsr(getmsr() | MSR_ME);
    30.1--- a/sys/src/9/sgi/dat.h
    30.2+++ b/sys/src/9/sgi/dat.h
    30.3@@ -204,7 +204,7 @@ struct Softtlb
    30.4 struct
    30.5 {
    30.6 	Lock;
    30.7-	long	machs;		/* bitmap of processors */
    30.8+	char	machs[MAXMACH];		/* active cpus */
    30.9 	short	exiting;
   30.10 }active;
   30.11 
    31.1--- a/sys/src/9/sgi/main.c
    31.2+++ b/sys/src/9/sgi/main.c
    31.3@@ -172,7 +172,7 @@ main(void)
    31.4 	confinit();
    31.5 	machinit();			/* calls clockinit */
    31.6 	active.exiting = 0;
    31.7-	active.machs = 1;
    31.8+	active.machs[0] = 1;
    31.9 	print("\nPlan 9\n");
   31.10 
   31.11 	kmapinit();
    32.1--- a/sys/src/9/teg2/archtegra.c
    32.2+++ b/sys/src/9/teg2/archtegra.c
    32.3@@ -676,7 +676,7 @@ cpustart(void)
    32.4 	Power *pwr;
    32.5 
    32.6 	up = nil;
    32.7-	if (active.machs & (1<<m->machno)) {
    32.8+	if (active.machs[m->machno]) {
    32.9 		serialputc('?');
   32.10 		serialputc('r');
   32.11 		panic("cpu%d: resetting after start", m->machno);
    33.1--- a/sys/src/9/teg2/dat.h
    33.2+++ b/sys/src/9/teg2/dat.h
    33.3@@ -246,7 +246,7 @@ typedef void		KMap;
    33.4 struct
    33.5 {
    33.6 	Lock;
    33.7-	int	machs;			/* bitmap of active CPUs */
    33.8+	char	machs[MAXMACH];		/* active CPUs */
    33.9 	int	wfi;			/* bitmap of CPUs in WFI state */
   33.10 	int	stopped;		/* bitmap of CPUs stopped */
   33.11 	int	exiting;		/* shutdown */
    34.1--- a/sys/src/9/teg2/main.c
    34.2+++ b/sys/src/9/teg2/main.c
    34.3@@ -208,13 +208,10 @@ getenv(char* name, char* buf, int n)
    34.4 void
    34.5 machon(uint cpu)
    34.6 {
    34.7-	ulong cpubit;
    34.8-
    34.9-	cpubit = 1 << cpu;
   34.10 	lock(&active);
   34.11-	if ((active.machs & cpubit) == 0) {	/* currently off? */
   34.12+	if (active.machs[cpu] == 0) {	/* currently off? */
   34.13+		active.machs[cpu] = 1;
   34.14 		conf.nmach++;
   34.15-		active.machs |= cpubit;
   34.16 	}
   34.17 	unlock(&active);
   34.18 }
   34.19@@ -223,13 +220,10 @@ machon(uint cpu)
   34.20 void
   34.21 machoff(uint cpu)
   34.22 {
   34.23-	ulong cpubit;
   34.24-
   34.25-	cpubit = 1 << cpu;
   34.26 	lock(&active);
   34.27-	if (active.machs & cpubit) {		/* currently on? */
   34.28+	if (active.machs[cpu]) {		/* currently on? */
   34.29+		active.machs[cpu] = 0;
   34.30 		conf.nmach--;
   34.31-		active.machs &= ~cpubit;
   34.32 	}
   34.33 	unlock(&active);
   34.34 }
    35.1--- a/sys/src/9/xen/main.c
    35.2+++ b/sys/src/9/xen/main.c
    35.3@@ -121,7 +121,7 @@ mach0init(void)
    35.4 
    35.5 	machinit();
    35.6 
    35.7-	active.machs = 1;
    35.8+	active.machs[0] = 1;
    35.9 	active.exiting = 0;
   35.10 }
   35.11 
    36.1--- a/sys/src/9/xen/trap.c
    36.2+++ b/sys/src/9/xen/trap.c
    36.3@@ -393,8 +393,8 @@ trap(Ureg* ureg)
    36.4 		iprint("cpu%d: spurious interrupt %d, last %d\n",
    36.5 			m->machno, vno, m->lastintr);
    36.6 		if(0)if(conf.nmach > 1){
    36.7-			for(i = 0; i < 32; i++){
    36.8-				if(!(active.machs & (1<<i)))
    36.9+			for(i = 0; i < MAXMACH; i++){
   36.10+				if(active.machs[i] == 0)
   36.11 					continue;
   36.12 				mach = MACHP(i);
   36.13 				if(m->machno == mach->machno)
    37.1--- a/sys/src/9/zynq/dat.h
    37.2+++ b/sys/src/9/zynq/dat.h
    37.3@@ -175,7 +175,7 @@ struct ISAConf
    37.4 struct
    37.5 {
    37.6 	Lock;
    37.7-	int	machs;			/* bitmap of active CPUs */
    37.8+	char	machs[MAXMACH];		/* active CPUs */
    37.9 	int	exiting;		/* shutdown */
   37.10 }active;
   37.11 
    38.1--- a/sys/src/9/zynq/main.c
    38.2+++ b/sys/src/9/zynq/main.c
    38.3@@ -385,7 +385,7 @@ mpinit(void)
    38.4 void
    38.5 main(void)
    38.6 {
    38.7-	active.machs |= (1 << m->machno);
    38.8+	active.machs[m->machno] = 1;
    38.9 	if(m->machno != 0){
   38.10 		uartputs("\n", 1);
   38.11 		mmuinit();