Re: dynamic sched timeslices

Kurt Garloff
2004-03-15T23:10:29Z

[-- Attachment #1.1: Type: text/plain, Size: 665 bytes --]

Hi Christoph,

quick response!
On Mon, Mar 15, 2004 at 10:59:39PM +0000, Christoph Hellwig wrote:
> Remove the silly desktop boot parameter and the patch looks basically
> okay to me.

See attachment.

> I remember we had a more complete patch to allow tuning the scheduler
> through sysctls in -mm once, though. Questions is why that one wasn't
> merged and if the same reasons apply to a 'light' version.

Hmm, I fail to remember unfortunately. Probably it had too many knobs.
Andrew?

Regards,
--
Kurt Garloff <garloff@suse.de> Cologne, DE
SUSE LINUX AG, Nuernberg, DE SUSE Labs (Head)

[-- Attachment #1.2: dynamic-timeslice-2.diff --]
[-- Type: text/plain, Size: 3366 bytes --]

diff -uNr linux-2.6.4/include/linux/sched.h linux-2.6.4.dyn-timeslice/include/linux/sched.h
--- linux-2.6.4/include/linux/sched.h 2004-03-16 00:03:52.000000000 +0100
+++ linux-2.6.4.dyn-timeslice/include/linux/sched.h 2004-03-16 00:05:14.000000000 +0100
@@ -176,6 +176,7 @@
#define MAX_SCHEDULE_TIMEOUT LONG_MAX
extern signed long FASTCALL(schedule_timeout(signed long timeout));
asmlinkage void schedule(void);
+extern int max_timeslice, min_timeslice;

struct namespace;

diff -uNr linux-2.6.4/include/linux/sysctl.h linux-2.6.4.dyn-timeslice/include/linux/sysctl.h
--- linux-2.6.4/include/linux/sysctl.h 2004-03-16 00:03:52.000000000 +0100
+++ linux-2.6.4.dyn-timeslice/include/linux/sysctl.h 2004-03-16 00:07:31.000000000 +0100
@@ -134,6 +134,9 @@
KERN_KDB=64, /* int: kdb on/off */
KERN_S390_HZ_TIMER=65, /* int: hz timer on or off */
KERN_DUMP=66, /* directory: dump parameters */
+ KERN_MAXTIMESLICE=67, /* int: nice -20 max timeslice */
+ KERN_MINTIMESLICE=68, /* int: nice +19 min timeslice */
+ KERN_HZ=69, /* unsigned long: internal kernel HZ */
};

diff -uNr linux-2.6.4/kernel/sched.c linux-2.6.4.dyn-timeslice/kernel/sched.c
--- linux-2.6.4/kernel/sched.c 2004-03-16 00:03:52.000000000 +0100
+++ linux-2.6.4.dyn-timeslice/kernel/sched.c 2004-03-16 00:06:14.000000000 +0100
@@ -79,12 +79,17 @@
/*
* These are the 'tuning knobs' of the scheduler:
*
- * Minimum timeslice is 10 msecs, default timeslice is 100 msecs,
- * maximum timeslice is 200 msecs. Timeslices get refilled after
- * they expire.
- */
-#define MIN_TIMESLICE ( 10 * HZ / 1000)
-#define MAX_TIMESLICE (200 * HZ / 1000)
+ * Minimum timeslice is 10 msecs, default timeslice is 150 msecs,
+ * maximum timeslice is 300 msecs. Timeslices get refilled after
+ * they expire.
+ */
+#define __MIN_TIMESLICE 10000
+#define __MAX_TIMESLICE 300000
+/* the sysctl values are exported in usec units to userspace */
+int max_timeslice = __MAX_TIMESLICE, min_timeslice = __MIN_TIMESLICE;
+#define MAX_TIMESLICE ((max_timeslice * HZ + 999999) / 1000000)
+#define MIN_TIMESLICE ((min_timeslice * HZ + 999999) / 1000000)
+
#define ON_RUNQUEUE_WEIGHT 30
#define CHILD_PENALTY 95
#define PARENT_PENALTY 100
diff -uNr linux-2.6.4/kernel/sysctl.c linux-2.6.4.dyn-timeslice/kernel/sysctl.c
--- linux-2.6.4/kernel/sysctl.c 2004-03-16 00:03:52.000000000 +0100
+++ linux-2.6.4.dyn-timeslice/kernel/sysctl.c 2004-03-16 00:05:14.000000000 +0100
@@ -167,6 +167,7 @@
static void unregister_proc_table(ctl_table *, struct proc_dir_entry *);
#endif

+static unsigned long __HZ = HZ;
/* The default sysctl tables: */

static ctl_table root_table[] = {
@@ -642,6 +643,30 @@
.mode = 0444,
.proc_handler = &proc_dointvec,
},
+ {
+ .ctl_name = KERN_MAXTIMESLICE,
+ .procname = "max-timeslice",
+ .data = &max_timeslice,
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = &proc_dointvec,
+ },
+ {
+ .ctl_name = KERN_MINTIMESLICE,
+ .procname = "min-timeslice",
+ .data = &min_timeslice,
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = &proc_dointvec,
+ },
+ {
+ .ctl_name = KERN_HZ,
+ .procname = "HZ",
+ .data = &__HZ,
+ .maxlen = sizeof(long),
+ .mode = 0444,
+ .proc_handler = &proc_dointvec,
+ },
{ .ctl_name = 0 }
};

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]