Subject: autonice configuration
To: None <tech-kern@NetBSD.ORG>
From: Michael Graff <explorer@flame.org>
List: tech-kern
Date: 07/16/1996 13:01:32
Some time ago there was a rather heated debate over how to adjust the
time it takes before a non-rootly process becomes niced, and to what
priority it becomes. Mainly, someone wanted to have a feature to
disable it, I believe.
I suggested a compile-time default as well as a sysctl which will
allow it to be adjusted. Here is the patch. I've passed a version of
this by Jason Thorpe, and made some changes as he suggested.
I'd like to commit this is there are no objections.
Index: conf/param.c
===================================================================
RCS file: /a/cvsroot/src/sys/conf/param.c,v
retrieving revision 1.16
diff -u -r1.16 param.c
--- param.c 1996/03/12 03:08:40 1.16
+++ param.c 1996/07/14 18:51:02
@@ -170,3 +170,20 @@
char *buffers;
struct utsname utsname;
+
+/*
+ * These control when and to what priority a process gets after a certain
+ * amount of CPU time expires. AUTONICETIME is in seconds.
+ */
+#ifdef AUTONICETIME
+int autonicetime = AUTONICETIME;
+#else
+int autonicetime = (60 * 10); /* 10 minutes */
+#endif
+
+#ifdef AUTONICEVAL
+int autoniceval = AUTONICEVAL;
+#else
+int autoniceval = NZERO + 4; /* default + 4 (usually 0 + 4) */
+#endif
+
Index: kern/kern_synch.c
===================================================================
RCS file: /a/cvsroot/src/sys/kern/kern_synch.c,v
retrieving revision 1.37
diff -u -r1.37 kern_synch.c
--- kern_synch.c 1996/04/22 01:38:37 1.37
+++ kern_synch.c 1996/07/14 18:51:09
@@ -598,8 +598,8 @@
rlim->rlim_cur += 5;
}
}
- if (s > 10 * 60 && p->p_ucred->cr_uid && p->p_nice == NZERO) {
- p->p_nice = NZERO + 4;
+ if (autonicetime && s > autonicetime && p->p_ucred->cr_uid && p->p_nice == NZERO) {
+ p->p_nice = autoniceval;
resetpriority(p);
}
Index: kern/kern_sysctl.c
===================================================================
RCS file: /a/cvsroot/src/sys/kern/kern_sysctl.c,v
retrieving revision 1.17
diff -u -r1.17 kern_sysctl.c
--- kern_sysctl.c 1996/05/20 17:49:05 1.17
+++ kern_sysctl.c 1996/07/14 18:51:09
@@ -195,6 +195,7 @@
struct proc *p;
{
int error, level, inthostid;
+ int old_autonicetime;
extern char ostype[], osrelease[], version[];
/* all sysctl names at this level are terminal */
@@ -278,6 +279,19 @@
return (sysctl_rdint(oldp, oldlenp, newp, RAW_PART));
case KERN_NTPTIME:
return (sysctl_ntptime(oldp, oldlenp));
+ case KERN_AUTONICETIME:
+ old_autonicetime = autonicetime;
+ error = sysctl_int(oldp, oldlenp, newp, newlen, &autonicetime);
+ if (autonicetime < 0)
+ autonicetime = old_autonicetime;
+ return (error);
+ case KERN_AUTONICEVAL:
+ error = sysctl_int(oldp, oldlenp, newp, newlen, &autoniceval);
+ if (autoniceval < PRIO_MIN)
+ autoniceval = PRIO_MIN;
+ if (autoniceval > PRIO_MAX)
+ autoniceval = PRIO_MAX;
+ return (error);
default:
return (EOPNOTSUPP);
}
Index: sys/sysctl.h
===================================================================
RCS file: /a/cvsroot/src/sys/sys/sysctl.h,v
retrieving revision 1.16
diff -u -r1.16 sysctl.h
--- sysctl.h 1996/04/09 20:55:36 1.16
+++ sysctl.h 1996/07/14 18:51:19
@@ -134,7 +134,9 @@
#define KERN_RAWPARTITION 24 /* int: raw partition number */
#define KERN_NTPTIME 25 /* struct: extended-precision time */
#define KERN_TIMEX 26 /* struct: ntp timekeeping state */
-#define KERN_MAXID 27 /* number of valid kern ids */
+#define KERN_AUTONICETIME 27 /* int: proc time before autonice */
+#define KERN_AUTONICEVAL 28 /* int: auto nice value */
+#define KERN_MAXID 29 /* number of valid kern ids */
#define CTL_KERN_NAMES { \
{ 0, 0 }, \
@@ -164,6 +166,8 @@
{ "rawpartition", CTLTYPE_INT }, \
{ "ntptime", CTLTYPE_STRUCT }, \
{ "timex", CTLTYPE_STRUCT }, \
+ { "autonicetime", CTLTYPE_INT }, \
+ { "autoniceval", CTLTYPE_INT }, \
}
/*
Index: sys/systm.h
===================================================================
RCS file: /a/cvsroot/src/sys/sys/systm.h,v
retrieving revision 1.50
diff -u -r1.50 systm.h
--- systm.h 1996/06/09 04:55:09 1.50
+++ systm.h 1996/07/14 18:51:19
@@ -72,6 +72,9 @@
extern char version[]; /* system version */
extern char copyright[]; /* system copyright */
+extern int autonicetime; /* time (in seconds) before autoniceval */
+extern int autoniceval; /* proc priority after autonicetime */
+
extern int nblkdev; /* number of entries in bdevsw */
extern int nchrdev; /* number of entries in cdevsw */
extern int nswdev; /* number of swap devices */
--Michael
--
Michael Graff <explorer@flame.org> NetBSD is the way to go!
PGP key on a key-server near you! Netshade the world!
Cthulhu for president: Tired of voting for the *LESSER* of two evils?