> > So I'm inclined _not_ to take your patch. One possibility could be to > > do the following: > > > > - for throttling between 0% and 80%, use the current algorithm. At 66%, > > the CPU will work for 10 ms and sleep for 40 ms. > > > > - for throttling above 80% adapt your algorithm to have a variable > > timeslice, going from 50 ms at 66% to 100 ms at 100%. This way, the CPU > > time will shrink below 10 ms and the sleep time will grow.
Oops, all the 66% should be 80%. > It seems odd to have a threshold like that on something that's supposedly > a linear scale. I futzed a bit with the threshold until the first derivative of the CPU time was zero at the threshold, and the result was 80%. That is, if you switch before 80%, the CPU time slice can grow to more than 10 ms right after the threshold, and then start shrinking. > > It looks like this: http://i.imgur.com/lyFie04.png > > > > So at 99% the timeslice will be 97.5 ms; the CPU will work for 975 us > > and sleep for the rest (10x more than with just your patch). But I'm > > not sure it's really worth it. > > Can you really run a CPU for 975us ? It's 2-3 million clock cycles, should be doable. Paolo