From: Roberto Ragusa <robertoragusa@technologist.com>
To: linux-kernel@vger.kernel.org
Cc: Roberto Ragusa <robertoragusa@technologist.com>
Subject: [PATCH] A nicer nice scheduling
Date: Sat, 15 Sep 2001 23:58:43 +0200 [thread overview]
Message-ID: <yam8658.2192.152344160@mail.inwind.it> (raw)
Hi,
please consider including this patch in the main kernel.
It was proposed on 11/04/2001 by Rik van Riel
([test-PATCH] Re: [QUESTION] 2.4.x nice level)
This patch has been working great for me, I applied it to
every new kernel out.
Without this patch, a nice=19 busy-looping process is given
15% of CPU cycles when there is a busy-looping nice=0 process.
Well, if one runs background CPU-consuming programs
(dnetc), this patch makes a nice speed boost.
Please CC to me any replies.
diff -urN linux-2.4.8-lmshsbrnc1/include/linux/sched.h linux-2.4.8-lmshsbrnc1_/include/linux/sched.h
--- linux-2.4.8-lmshsbrnc1/include/linux/sched.h Sun Aug 12 10:18:03 2001
+++ linux-2.4.8-lmshsbrnc1_/include/linux/sched.h Sun Aug 12 12:19:16 2001
@@ -305,7 +305,8 @@
* the goodness() loop in schedule().
*/
long counter;
- long nice;
+ short nice_calc;
+ short nice;
unsigned long policy;
struct mm_struct *mm;
int has_cpu, processor;
diff -urN linux-2.4.8-lmshsbrnc1/kernel/sched.c linux-2.4.8-lmshsbrnc1_/kernel/sched.c
--- linux-2.4.8-lmshsbrnc1/kernel/sched.c Sun Aug 12 10:18:03 2001
+++ linux-2.4.8-lmshsbrnc1_/kernel/sched.c Sun Aug 12 12:19:16 2001
@@ -680,8 +680,26 @@
struct task_struct *p;
spin_unlock_irq(&runqueue_lock);
read_lock(&tasklist_lock);
- for_each_task(p)
+ for_each_task(p) {
+ if (p->nice <= 0) {
+ /* The normal case... */
p->counter = (p->counter >> 1) + NICE_TO_TICKS(p->nice);
+ } else {
+ /*
+ * Niced tasks get less CPU less often, leading to
+ * the following distribution of CPU time:
+ *
+ * Nice 0 5 10 15 19
+ * %CPU 100 56 25 6 1
+ */
+ short prio = 20 - p->nice;
+ p->nice_calc += prio;
+ if (p->nice_calc >= 20) {
+ p->nice_calc -= 20;
+ p->counter = (p->counter >> 1) + NICE_TO_TICKS(p->nice);
+ }
+ }
+ }
read_unlock(&tasklist_lock);
spin_lock_irq(&runqueue_lock);
}
--
Roberto Ragusa robertoragusa at technologist.com
next reply other threads:[~2001-09-15 22:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-09-15 21:58 Roberto Ragusa [this message]
2001-09-16 14:24 ` [PATCH] A nicer nice scheduling Giuliano Pochini
-- strict thread matches above, loose matches on Subject: below --
2001-10-22 18:16 Roberto Ragusa
2001-10-22 19:44 ` bill davidsen
[not found] <Pine.LNX.4.10.10110221644570.25216-100000@coffee.psychology.mcmaster.ca>
2001-10-22 22:12 ` Bill Davidsen
[not found] <Pine.LNX.4.10.10110221821120.25216-100000@coffee.psychology.mcmaster.ca>
2001-10-23 15:46 ` Bill Davidsen
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=yam8658.2192.152344160@mail.inwind.it \
--to=robertoragusa@technologist.com \
--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