public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC] mod_timer() helper functions?
@ 2009-05-16  7:36 Chris Peterson
  2009-05-17  6:03 ` Andrew Morton
  2009-05-18  7:14 ` Andi Kleen
  0 siblings, 2 replies; 9+ messages in thread
From: Chris Peterson @ 2009-05-16  7:36 UTC (permalink / raw)
  To: linux-kernel; +Cc: tglx

Reviewing the kernel's nearly one-thousand calls to mod_timer(), there
are three basic patterns:

 * multi-second timeouts
 * millisecond timeouts
 * +1 jiffie ASAP events

Few mod_timer() calls actually use the function's 'expires' deadline
time without manually calculating 'jiffies + delay'. The following
helper functions could provide a simpler, more descriptive interface
than the low-level mod_timer() function. Also, when scheduling longer
timers, these helper functions could use round_jiffies() to (secretly)
batch timers on whole seconds to reduce power usage.

Any suggestions? Is there enough value to warrant adding helper
function like these as an alternative to mod_timer()?


chris

---
static inline int mod_timer_seconds(struct timer_list *timer, time_t seconds)
{
	return mod_timer(timer, round_jiffies(jiffies + seconds * HZ));
}

static inline int mod_timer_msecs(struct timer_list *timer, unsigned int msecs)
{
	/* TODO? Round jiffies if within some epsilon of a whole second? */
	return mod_timer(timer, jiffies + msecs_to_jiffies(msecs));
}

static inline int mod_timer_yield(struct timer_list *timer)
{
	/* After these messages, we'll be right back. */
	return mod_timer(timer, jiffies + 1);
}

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2009-05-21  5:11 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-16  7:36 [RFC] mod_timer() helper functions? Chris Peterson
2009-05-17  6:03 ` Andrew Morton
2009-05-17  7:50   ` Chris Peterson
2009-05-17  8:03     ` Andrew Morton
2009-05-17 12:13       ` Thomas Gleixner
2009-05-18  7:14 ` Andi Kleen
2009-05-20  7:11   ` Chris Peterson
2009-05-20  8:14     ` Andi Kleen
2009-05-21  5:11       ` Chris Peterson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox