Subject: Review needed for change in vm_machdep.c
To: None <port-mips@netbsd.org>
From: Ethan Solomita <ethan@geocast.com>
List: port-mips
Date: 03/23/2000 12:04:29
        I've noticed that, on our mips port, the kernel threads (such as
ioflush) are running at splhigh. This isn't true for the i386 port,
where it is at spl0. There's also no reason for ioflush, as an example,
to have interrupts blocked.

        I added a printf() in init_main.c, right where it calls
kthread_create1() to make the new threads. At that point, we are
actually running at spl0(), just like we should. But the kernel threads
are being created at splhigh(), regardless.

        I believe the problem is in vm_machdep.c:cpu_fork(). At this
point in init_main.c where we're creating the new threads, we've never
had a
context switch. Although we're running at spl0, the pcb doesn't have a
saved value for the status register ST.

        Yet in cpu_fork() we copy the u_pcb from the parent to the
child. At
the bottom we explicitly set RA, SP, S0 and S1. I added to them the
line:

        pcb->pcb_context[11] = (int)_splget();          /* ST */

        This way we'll get whatever the spl level is *now*, not at a
time of
context switch. It does fix the problem with splhigh kernel threads. But
I am not deeply familiar with the bowels of the mips port, so before I
change something like this I want to get other eyeballs on it.

	Comments?

        Thanks!
        -- Ethan