This patch implements a prototype version of a simplified interactive bonus mechanism. The mechanism does not attempt to identify interactive tasks and give them a bonus (like the current mechanism does) but instead attacks the problem that the bonuses are supposed to fix, unacceptable interactive latency, directly. It does this by measuring every interactive latency and using a Kalman filter to estimate a running average of each tasks' interactive latency. This average is then compared to an "unacceptable interactive latency" value and if it is above this the task's interactive bonus is increased and otherwise it is compared to an "acceptable interactive latency" value and if it is above this value the task's interactive bonus is decreased. This results in the the task's tending to stabilize at a value that keeps its interactive latency between the two limits. As a first approximation this mechanism assumes that all uninterruptible sleeps are not interactive and that all interruptible sleeps are unless they are tagged with the TASK_NONINTERACTIVE flag. Advantages: 1. Simple and (arguably) easy to understand mechanism. 2. Tasks only get interactive bonuses when they need them and this should reduce the amount of preemption that occurs which in turn should reduce the context switching rate. 3. It seems to work (at least for me). Problems addressed: 1. If a task that has acquired an interactive bonus suddenly becomes CPU bound and interactive bonuses are only assessed at wake up they will retain their bonus. This problem is addressed by decrementing all tasks interactive bonuses at the end of their time slice. Problems not addressed: 1. Like the current mechanism, this mechanism is sub optimal if non interactive sleeps are identified as interactive. This problem be fixed with more widespread (but judicious) use of TASK_INTERACTIVE. Things that could be better: 1. The mechanism for decreasing interactive bonuses for CPU bound tasks could be better targetted. Possible Modifications: 1. Increase the maximum available interactive bonus to 19. 2. Do not award interactive bonuses to tasks with nice values greater than zero on the assumption that this is a declaration that interactive latency is not an issue for these tasks. 3. Move the smoothing from the interactive latency to the interactive bonus. I.e. use the raw interactive latency to decide whether the current bonus is increased, decreased or left alone but use a Kalman filter to smooth the bonus value. Signed-off-by: Peter Williams --- Your comments on this proposal are requested. --- fs/proc/array.c | 4 include/linux/sched.h | 19 ++ kernel/sched.c | 259 +++++++++++----------------------------- 3 files changed, 90 insertions(+), 192 deletions(-) -- Peter Williams pwil3058@bigpond.net.au "Learning, n. The kind of ignorance distinguishing the studious." -- Ambrose Bierce