public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Con Kolivas <kernel@kolivas.org>
To: linux kernel mailing list <linux-kernel@vger.kernel.org>
Cc: Andrew Morton <akpm@osdl.org>, Ingo Molnar <mingo@elte.hu>
Subject: [PATCH] optional non-interactive mode for cpu scheduler
Date: Tue, 02 Nov 2004 16:31:19 +1100	[thread overview]
Message-ID: <41871BA7.6070300@kolivas.org> (raw)


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

optional non-interactive mode for cpu scheduler



[-- Attachment #1.2: sched-optional_non-interactive.diff --]
[-- Type: text/x-patch, Size: 3292 bytes --]

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 }
 };
 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 256 bytes --]

             reply	other threads:[~2004-11-02  5:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-02  5:31 Con Kolivas [this message]
2004-11-02 12:52 ` [PATCH] optional non-interactive mode for cpu scheduler Ingo Molnar
2004-11-02 13:02   ` Con Kolivas
2004-11-02 13:11     ` Ingo Molnar
2004-11-02 13:40       ` Con Kolivas
2004-11-02 13:52         ` Ingo Molnar
2004-11-02 17:17           ` Kyle Moffett
2004-11-03  9:16           ` Con Kolivas

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=41871BA7.6070300@kolivas.org \
    --to=kernel@kolivas.org \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    /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