Re: [RFC patch 1/2] sched: dynamically adapt granularity with nr_running

Peter Zijlstra
2010-09-12T10:41:33Z

On Sat, 2010-09-11 at 15:57 -0400, Mathieu Desnoyers wrote:
> The interesting part is in the range from 4 to 8 tasks. I diminish the scheduler
> granularity as the number of tasks increases rather than increasing latency.
> This leads to more scheduler preemptions than usual, but only in the 4-8 running
> tasks range.

I really don't get it.. that's exactly what it does from the 1..3 range
too, if you want to extend that, simply set a lower min_gran, it will
update nr_latency and you get it from 1..(latency/min_gran) range.

And you didn't touch sched_proc_update_handler(), which recomputes
sched_nr_latency when you change sched_latency or sched_min_gran.

So the current stuff is:

period := max(latency, min_gran * nr_running)

or, conversely:

gran := max(min_gran, latency / nr_running)

Which seems to be exactly what you want, no? Its doing that!

Except that in the one place we used 'gran' directly we avoided the
division and used the minimal value: min_gran in all cases, which is a
trade-of favouring latency.