Subject: tsleep while cold can be avoided!
To: None <thorpej@nas.nasa.gov>
From: Gordon W. Ross <gwr@mc.com>
List: tech-kern
Date: 03/25/1997 17:51:55
> From: Jason Thorpe <thorpej@nas.nasa.gov>
> Date: Mon, 24 Mar 1997 15:16:07 -0800
>
> On Mon, 24 Mar 97 16:55:15 EST
> gwr@mc.com (Gordon W. Ross) wrote:
>
> > While tsleep() does not really do as the comment says it will,
> > I'm not sure we want it to. Enabling interrupts while cold is
> > not necessarily a good idea (safer to wait until autoconfig is
> > finished). My hope is that with the code movement I suggested,
> > we could change that bit of code in tsleep() to this:
> >
> > if (cold)
> > panic("tsleep cold");
>
> Yah, I'm with Gordon on this one... IMO, the whole motion of calling
> tsleep() while cold is, at best, counter-intuitive.
>
> Jason R. Thorpe thorpej@nas.nasa.gov
> NASA Ames Research Center Home: 408.866.1912
> NAS: M/S 258-6 Work: 415.604.0935
> Moffett Field, CA 94035 Pager: 415.428.6939
I've since tried out the code movement idea, and it works very nicely!
If I move the code that does: findroot/setroot, swapconf, dumpconf
from where it is now into a new, separate function that is called just
before vfs_mountroot, then the kernel does not call tsleep while cold.
The code that I moved does things like read disk labels, and is more
robust against missing interrupt problems if it is done later, so that
timeouts will work. Therefore, I propose the following changes.
Comments?
Gordon
diff -c sys/systm.h.orig sys/systm.h
*** sys/systm.h.orig Fri Jan 31 11:05:18 1997
--- sys/systm.h Tue Mar 25 15:33:03 1997
***************
*** 260,265 ****
--- 260,266 ----
void consinit __P((void));
+ void cpu_rootconf __P((void));
void cpu_startup __P((void));
void cpu_set_kpc __P((struct proc *, void (*)(struct proc *)));
diff -c kern/init_main.c.orig kern/init_main.c
*** kern/init_main.c.orig Mon Feb 3 11:11:20 1997
--- kern/init_main.c Tue Mar 25 15:33:24 1997
***************
*** 320,325 ****
--- 320,326 ----
schedcpu(NULL);
/* Mount the root file system. */
+ cpu_rootconf();
do {
domountroothook();
if ((error = vfs_mountroot())) {
I just included one representative sample change based on the sun3
port here. All ports would need a little code moved into the new
cpu_rootconf() function, something like the change shown here.
diff -c arch/sun3/sun3/autoconf.c.orig arch/sun3/sun3/autoconf.c
*** arch/sun3/sun3/autoconf.c.orig Tue Mar 25 15:44:15 1997
--- arch/sun3/sun3/autoconf.c Tue Mar 25 15:46:09 1997
***************
*** 87,96 ****
--- 87,106 ----
printf("enabling interrupts\n");
(void)spl0();
+ #if 0
rootconf(); /* local findroot/setroot code */
swapconf();
dumpconf();
+ #endif
cold = 0;
+ }
+
+ void
+ cpu_rootconf()
+ {
+ rootconf(); /* local findroot/setroot code */
+ swapconf();
+ dumpconf();
}
/****************************************************************/