Re: Breakage in tree

Alexander Yurchenko <[email protected]> Tue, 16 Mar 2004 02:43:38 +0300
Newsgroups gmane.os.openbsd.smp
Message-ID <[email protected]>
On Sun, Feb 22, 2004 at 07:21:49PM -0600, Marco Peereboom wrote:
> I saw that Niklas committed a bunch of stuff so I tried to give the SMP  
> branch a twirl. It didn't compile though. There is a warning and an  

Well, if you want to just compile it, try this. But the kernel hangs
just after forking init.

Index: arch/i386/i386/cpu.c
===================================================================
RCS file: /cvs/src/sys/arch/i386/i386/Attic/cpu.c,v
retrieving revision 1.1.2.10
diff -u -r1.1.2.10 cpu.c
--- arch/i386/i386/cpu.c	14 Mar 2004 22:08:20 -0000	1.1.2.10
+++ arch/i386/i386/cpu.c	15 Mar 2004 23:40:33 -0000
@@ -297,7 +297,7 @@
 		ci->ci_next = cpu_info_list->ci_next;
 		cpu_info_list->ci_next = ci;
 #else
-		printf("%s: not started\n", sc->sc_dev.dv_xname);
+		printf("%s: not started\n", ci->ci_dev.dv_xname);
 #endif
 		break;
 
Index: arch/i386/i386/locore.s
===================================================================
RCS file: /cvs/src/sys/arch/i386/i386/locore.s,v
retrieving revision 1.48.6.23
diff -u -r1.48.6.23 locore.s
--- arch/i386/i386/locore.s	14 Mar 2004 17:47:43 -0000	1.48.6.23
+++ arch/i386/i386/locore.s	15 Mar 2004 23:40:33 -0000
@@ -1978,7 +1978,7 @@
 	GET_CPUINFO(%eax)
 	pushl	%eax
 #else
-	pushl	_C_LABEL(cpu_info_store)
+	pushl	_C_LABEL(cpu_info_primary)
 #endif
 	call	*_C_LABEL(npxdna_func)
 	addl	$4,%esp
Index: arch/i386/i386/pmap.c
===================================================================
RCS file: /cvs/src/sys/arch/i386/i386/pmap.c,v
retrieving revision 1.34.2.21
diff -u -r1.34.2.21 pmap.c
--- arch/i386/i386/pmap.c	20 Feb 2004 22:19:55 -0000	1.34.2.21
+++ arch/i386/i386/pmap.c	15 Mar 2004 23:40:35 -0000
@@ -1354,7 +1354,9 @@
 	struct pv_entry *cpv, *prevpv;
 {
 	pt_entry_t *ptep, opte;
+#ifdef MULTIPROCESSOR
 	int32_t cpumask = 0;
+#endif
 
 	/*
 	 * we never steal kernel mappings or mappings from pmaps we can't lock
Index: arch/i386/i386/vm_machdep.c
===================================================================
RCS file: /cvs/src/sys/arch/i386/i386/vm_machdep.c,v
retrieving revision 1.17.4.12
diff -u -r1.17.4.12 vm_machdep.c
--- arch/i386/i386/vm_machdep.c	20 Feb 2004 22:19:55 -0000	1.17.4.12
+++ arch/i386/i386/vm_machdep.c	15 Mar 2004 23:40:35 -0000
@@ -90,8 +90,15 @@
 
 	p2->p_md.md_flags = p1->p_md.md_flags;
 
-	/* Sync curpcb (which is presumably p1's PCB) and copy it to p2. */
-	savectx(curcpu()->ci_curpcb);
+	/* Copy pcb from proc p1 to p2. */
+	if (p1 == curproc) {
+		/* Sync the PCB before we copy it. */
+		savectx(curpcb);
+	}
+#ifdef DIAGNOSTIC
+	else if (p1 != &proc0)
+		panic("cpu_fork: curproc");
+#endif
 	*pcb = p1->p_addr->u_pcb;
 
 	/*
@@ -165,12 +172,14 @@
 	switch_exit(p);
 }
 
+#ifdef MULTIPROCESSOR
 void
 cpu_wait(p)
-     struct proc *p;
+	struct proc *p;
 {
 	tss_free(p->p_md.md_tss_sel);
 }
+#endif
 
 /*
  * Dump the machine specific segment at the start of a core dump.
Index: arch/i386/include/cpu.h
===================================================================
RCS file: /cvs/src/sys/arch/i386/include/cpu.h,v
retrieving revision 1.29.2.20
diff -u -r1.29.2.20 cpu.h
--- arch/i386/include/cpu.h	14 Mar 2004 22:08:21 -0000	1.29.2.20
+++ arch/i386/include/cpu.h	15 Mar 2004 23:40:35 -0000
@@ -192,15 +192,11 @@
  */
 extern void need_resched __P((void));
 
-extern void (*delay_func) __P((int));
-struct timeval;
-extern void (*microtime_func) __P((struct timeval *));
+#else /* MULTIPROCESSOR */
 
-#define	DELAY(x)	(*delay_func)(x)
-#define delay(x)	(*delay_func)(x)
-#define microtime(tv)	(*microtime_func)(tv)
+#define I386_MAXPROCS		1
+#define	curcpu()		(&cpu_info_primary)
 
-#else /* MULTIPROCESSOR */
 /*
  * Preempt the current process if in interrupt from user mode,
  * or after the current trap/syscall if in system mode.
@@ -213,8 +209,13 @@
 /*
  * We need a machine-independent name for this.
  */
-#define	DELAY(x)		delay(x)
-void	delay(int);
+extern void (*delay_func)(int);
+struct timeval;
+extern void (*microtime_func)(struct timeval *);
+
+#define	DELAY(x)	(*delay_func)(x)
+#define delay(x)	(*delay_func)(x)
+#define microtime(tv)	(*microtime_func)(tv)
 
 /*
  * definitions of cpu-dependent requirements
Index: arch/i386/isa/icu.s
===================================================================
RCS file: /cvs/src/sys/arch/i386/isa/icu.s,v
retrieving revision 1.12.2.16
diff -u -r1.12.2.16 icu.s
--- arch/i386/isa/icu.s	19 Feb 2004 10:48:42 -0000	1.12.2.16
+++ arch/i386/isa/icu.s	15 Mar 2004 23:40:35 -0000
@@ -42,7 +42,7 @@
 _C_LABEL(ipending):
 	.long	0		# interupts pending
 #ifndef MULTIPROCESSOR
-_C_LABEL(astpending)
+_C_LABEL(astpending):
 	.long	0		# async software traps (softints) pending
 #endif
 _C_LABEL(netisr):
Index: kern/init_main.c
===================================================================
RCS file: /cvs/src/sys/kern/init_main.c,v
retrieving revision 1.46.2.19
diff -u -r1.46.2.19 init_main.c
--- kern/init_main.c	19 Feb 2004 10:56:37 -0000	1.46.2.19
+++ kern/init_main.c	15 Mar 2004 23:40:43 -0000
@@ -184,7 +184,9 @@
 	int s, i;
 	register_t rval[2];
 	extern struct pdevinit pdevinit[];
+#ifdef MULTIPROCESSOR
 	extern struct SIMPLELOCK kprintf_slock;
+#endif
 	extern void scheduler_start(void);
 	extern void disk_init(void);
 	extern void endtsleep(void *);
@@ -209,7 +211,9 @@
 	config_init();		/* init autoconfiguration data structures */
 	consinit();
 
+#ifdef MULTIPROCESSOR
 	SIMPLE_LOCK_INIT(&kprintf_slock);
+#endif
 
 	printf(copyright);
 	printf("\n");

-- 
   Alexander Yurchenko (aka grange)