Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 04 Dec 1996 09:46:04 -0800
From:      Erich Boleyn <erich@uruk.org>
To:        peter@spinner.dialix.com
Cc:        smp@freebsd.org
Subject:   Get running with 2 CPUs only!  (finally...)
Message-ID:  <E0vVLOW-0002Ib-00@uruk.org>

next in thread | raw e-mail | index | archive | help

It turns out that in the patch I sent, which was making sure "x" was
initialized in the "processorEntry" routine, had an off-by-one error, as
the CPU numbering was 1-based, and not 0-based, as I thought.  Sigh.

Anyway, I tried this kernel, and it returns the right thing from dmesg
(only 2 CPUs probed and activated), the 2nd CPU activates and is now
running on my box, etc.  I even performed the diff on the kernel running
2-CPU.

With this and NCPU = 2, I'm running with APIC_IO + SMP_INVLTLB, and 2 CPUs
are up and running (I've been doing cvs stuff, compiles, etc. with no
problems for the last 15 minutes).

Thanks for all the great work, guys!  Particularly now that TLB invalidates
propagate, I feel much more comfortable running things.  (and of course,
it works on my test P6 box ;-).

So, here is the correct and tested patch for limiting to NCPU
cpus with no kernel panics (if you didn't see it and fix it already).
This is against the cvs tree from this morning before I made any changes:

---------------------------(start diff mp_machdep.c)----------------------
--- mp_machdep.c	Tue Dec  3 19:06:09 1996
+++ /usr/src/sys/i386/i386/mp_machdep.c	Wed Dec  4 09:35:14 1996
@@ -764,7 +764,7 @@
 static void
 processorEntry( ProcEntry entry, int* cpu )
 {
-    int x;
+    int x = *cpu;
 
     /* check for usability */
     if ( !(entry->cpuFlags & PROCENTRY_FLAG_EN) ) return;
@@ -775,12 +775,9 @@
 	x = 0;
 	bootCpuId = entry->apicID;
     } else {
-	/* add another AP to list */
-	x = (*cpu)++;
-	if ( x == NCPU ) {
-	    printf( "too many CPUs, increase 'NCPU'\n" );
-	    panic( "\n" );
-	}
+	/* add another AP to list, if less than max number of CPUs */
+	if ( x == NCPU ) return;
+	*cpu = x + 1;
     }
 
     CPU_TO_ID( x ) = entry->apicID;
---------------------------(end diff mp_machdep.c)----------------------


--
  Erich Stefan Boleyn                 \_ E-mail (preferred):  <erich@uruk.org>
Mad Genius wanna-be, CyberMuffin        \__      (finger me for other stats)
Web:  http://www.uruk.org/~erich/     Motto: "I'll live forever or die trying"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E0vVLOW-0002Ib-00>