Messages in this thread Patch in this message | | | Date | Sun, 11 Apr 1999 19:36:08 +0200 (CEST) | From | Rik van Riel <> | Subject | [PATCH] small scheduling optimization |
| |
Hi,
trying to keep my promise, I'm coding Linux kernel patches again.
The first patch today was an update to the sysctl documentation, sent to Alan, Linus and the kernel-doc mailing list.
This second patch is just a small optimization to the code calling the scheduling code. With a program like rc5des running (nice +19) in the background and NOTHING in the foreground Linux still goes through the scheduler 50 times a second!
This small patch solves that problem by simply not rescheduling if there's nothing else to be run. A quite similar change has increased someone's rc5des keyrate by 3%, but it's probably somewhat less on modern systems. The effect is too small to really care about the change, but IMHO it's the Right Thing(tm)!
You can always grab my latest patches from: http://www.nl.linux.org/~riel/patches/
have fun,
Rik -- Open Source: you deserve to be in control of your data. +-------------------------------------------------------------------+ | Le Reseau netwerksystemen BV: http://www.reseau.nl/ | | Linux Memory Management site: http://humbolt.geo.uu.nl/Linux-MM/ | | Nederlandse Linux documentatie: http://www.nl.linux.org/ | +-------------------------------------------------------------------+
diff -u sched.c.old linux/kernel/sched.c --- linux/kernel/sched.c.old 1999/03/24 02:38:01 +++ linux/kernel/sched.c 1999/04/11 17:17:58 @@ -1367,7 +1367,7 @@ unsigned long user = ticks - system; if (p->pid) { p->counter -= ticks; - if (p->counter < 0) { + if (p->counter < 0 && nr_running > 1) { p->counter = 0; p->need_resched = 1; } diff -u smp.c.old linux/arch/i386/kernel/smp.c --- linux/arch/i386/kernel/smp.c.old 1999/03/24 02:44:14 +++ linux/arch/i386/kernel/smp.c 1999/04/11 17:20:54 @@ -1709,7 +1709,7 @@ update_one_process(p, 1, user, system, cpu); p->counter -= 1; - if (p->counter < 0) { + if (p->counter < 0 && nr_running > smp_num_cpus) { p->counter = 0; p->need_resched = 1; }
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |