Subject: schedcpu() raises interrupt level for too long
To: None <tech-kern@netbsd.org>
From: Paul Kranenburg <pk@cs.few.eur.nl>
List: tech-kern
Date: 01/09/2003 16:26:08
The schedcpu() function in kern_synch.c goes to splstatclock() to protect
the current process' cpu tick counters.  However, it continues at this
interrupt level, grabs the scheduler lock, and recomputes the process
priority. It seems to me it should go to splsched() for the latter phase.

This makes a difference if splstatclock() is too high a level (as it is
e.g. on sparc) to be running the actual CPU reschedule notification at.

I propose the patch below.  comments?

===================================================================
RCS file: /cvsroot/src/sys/kern/kern_synch.c,v
retrieving revision 1.119
diff -c -r1.119 kern_synch.c
*** kern_synch.c        2002/12/29 17:40:26     1.119
--- kern_synch.c        2003/01/09 15:19:49
***************
*** 284,289 ****
--- 284,293 ----
                        (p->p_cpticks * FSCALE / clkhz)) >> FSHIFT;
  #endif
                p->p_cpticks = 0;
+               /* Done with the process CPU tick update */
+               splx(s);
+ 
+               s = splsched();
                newcpu = (u_int)decay_cpu(loadfac, p->p_estcpu);
                p->p_estcpu = newcpu;
                SCHED_LOCK(s1);