Subject: Re: Scheduler API changes for yamt-idlelwp
To: Andrew Doran <ad@netbsd.org>
From: Daniel Sieger <dsieger@TechFak.Uni-Bielefeld.DE>
List: tech-kern
Date: 02/21/2007 17:43:31
--Qxx1br4bt0+wmkIi
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Hi,
On Tue, Feb 20, 2007 at 02:44:46AM +0000, Andrew Doran wrote:
>
> The main intention is to avoid using ifdefs unless it costs us to do
> otherwise: code size, or real overhead at execution time. schedclock()
> isn't called all that often, so we can get away without the ifdefs if
> we just make it a dummy function.
Ok, agreed. The patch below adds sched_clock() to the API and remvoes
the unnecessary #ifdefs. The patch also renders sys/sched_4bsd.h to be
empty. I'm not sure wether we should keep it for the moment or simply
remove it. I mean, in the end, it would be nice if the API is
completely self-contained without any scheduler-specific definitions
exposed to the rest of the kernel. Opinions?
Regards,
Daniel
--
Daniel Sieger
Faculty of Technology
Bielefeld University
wwwhomes.uni-bielefeld.de/dsieger
--Qxx1br4bt0+wmkIi
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="schedclock.diff"
Index: kern/kern_clock.c
===================================================================
RCS file: /cvsroot/src/sys/kern/kern_clock.c,v
retrieving revision 1.106.2.2
diff -u -r1.106.2.2 kern_clock.c
--- kern/kern_clock.c 20 Feb 2007 21:48:44 -0000 1.106.2.2
+++ kern/kern_clock.c 21 Feb 2007 16:29:36 -0000
@@ -331,9 +331,7 @@
int schedhz;
int profprocs;
int hardclock_ticks;
-#ifdef SCHED_4BSD
static int statscheddiv; /* stat => sched divider (used if schedhz == 0) */
-#endif
static int psdiv; /* prof => stat divider */
int psratio; /* ratio: prof / stat */
#ifndef __HAVE_TIMECOUNTER
@@ -412,14 +410,12 @@
if (profhz == 0)
profhz = i;
psratio = profhz / i;
-#ifdef SCHED_4BSD
if (schedhz == 0) {
/* 16Hz is best */
statscheddiv = i / 16;
if (statscheddiv <= 0)
panic("statscheddiv");
}
-#endif /* SCHED_4BSD */
#ifndef __HAVE_TIMECOUNTER
#ifdef NTP
@@ -1246,18 +1242,16 @@
++p->p_cpticks;
mutex_spin_exit(&p->p_stmutex);
-#ifdef SCHED_4BSD
/*
* If no separate schedclock is provided, call it here
* at about 16 Hz.
*/
if (schedhz == 0) {
if ((int)(--ci->ci_schedstate.spc_schedticks) <= 0) {
- schedclock(l);
+ sched_clock(l);
ci->ci_schedstate.spc_schedticks = statscheddiv;
}
}
-#endif /* SCHED_4BSD */
}
#ifndef __HAVE_TIMECOUNTER
Index: kern/sched_4bsd.c
===================================================================
RCS file: /cvsroot/src/sys/kern/Attic/sched_4bsd.c,v
retrieving revision 1.1.2.4
diff -u -r1.1.2.4 sched_4bsd.c
--- kern/sched_4bsd.c 21 Feb 2007 12:11:37 -0000 1.1.2.4
+++ kern/sched_4bsd.c 21 Feb 2007 16:29:36 -0000
@@ -530,7 +530,7 @@
*/
void
-schedclock(struct lwp *l)
+sched_clock(struct lwp *l)
{
struct proc *p = l->l_proc;
Index: sys/sched.h
===================================================================
RCS file: /cvsroot/src/sys/sys/sched.h,v
retrieving revision 1.30.2.2
diff -u -r1.30.2.2 sched.h
--- sys/sched.h 20 Feb 2007 21:48:47 -0000 1.30.2.2
+++ sys/sched.h 21 Feb 2007 16:29:37 -0000
@@ -159,6 +159,8 @@
#ifdef _KERNEL
+extern int schedhz; /* ideally: 16 */
+
struct proc;
struct cpu_info;
@@ -172,6 +174,7 @@
/* Main scheduler functions */
void sched_tick(struct cpu_info *); /* Maybe resched after spc_ticks hardclock() ticks */
+void sched_clock(struct lwp *); /* Called from statclock(), e.g. to handle priority adjustment */
/* Runqueue-related functions */
inline boolean_t sched_curcpu_runnable_p(void); /* Indicate runnable processes on current CPU */
Index: sys/sched_4bsd.h
===================================================================
RCS file: /cvsroot/src/sys/sys/Attic/sched_4bsd.h,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 sched_4bsd.h
--- sys/sched_4bsd.h 20 Feb 2007 21:48:47 -0000 1.1.2.1
+++ sys/sched_4bsd.h 21 Feb 2007 16:29:37 -0000
@@ -76,8 +76,4 @@
#ifndef _SYS_SCHED_4BSD_H_
#define _SYS_SCHED_4BSD_H_
-extern int schedhz; /* ideally: 16 */
-
-void schedclock(struct lwp *);
-
#endif /* _SYS_SCHED_4BSD_H_ */
--Qxx1br4bt0+wmkIi--