From: Kurt Garloff <garloff@suse.de>
To: Linux kernel list <linux-kernel@vger.kernel.org>
Subject: dynamic sched timeslices
Date: Mon, 15 Mar 2004 23:42:01 +0100 [thread overview]
Message-ID: <20040315224201.GX4452@tpkurt.garloff.de> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 1073 bytes --]
Hi,
attached patch allows userspace to tune the scheduling timeslices.
It can be used for a couple of things:
* Tune a workload for batch processing:
You'd probably wnat to use long timeslices in order to not reschedule
as often to make good use of your CPU caches
* Tune a workload for interactive use:
Under load, you may want to reduce the scedulilng latencies by using
shorter timeslices (and there are situations where the interactiviy
tweak -- even if they were perfect -- can't save you).
* Tune the ration betweeen maximum and minimum timeslices to make
nice much nicer e.g.
The patch exports /proc/sys/kernel/max_timeslice and min_timeslice,
unites are us. It also exports HZ (readonly).
The patch implementes the desktop boot parameter which introduces
shorter timeslices.
Patch is from andrea and is in our 2.4 tree; 2.6 port was done by me and
straightforward.
Regards,
--
Kurt Garloff <garloff@suse.de> Cologne, DE
SUSE LINUX AG, Nuernberg, DE SUSE Labs (Head)
[-- Attachment #1.2: dynamic-timeslice.diff --]
[-- Type: text/plain, Size: 3827 bytes --]
diff -uNrp linux-2.6.4/include/linux/sched.h linux-2.6.4.sched/include/linux/sched.h
--- linux-2.6.4/include/linux/sched.h 2004-03-11 21:01:41.746772792 +0100
+++ linux-2.6.4.sched/include/linux/sched.h 2004-03-11 21:24:41.208062800 +0100
@@ -176,6 +176,7 @@ extern unsigned long cache_decay_ticks;
#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 -uNrp linux-2.6.4/include/linux/sysctl.h linux-2.6.4.sched/include/linux/sysctl.h
--- linux-2.6.4/include/linux/sysctl.h 2004-03-11 21:01:41.747772640 +0100
+++ linux-2.6.4.sched/include/linux/sysctl.h 2004-03-11 21:32:32.968344336 +0100
@@ -134,6 +134,9 @@ enum
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: interal kernel HZ */
};
diff -uNrp linux-2.6.4/kernel/sched.c linux-2.6.4.sched/kernel/sched.c
--- linux-2.6.4/kernel/sched.c 2004-03-11 21:01:41.752771880 +0100
+++ linux-2.6.4.sched/kernel/sched.c 2004-03-11 22:06:26.166251272 +0100
@@ -79,12 +79,19 @@ EXPORT_SYMBOL(dump_oncpu);
/*
* 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
+#define __MIN_TIMESLICE_DESKTOP 2000
+#define __MAX_TIMESLICE_DESKTOP 60000
+/* 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
@@ -2965,3 +2972,13 @@ task_t *kdb_cpu_curr(int cpu)
return(cpu_curr(cpu));
}
#endif
+
+static int __init init_desktop(char *str)
+{
+ min_timeslice = __MIN_TIMESLICE_DESKTOP;
+ max_timeslice = __MAX_TIMESLICE_DESKTOP;
+ return 1;
+}
+__setup("desktop", init_desktop);
+
+
diff -uNrp linux-2.6.4/kernel/sysctl.c linux-2.6.4.sched/kernel/sysctl.c
--- linux-2.6.4/kernel/sysctl.c 2004-03-11 21:01:37.983344920 +0100
+++ linux-2.6.4.sched/kernel/sysctl.c 2004-03-11 21:36:26.253879544 +0100
@@ -167,6 +167,7 @@ static void register_proc_table(ctl_tabl
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 @@ static ctl_table kern_table[] = {
.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 --]
next reply other threads:[~2004-03-15 22:44 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-03-15 22:42 Kurt Garloff [this message]
2004-03-15 22:59 ` Christoph Hellwig
2004-03-15 23:09 ` Kurt Garloff
2004-03-15 23:40 ` Andrew Morton
2004-03-16 11:36 ` Kurt Garloff
2004-03-16 13:13 ` Con Kolivas
2004-03-16 14:29 ` Kurt Garloff
2004-03-16 20:45 ` Con Kolivas
2004-03-18 0:20 ` Kurt Garloff
2004-03-18 0:32 ` Andrew Morton
2004-03-18 3:38 ` Con Kolivas
2004-03-16 15:03 ` Timothy Miller
2004-03-16 15:08 ` Kurt Garloff
2004-03-23 9:23 ` Pavel Machek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040315224201.GX4452@tpkurt.garloff.de \
--to=garloff@suse.de \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®