From: Andi Kleen <andi@firstfloor.org>
To: Chris Peterson <cpeterso@cpeterso.com>
Cc: linux-kernel@vger.kernel.org, tglx@linutronix.de
Subject: Re: [RFC] mod_timer() helper functions?
Date: Mon, 18 May 2009 09:14:21 +0200 [thread overview]
Message-ID: <87eiumq3w2.fsf@basil.nowhere.org> (raw)
In-Reply-To: <a24804730905160036j2720c557o347cec1513df9c4a@mail.gmail.com> (Chris Peterson's message of "Sat, 16 May 2009 00:36:15 -0700")
Chris Peterson <cpeterso@cpeterso.com> writes:
>
> Any suggestions? Is there enough value to warrant adding helper
> function like these as an alternative to mod_timer()?
I like the basic idea. The opencoding has always annoyed me.
>
>
> chris
>
> ---
> static inline int mod_timer_seconds(struct timer_list *timer, time_t seconds)
I would prefer a name like mod_timer_in_secs() to make it clear it's relative
> {
> 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));
This is a bit misleading because depending on HZ the accuracy is far from
a millisecond (worst case 10ms error with HZ==100). Naming should make
that clearer. Or maybe these users should all switch to hrtimers,
but then those could be not available either.
I suspect you also want a helper for longer term delays that uses
deferred timers or more aggressive rounding.
> }
>
> static inline int mod_timer_yield(struct timer_list *timer)
> {
> /* After these messages, we'll be right back. */
> return mod_timer(timer, jiffies + 1);
Can't say I like the name here, although I don't have a better one.
-Andi
--
ak@linux.intel.com -- Speaking for myself only.
next prev parent reply other threads:[~2009-05-18 7:14 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2009-05-20 7:11 ` Chris Peterson
2009-05-20 8:14 ` Andi Kleen
2009-05-21 5:11 ` Chris Peterson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87eiumq3w2.fsf@basil.nowhere.org \
--to=andi@firstfloor.org \
--cc=cpeterso@cpeterso.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox