Subject: Re: more funky stuff with kthreads and interrupts
To: None <,,,>
From: Toru Nishimura <>
List: port-cobalt
Date: 05/08/2001 12:32:03
Attention please.  This is a hot fix.

NetBSD/mips users have been suffered from general slowness or severe
clock drift when system activity is high.  Other camps of NetBSD
ports were found recently to run system kthreads (pagedaemon,
ioflush, reaper, aiodoned) in splhigh condition.  And then NetBSD/mips
was proven to have the same error.

I thought NetBSD/mips was immune from it as pcb0 was forced to have
spl0 condition which was propagated to all of children, but it was a
wrong fix.  The issue is pcb0 gets overwritten before the first
kthread_create1() is called.  For a normal process which has user mode
it doesn't matter because proc_trampoline() makes the process to have
spl0 during exception return path to user mode, however, kthreads stay
in kernel mode mistakenly left in splhigh condition.

/// FIX ///
Make sure to have spl0 condition whenever a new thread of control
is created.

/// COMMENT ///
This is another, probably the 3rd, occation where processor
is forced to have explicit "interrupt level" assignment for SR. 

Tohru Nishimura
Information Technology Centre
Nara Institute of Science and Technology

Index: vm_machdep.c
RCS file: /cvsroot/syssrc/sys/arch/mips/mips/vm_machdep.c,v
retrieving revision 1.74
diff -c -r1.74 vm_machdep.c
*** vm_machdep.c	2001/04/24 04:31:03	1.74
--- vm_machdep.c	2001/05/08 03:17:32
*** 145,150 ****
--- 145,151 ----
  	pcb->pcb_context[8] = (int)f - 24;		/* SP */
  	pcb->pcb_context[0] = (int)func;		/* S0 */
  	pcb->pcb_context[1] = (int)arg;			/* S1 */
+ 	pcb->pcb_context[11] |= MIPS_INT_MASK | MIPS_SR_INT_IE; /* SR */