Subject: semi-attached CPUs in sommerfeld_i386_mp_1 branch
To: None <sommerfeld@netbsd.org>
From: Rafal Boni <rafal@mediaone.net>
List: tech-smp
Date: 01/19/2002 12:02:50
Bill:
	It looks like the way the i386 smp code is implemented, the cpus
	are linked into the cpu_info_list before the cpu_info structures
	are fully initialized.  I'm not sure if this is simply a case of
	walkers of the cpu_info list needing to be smarter about the par-
	ticular fields they're interested in, a genuine problem or just
	a case of "I picked a bad example to look at".

	The problem where I encoutered this was building a kernel with
	apm enabled on the MP branch; the kernel panic'ed as the APM code
	attempted to set GDT info in the not-yet-initialized ci_gdt member
	of the cpu_info code (in the setgdt() call).  Now, I know that APM
	and MP don't mix, but this could have been demonstrated by any other
	piece of code that needed to tweak the GDT between when the cpu's
	were detected and attached (which is when they're linked into the
	cpu list) and when the cpu's were spun up (when the per-cpu GDT was
	allocated).

	So, which of the following is the most correct:
	    (1) CPU structures should be fully initialized before being
		linked into the cpu list.
	    (2) Walkers of the cpu_info list need to be aware that there
		are windows where half-initialized cpu_info entries may
		exist in the list, or
	    (3) something other than the above two choices? ("the GDT 
		code is special and should be fixed to deal", "stuff 
		called from autoconfig should be extra careful when 
		walking the cpu list" or something else entirely).

Thanks,
--rafal

----
Rafal Boni                                                   rafal@mediaone.net