yet another scheduler patch
Subsystems (2)
PATCH 1/1 yet another scheduler patch
Yes.... This is another patch for the scheduler interactivity game... :)
This one is based on the scoring algorithm of the ULE scheduler included in the latest freeBSD. Every process descriptor includes two new variables:
sleeptime (the time the process spend in voluntary sleep) and runtime (incremented in scheduler_tick function).
These variable are scaled by the sleeptime_runtime_update() function in such way that their sum doesn't exceed the SLEEP_RUN_MAX value when the effective priority is needed.
The interactive score for each process is calculated with the interactive_score() function (take a look at the patch). If the process int score is less than the INTERACTIVE_THRESHOLD value, the process itself is considered interactive and it get a MIN_TIMESLICE time slice. All the other processes get a time slice proportional to their effective priorities.
I've tried the patch only on a ppc UP machine and it behaves quite well. I've made some tests with volanomark under different loads (eg. listening a song with xmms, playing a movie with xine) and all the results are better than results of the same tests over a vanilla kernel.
Soon as possible i'll set up a web page with the results.
Also the audio-skip problem in xmms is solved. The window-shaking test has been passed :).
If someone wants to give a try he's welcome.
Ciao,
-- Francesco
fs/proc/array.c +10 -1
@@ -154,13 +154,22 @@read_lock (&tasklist_lock); buffer += sprintf(buffer, "State:\t%s\n" + "sleeptime:\t%d\n" + "runtime:\t%d\n" + "prio:\t%d\n" + "static_prio:\t%d\n" "Tgid:\t%d\n" "Pid:\t%d\n" "PPid:\t%d\n" "TracerPid:\t%d\n" "Uid:\t%d\t%d\t%d\t%d\n" "Gid:\t%d\t%d\t%d\t%d\n", - get_task_state(p), p->tgid, + get_task_state(p), + p->sleeptime, + p->runtime, + p->prio, + p->static_prio, + p->tgid, p->pid, p->pid ? p->real_parent->pid : 0, p->pid && p->ptrace ? p->parent->pid : 0, p->uid, p->euid, p->suid, p->fsuid,
include/asm-ppc/bitops.h +6 -2
@@ -284,9 +284,13 @@return __ffs (b[1 ]) +32 ;if (unlikely (b[2 ]))return __ffs (b[2 ]) +64 ; -if (b[3 ]) +if (unlikely (b[3 ]))return __ffs (b[3 ]) +96 ; -return __ffs (b[4 ]) +128 ; +if (unlikely (b[4 ])) +return __ffs (b[4 ]) +128 ; +if (b[5 ]) +return __ffs (b[5 ]) +160 ; +return __ffs (b[6 ]) +192 ; }/**
include/linux/init_task.h +1 -1
@@ -68,7 +68,7 @@ .flags = 0, \ .lock_depth = -1, \ .prio = MAX_PRIO-20, \ - .static_prio = MAX_PRIO-20, \ + .static_prio = MAX_PRIO-100, \ .policy = SCHED_NORMAL, \ .cpus_allowed = CPU_MASK_ALL, \ .mm = NULL, \
include/linux/sched.h +5 -2
@@ -280,7 +280,7 @@#define MAX_USER_RT_PRIO 100#define MAX_RT_PRIO MAX_USER_RT_PRIO -#define MAX_PRIO (MAX_RT_PRIO + 40) +#define MAX_PRIO (MAX_RT_PRIO + 120)/* * Some day this will be a full-fledged user tracking system..
@@ -339,8 +339,11 @@struct list_head run_list;prio_array_t *array; -unsigned long sleep_avg;unsigned long last_run; +unsigned long go_to_sleep; +unsigned runtime; +unsigned sleeptime; +int interactive_score;unsigned long policy;cpumask_t cpus_allowed;
kernel/sched.c +95 -104
320 lines not on this page · raw message
Now my patch works also on x86 platform, and it works well (for me). Please give it a try, any feedback is welcome!
The attached diff is for 2.6.0-test5 and is only for ppc32 and i386 archs
Ciao,
-- Francesco
fs/proc/array.c +10 -1
@@ -154,13 +154,22 @@read_lock (&tasklist_lock); buffer += sprintf(buffer, "State:\t%s\n" + "sleeptime:\t%d\n" + "runtime:\t%d\n" + "prio:\t%d\n" + "static_prio:\t%d\n" "Tgid:\t%d\n" "Pid:\t%d\n" "PPid:\t%d\n" "TracerPid:\t%d\n" "Uid:\t%d\t%d\t%d\t%d\n" "Gid:\t%d\t%d\t%d\t%d\n", - get_task_state(p), p->tgid, + get_task_state(p), + p->sleeptime, + p->runtime, + p->prio, + p->static_prio, + p->tgid, p->pid, p->pid ? p->real_parent->pid : 0, p->pid && p->ptrace ? p->parent->pid : 0, p->uid, p->euid, p->suid, p->fsuid,
include/asm-i386/bitops.h +8 -4
@@ -426,8 +426,8 @@/* * Every architecture must define this function. It's the fastest -* way of searching a 140-bit bitmap where the first 100 bits are -* unlikely to be set. It's guaranteed that at least one of the 140 +* way of searching a 220-bit bitmap where the first 100 bits are +* unlikely to be set. It's guaranteed that at least one of the 220 * bits is cleared. */ static inline int sched_find_first_bit (const unsigned long *b)
@@ -439,8 +439,12 @@if (unlikely (b[2 ]))return __ffs (b[2 ]) +64 ;if (b[3 ]) -return __ffs (b[3 ]) +96 ; -return __ffs (b[4 ]) +128 ; +return __ffs (b[3 ]) +96 ; +if (b[4 ]) +return __ffs (b[4 ]) +128 ; +if (b[5 ]) +return __ffs (b[5 ]) +160 ; +return __ffs (b[6 ]) +192 ; }/**
include/asm-ppc/bitops.h +6 -2
@@ -273,7 +273,7 @@#define hweight8 (x) generic_hweight8(x)/* -* Find the first bit set in a 140-bit bitmap. +* Find the first bit set in a 200-bit bitmap. * The first 100 bits are unlikely to be set. */ static inline int sched_find_first_bit (unsigned long *b)
@@ -286,7 +286,11 @@return __ffs (b[2 ]) +64 ;if (b[3 ])return __ffs (b[3 ]) +96 ; -return __ffs (b[4 ]) +128 ; +if (b[4 ]) +return __ffs (b[4 ]) +128 ; +if (b[5 ]) +return __ffs (b[5 ]) +160 ; +return __ffs (b[6 ]) +192 ; }/**
Binary files linux-2.6.0-test5-orig/include/linux/.vermagic.h.swp and linux-2.6.0-test5/include/linux/.vermagic.h.swp differ
include/linux/init_task.h +1 -1
@@ -68,7 +68,7 @@ .flags = 0, \ .lock_depth = -1, \ .prio = MAX_PRIO-20, \ - .static_prio = MAX_PRIO-20, \ + .static_prio = MAX_PRIO-100, \ .policy = SCHED_NORMAL, \ .cpus_allowed = CPU_MASK_ALL, \ .mm = NULL, \
include/linux/sched.h +5 -2
@@ -280,7 +280,7 @@#define MAX_USER_RT_PRIO 100#define MAX_RT_PRIO MAX_USER_RT_PRIO -#define MAX_PRIO (MAX_RT_PRIO + 40) +#define MAX_PRIO (MAX_RT_PRIO + 120)/* * Some day this will be a full-fledged user tracking system..
@@ -339,8 +339,11 @@struct list_head run_list;prio_array_t *array; -unsigned long sleep_avg;unsigned long last_run; +unsigned long go_to_sleep; +unsigned runtime; +unsigned sleeptime; +int interactive_score;unsigned long policy;cpumask_t cpus_allowed;
kernel/sched.c +94 -103
312 lines not on this page · raw message
Quoted 9 lines · Francesco Sportolari
Now my patch works also on x86 platform, and it works well (for me). Please give it a try, any feedback is welcome!
The attached diff is for 2.6.0-test5 and is only for ppc32 and i386 archs
Ciao,
-- Francesco
Hi, could you alter this so that it does not mess around with kernel threads? It should only adjust user processes. Sorry if it is doing the right thing, but [eg] pdflush has a prio of 100 currently..
In general usage (no load, X 4.3.0 + gnome 2.2.x), applications start up slower.
Under a moderate load (make -j4) xmms will not skip but it fails the wiggle test. Renicing X to -10 (it was at 0 before) does not seem to help.
[Machine is an Athlon 1200 (not a rating) with 384mb ram, ide disks with DMA enabled]
Hope this helps, somehow :-)
- Wade