Re: Schedule idle

Harald Hoyer (Harald.Hoyer@hot.spotline.de)
Wed, 11 Nov 1998 16:05:27 +0100


This is a multi-part message in MIME format.
--------------7F743D880D7F9B61571799ED
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

To Linus:
Someone is playing games with goodness (kswapd ??) setting the priority to a
value, which results in weights > INT_MAX.

Harald Koenig wrote:

> my original feature request (which was solved for us by Ingo's SCHED_IDLE)
> was to run background jobs (esp. `rc5' that time) which shall _not_
> (or only very minimally) compete with other running tasks, even with
> nive-19 tasks (because we're using NQS/LSF style batch jobs which are
> far more important than rc5, but far less important than interactive work).
> so it's not an "important RT" thing in my eyes, `only' an important nuance
> of scheduling policy.
>
> if there is another solution which will claim only some very few % of CPU-time
> for those background/idle jobs (vs. nice-19 tasks) I'd be happy to use it...
>

What about this patch:

sched.patch - attached .... the kernel patch required
idle.c - attached .... an example idle task

How it works:
SCHED_OTHER now accepts rt_priority. This priority is a negative one, like the
nice value. The real idle task has goodness -1000. If the goodness for our idle
task is computed, rt_priority * (-1) will be added to its weight, resulting in
lower numbers than every other processes, even if their timeslice is over.

--
»»»» Harald Hoyer ««»» mailto:HarryH@Royal.Net ««»» http://hot.spotline.de ««««
···············································································
Software production is assumed to be a line function, but it is run
like a staff function.

-- Paul Licker --------------7F743D880D7F9B61571799ED Content-Type: text/plain; charset=us-ascii; name="sched.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="sched.patch"

--- linux/kernel/sched.c.orig Wed Nov 11 14:34:56 1998 +++ linux/kernel/sched.c Wed Nov 11 15:47:44 1998 @@ -302,10 +302,15 @@ /* .. and a slight advantage to the current thread */ if (p->mm == prev->mm) weight += 1; - weight += p->priority; + + /* some like it hot ... but who is it ??? */ + if (p->priority + (unsigned long)weight < INT_MAX) + weight += p->priority; + else + weight = INT_MAX; } - return weight; + return weight - p->rt_priority; } /* @@ -594,7 +599,7 @@ } /* Do we need to re-calculate counters? */ - if (!c) { + if ((c <= 0) && (c > (-100)) ){ struct task_struct *p; read_lock(&tasklist_lock); for_each_task(p) @@ -1458,9 +1463,10 @@ retval = -EINVAL; if (lp.sched_priority < 0 || lp.sched_priority > 99) goto out_unlock; +/* if ((policy == SCHED_OTHER) != (lp.sched_priority == 0)) goto out_unlock; - +*/ retval = -EPERM; if ((policy == SCHED_FIFO || policy == SCHED_RR) && !capable(CAP_SYS_NICE))

--------------7F743D880D7F9B61571799ED Content-Type: text/plain; charset=us-ascii; name="idle.c" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="idle.c"

#include <sched.h> #include <stdio.h>

int main() { struct sched_param p; int loop; p.sched_priority = 99; if ( sched_setscheduler(0, SCHED_OTHER, &p) ) { perror("set_scheduler"); return 10; } for(;;) { loop++; } }

--------------7F743D880D7F9B61571799ED--

- 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/