Messages in this thread Patch in this message | | | Date | Tue, 02 Nov 2004 16:31:19 +1100 | From | Con Kolivas <> | Subject | [PATCH] optional non-interactive mode for cpu scheduler |
| |
optional non-interactive mode for cpu scheduler
Some environments desire strict control over cpu resources based on nice values without interactive determination.
Add a sysctl (/proc/sys/kernel/interactive) to disable dynamic priority behaviour and interactive reinsertion.
Signed-off-by: Con Kolivas <kernel@kolivas.org>
Index: linux-2.6.10-rc1-mm2/include/linux/sched.h =================================================================== --- linux-2.6.10-rc1-mm2.orig/include/linux/sched.h 2004-11-02 13:20:03.000000000 +1100 +++ linux-2.6.10-rc1-mm2/include/linux/sched.h 2004-11-02 16:03:53.807209246 +1100 @@ -738,6 +738,7 @@ extern int task_prio(const task_t *p); extern int task_nice(const task_t *p); extern int task_curr(const task_t *p); extern int idle_cpu(int cpu); +extern int sched_interactive; void yield(void); Index: linux-2.6.10-rc1-mm2/include/linux/sysctl.h =================================================================== --- linux-2.6.10-rc1-mm2.orig/include/linux/sysctl.h 2004-11-02 13:19:19.000000000 +1100 +++ linux-2.6.10-rc1-mm2/include/linux/sysctl.h 2004-11-02 16:07:46.071023189 +1100 @@ -134,6 +134,7 @@ enum KERN_SPARC_SCONS_PWROFF=64, /* int: serial console power-off halt */ KERN_HZ_TIMER=65, /* int: hz timer on or off */ KERN_UNKNOWN_NMI_PANIC=66, /* int: unknown nmi panic flag */ + KERN_INTERACTIVE=67, /* int: dynamic priorities */ }; Index: linux-2.6.10-rc1-mm2/kernel/sched.c =================================================================== --- linux-2.6.10-rc1-mm2.orig/kernel/sched.c 2004-11-02 14:52:51.000000000 +1100 +++ linux-2.6.10-rc1-mm2/kernel/sched.c 2004-11-02 16:13:48.419712248 +1100 @@ -150,8 +150,8 @@ #define DELTA(p) \ (SCALE(TASK_NICE(p), 40, MAX_BONUS) + INTERACTIVE_DELTA) -#define TASK_INTERACTIVE(p) \ - ((p)->prio <= (p)->static_prio - DELTA(p)) +#define TASK_INTERACTIVE(p) ((sched_interactive) && \ + ((p)->prio <= (p)->static_prio - DELTA(p))) #define INTERACTIVE_SLEEP(p) \ (JIFFIES_TO_NS(MAX_SLEEP_AVG * \ @@ -602,6 +602,13 @@ static inline void enqueue_task_head(str } /* + * This is a sysctl which allows dynamic priorities to be applied based on + * interactive behaviour, and selective interactive reinsertion into the + * active array despite timeslice expiration. + */ +int sched_interactive = 1; + +/* * effective_prio - return the priority that is based on the static * priority but is modified by bonuses/penalties. * @@ -622,6 +629,10 @@ static int effective_prio(task_t *p) if (rt_task(p)) return p->prio; + /* Dynamic priorities are not used with interactive mode off */ + if (!sched_interactive) + return p->static_prio; + bonus = CURRENT_BONUS(p) - MAX_BONUS / 2; prio = p->static_prio - bonus; Index: linux-2.6.10-rc1-mm2/kernel/sysctl.c =================================================================== --- linux-2.6.10-rc1-mm2.orig/kernel/sysctl.c 2004-11-02 13:19:19.000000000 +1100 +++ linux-2.6.10-rc1-mm2/kernel/sysctl.c 2004-11-02 16:06:27.621555227 +1100 @@ -624,6 +624,14 @@ static ctl_table kern_table[] = { .proc_handler = &proc_unknown_nmi_panic, }, #endif + { + .ctl_name = KERN_INTERACTIVE, + .procname = "interactive", + .data = &sched_interactive, + .maxlen = sizeof (int), + .mode = 0644, + .proc_handler = &proc_dointvec, + }, { .ctl_name = 0 } }; [unhandled content-type:application/pgp-signature] | |