Re: [PATCH 2/2] block: Convert BDI proportion calculations toflexible proportions

From: Peter Zijlstra
Date: Fri May 18 2012 - 10:34:39 EST


On Fri, 2012-05-18 at 16:24 +0200, Jan Kara wrote:
> Yeah, that should be easy enough so I'll try it that way since I presume
> it's nicer to power usage to use deferred timers if it's reasonably
> possible.

Btw, your current scheme also drifts. Since you do jiffes + 3*HZ you
period might actually be longer if the timer got delayed.

If you keep an external jiffies count like:

unsigned long period_jiffies = jiffies;

void my_timer_func()
{
unsigned long delta = jiffies - period_jiffies;
unsigned long periods = delta / 3*HZ;

age(periods);

period_jiffies += 3*HZ * periods;
mod_timer(&my_timer, period_jiffies);
}


it all works without drift (+- bugs of course).
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/