From: Ingo Molnar <mingo@elte.hu>
To: "S.Çağlar Onur" <caglar@pardus.org.tr>
Cc: linux-kernel@vger.kernel.org,
Linus Torvalds <torvalds@linux-foundation.org>,
Andrew Morton <akpm@linux-foundation.org>,
Con Kolivas <kernel@kolivas.org>, Nick Piggin <npiggin@suse.de>,
Mike Galbraith <efault@gmx.de>,
Arjan van de Ven <arjan@infradead.org>,
Peter Williams <pwil3058@bigpond.net.au>,
Thomas Gleixner <tglx@linutronix.de>, Willy Tarreau <w@1wt.eu>,
Gene Heskett <gene.heskett@gmail.com>, Mark Lord <lkml@rtr.ca>,
Zach Carter <linux@zachcarter.com>,
Kasper Sandberg <lkml@metanurb.dk>,
buddabrod <buddabrod@gmail.com>,
Srivatsa Vaddagiri <vatsa@in.ibm.com>
Subject: Re: [patch] CFS scheduler, -v7
Date: Sat, 28 Apr 2007 21:24:46 +0200 [thread overview]
Message-ID: <20070428192446.GA18822@elte.hu> (raw)
In-Reply-To: <200704282220.17689.caglar@pardus.org.tr>
[-- Attachment #1: Type: text/plain, Size: 314 bytes --]
* S.Çağlar Onur <caglar@pardus.org.tr> wrote:
> If you want some more output/info etc. please just say, i have both v6
> and v7 available.
could you try the auto-renice patch ontop of -v7:
http://people.redhat.com/mingo/cfs-scheduler/sched-cfs-auto-renice.patch
does this make it behave like -v6?
Ingo
[-- Attachment #2: sched-cfs-auto-renice.patch --]
[-- Type: text/plain, Size: 6597 bytes --]
---
arch/i386/kernel/ioport.c | 17 ++++++++++++++---
arch/x86_64/kernel/ioport.c | 12 ++++++++++--
drivers/block/loop.c | 5 ++++-
include/linux/sched.h | 7 +++++++
kernel/Kconfig.preempt | 17 +++++++++++++++++
kernel/sched.c | 40 ++++++++++++++++++++++++++++++++++++++++
kernel/workqueue.c | 2 +-
mm/oom_kill.c | 4 +++-
8 files changed, 96 insertions(+), 8 deletions(-)
Index: linux/arch/i386/kernel/ioport.c
===================================================================
--- linux.orig/arch/i386/kernel/ioport.c
+++ linux/arch/i386/kernel/ioport.c
@@ -64,9 +64,17 @@ asmlinkage long sys_ioperm(unsigned long
if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
return -EINVAL;
- if (turn_on && !capable(CAP_SYS_RAWIO))
- return -EPERM;
-
+ if (turn_on) {
+ if (!capable(CAP_SYS_RAWIO))
+ return -EPERM;
+ /*
+ * Task will be accessing hardware IO ports,
+ * mark it as special with the scheduler too:
+ */
+#ifdef CONFIG_BOOST_X
+ sched_privileged_task(current);
+#endif
+ }
/*
* If it's the first ioperm() call in this thread's lifetime, set the
* IO bitmap up. ioperm() is much less timing critical than clone(),
@@ -145,6 +153,9 @@ asmlinkage long sys_iopl(unsigned long u
if (level > old) {
if (!capable(CAP_SYS_RAWIO))
return -EPERM;
+#ifdef CONFIG_BOOST_X
+ sched_privileged_task(current);
+#endif
}
t->iopl = level << 12;
regs->eflags = (regs->eflags & ~X86_EFLAGS_IOPL) | t->iopl;
Index: linux/arch/x86_64/kernel/ioport.c
===================================================================
--- linux.orig/arch/x86_64/kernel/ioport.c
+++ linux/arch/x86_64/kernel/ioport.c
@@ -41,8 +41,13 @@ asmlinkage long sys_ioperm(unsigned long
if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
return -EINVAL;
- if (turn_on && !capable(CAP_SYS_RAWIO))
- return -EPERM;
+ if (turn_on) {
+ if (!capable(CAP_SYS_RAWIO))
+ return -EPERM;
+#ifdef CONFIG_BOOST_X
+ sched_privileged_task(current);
+#endif
+ }
/*
* If it's the first ioperm() call in this thread's lifetime, set the
@@ -113,6 +118,9 @@ asmlinkage long sys_iopl(unsigned int le
if (level > old) {
if (!capable(CAP_SYS_RAWIO))
return -EPERM;
+#ifdef CONFIG_BOOST_X
+ sched_privileged_task(current);
+#endif
}
regs->eflags = (regs->eflags &~ X86_EFLAGS_IOPL) | (level << 12);
return 0;
Index: linux/drivers/block/loop.c
===================================================================
--- linux.orig/drivers/block/loop.c
+++ linux/drivers/block/loop.c
@@ -588,7 +588,10 @@ static int loop_thread(void *data)
*/
current->flags |= PF_NOFREEZE;
- set_user_nice(current, -20);
+ /*
+ * The loop thread is important enough to be given a boost:
+ */
+ sched_privileged_task(current);
while (!kthread_should_stop() || lo->lo_bio) {
Index: linux/include/linux/sched.h
===================================================================
--- linux.orig/include/linux/sched.h
+++ linux/include/linux/sched.h
@@ -1268,6 +1268,13 @@ static inline int rt_mutex_getprio(struc
#endif
extern void set_user_nice(struct task_struct *p, long nice);
+/*
+ * Task has special privileges, give it more CPU power:
+ */
+extern void sched_privileged_task(struct task_struct *p);
+
+extern int sysctl_sched_privileged_nice_level;
+
extern int task_prio(const struct task_struct *p);
extern int task_nice(const struct task_struct *p);
extern int can_nice(const struct task_struct *p, const int nice);
Index: linux/kernel/Kconfig.preempt
===================================================================
--- linux.orig/kernel/Kconfig.preempt
+++ linux/kernel/Kconfig.preempt
@@ -63,3 +63,20 @@ config PREEMPT_BKL
Say Y here if you are building a kernel for a desktop system.
Say N if you are unsure.
+config BOOST_X
+ bool "Boost X"
+ default y
+ help
+ This option instructs the kernel to guarantee more CPU time to
+ X than to other tasks, which is useful if you want to have a
+ faster desktop even under high system load.
+
+ This option works by automatically boosting X's priority via
+ renicing it to -10. NOTE: CFS does not suffer from
+ "overscheduling" problems when X is reniced to -10, so if this
+ is a predominantly desktop box it makes sense to select this
+ option.
+
+ Say Y here if you are building a kernel for a desktop system.
+ Say N if you want X to be treated as a normal task.
+
Index: linux/kernel/sched.c
===================================================================
--- linux.orig/kernel/sched.c
+++ linux/kernel/sched.c
@@ -3323,6 +3323,46 @@ out_unlock:
EXPORT_SYMBOL(set_user_nice);
/*
+ * Nice level for privileged tasks. (can be set to 0 for this
+ * to be turned off)
+ */
+int sysctl_sched_privileged_nice_level __read_mostly = -10;
+
+static int __init privileged_nice_level_setup(char *str)
+{
+ sysctl_sched_privileged_nice_level = simple_strtol(str, NULL, 0);
+ return 1;
+}
+__setup("privileged_nice_level=", privileged_nice_level_setup);
+
+/*
+ * Tasks with special privileges call this and gain extra nice
+ * levels:
+ */
+void sched_privileged_task(struct task_struct *p)
+{
+ long new_nice = sysctl_sched_privileged_nice_level;
+ long old_nice = TASK_NICE(p);
+
+ if (new_nice >= old_nice)
+ return;
+ /*
+ * Setting the sysctl to 0 turns off the boosting:
+ */
+ if (unlikely(!new_nice))
+ return;
+
+ if (new_nice < -20)
+ new_nice = -20;
+ else if (new_nice > 19)
+ new_nice = 19;
+
+ set_user_nice(p, new_nice);
+}
+
+EXPORT_SYMBOL(sched_privileged_task);
+
+/*
* can_nice - check if a task can reduce its nice value
* @p: task
* @nice: nice value
Index: linux/kernel/workqueue.c
===================================================================
--- linux.orig/kernel/workqueue.c
+++ linux/kernel/workqueue.c
@@ -355,7 +355,7 @@ static int worker_thread(void *__cwq)
if (!cwq->freezeable)
current->flags |= PF_NOFREEZE;
- set_user_nice(current, -5);
+ sched_privileged_task(current);
/* Block and flush all signals */
sigfillset(&blocked);
Index: linux/mm/oom_kill.c
===================================================================
--- linux.orig/mm/oom_kill.c
+++ linux/mm/oom_kill.c
@@ -293,7 +293,9 @@ static void __oom_kill_task(struct task_
* all the memory it needs. That way it should be able to
* exit() and clear out its resources quickly...
*/
- p->time_slice = HZ;
+ if (p->policy == SCHED_NORMAL || p->policy == SCHED_BATCH)
+ sched_privileged_task(p);
+
set_tsk_thread_flag(p, TIF_MEMDIE);
force_sig(SIGKILL, p);
next prev parent reply other threads:[~2007-04-28 19:26 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-28 15:25 [patch] CFS scheduler, -v7 Ingo Molnar
2007-04-28 19:20 ` S.Çağlar Onur
2007-04-28 19:24 ` Ingo Molnar [this message]
2007-04-28 23:42 ` S.Çağlar Onur
2007-04-29 7:11 ` Ingo Molnar
2007-04-29 12:37 ` S.Çağlar Onur
2007-04-29 15:58 ` Ingo Molnar
2007-04-29 22:29 ` Dennis Brendel
2007-04-30 14:38 ` S.Çağlar Onur
2007-04-28 19:27 ` S.Çağlar Onur
2007-04-29 17:28 ` Prakash Punnoor
2007-05-04 13:05 ` Prakash Punnoor
2007-04-30 16:29 ` Srivatsa Vaddagiri
2007-04-30 18:30 ` Balbir Singh
-- strict thread matches above, loose matches on Subject: below --
2007-04-30 5:20 Al Boldi
2007-05-03 7:45 ` Ingo Molnar
2007-05-03 8:07 ` Ingo Molnar
2007-05-03 11:16 ` Al Boldi
2007-05-03 12:36 ` Ingo Molnar
2007-05-03 13:49 ` Al Boldi
2007-05-03 8:42 ` Al Boldi
2007-05-03 15:02 ` Ting Yang
2007-05-03 15:17 ` Ingo Molnar
2007-05-03 16:00 ` Ting Yang
2007-05-03 19:48 ` Ingo Molnar
2007-05-03 19:57 ` William Lee Irwin III
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=20070428192446.GA18822@elte.hu \
--to=mingo@elte.hu \
--cc=akpm@linux-foundation.org \
--cc=arjan@infradead.org \
--cc=buddabrod@gmail.com \
--cc=caglar@pardus.org.tr \
--cc=efault@gmx.de \
--cc=gene.heskett@gmail.com \
--cc=kernel@kolivas.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@zachcarter.com \
--cc=lkml@metanurb.dk \
--cc=lkml@rtr.ca \
--cc=npiggin@suse.de \
--cc=pwil3058@bigpond.net.au \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=vatsa@in.ibm.com \
--cc=w@1wt.eu \
/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