Commit 2cf13d58 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] CPU scheduler interactivity changes

From: Con Kolivas <kernel@kolivas.org>

Interactivity scheduler tweaks on top of Ingo's A3 interactivity patch.

Interactive credit added to task struct to find truly interactive tasks and
treat them differently.

Extra #defines included as helpers for conversion to/from nanosecond timing,
to work out an average timeslice for nice 0 tasks, and the effective dynamic
priority bonuses that will be given to tasks.

MAX_SLEEP_AVG modified to change dynamic priority by one for a nice 0 task
sleeping or running for one full timeslice.

CREDIT_LIMIT is the number of times a task earns sleep_avg over MAX_SLEEP_AVG
before it is considered HIGH_CREDIT (truly interactive); and -CREDIT_LIMIT is
LOW_CREDIT

TIMESLICE GRANULARITY is modified to be more frequent for more
interactivetasks (10 ms for top 2 dynamic priorities and then halving each
priority belowthat) and less frequent per extra cpu.

JUST_INTERACTIVE_SLEEP logic created to be a sleep_avg consistent with giving
a task enough dynamic priority to remain on the active array.

Task preemption of equal priority tasks is dropped as requeuing with
TIMESLICE_GRANULARITY makes this unecessary.

Dynamic priority bonus simplified.

User tasks that sleep a long time and not waking from uninterruptible sleep
are sought and categorised as idle. Their sleep avg is limited in it's rise to
prevent them becoming high priority and suddenly turning into cpu hogs.

Bonus for sleeping is proportionately higher the lower the dynamic priority of
a task is; this allows for very rapid escalation to interactive status.

Tasks that are LOW_CREDIT are limited in rise per sleep to one priority level.

Non HIGH_CREDIT tasks waking from uninterruptible sleep are sought to detect
cpu hogs waiting on I/O and their sleep_avg rise is limited to just
interactive state to prevent cpu bound tasks from becoming interactive during
I/O wait.

Tasks that earn sleep_avg over MAX_SLEEP_AVG get interactive credits.

On runqueue bonus is not given to non HIGH_CREDIT tasks waking from
uninterruptible sleep.

Forked tasks and their parents get sleep_avg limited to the minimum necessary
to maintain their effective dynamic priority thus preventing repeated forking
from being a way to get highly interactive, but not penalise them noticably
otherwise.

CAN_MIGRATE_TASK cleaned up and modified to work with nanosecond timestamps.

Reverted Ingo's A3 Starvation limit change - it was making interactive tasks
suffer more under increasing load. If a cpu is grossly overloaded and
everyone is going to starve it may as well run interactive tasks
preferentially.

Task requeuing is limited to interactive tasks only (cpu bound tasks dont need
low latency and derive benefit from longer timeslices), and they must have at
least TIMESLICE_GRANULARITY remaining.

HIGH_CREDIT tasks get penalised less sleep_avg the more interactive they are
thus keeping them interactive for bursts but if they become sustained cpu hogs
they will slide increasingly rapidly down the dynamic priority scale.

Tasks that run out of sleep_avg, are still using up cpu time and are not high
or low credit yet get penalised interactive credits to determine LOW_CREDIT
tasks (cpu bound ones).
parent 875ee1e1
......@@ -342,6 +342,7 @@ struct task_struct {
prio_array_t *array;
unsigned long sleep_avg;
long interactive_credit;
unsigned long long timestamp;
int activated;
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment