public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Ingo Molnar <mingo@redhat.com>,
	Kernel development list <linux-kernel@vger.kernel.org>
Subject: Re: Use of high-res timers
Date: Thu, 31 May 2012 09:36:56 +0200 (CEST)	[thread overview]
Message-ID: <alpine.LFD.2.02.1205310932240.3231@ionos> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1205301419090.1543-100000@iolanthe.rowland.org>

On Wed, 30 May 2012, Alan Stern wrote:

> Thomas, Ingo, or anyone else:
> 
> My driver needs to time a bunch of events, with roughly millisecond
> precision.  Up to now it has used old-fashioned timer_lists and the
> jiffies counter, but I'm switching over to high-resolution timers and
> ktime_get.
> 
> This leads to a few questions (these issues don't seem to be addressed 
> anywhere in Documentation/timers):
> 
> 	Should I be concerned about efficiency?  I may well end up
> 	calling ktime_get several times per millisecond; is it fast
> 	enough for this to be okay?

It better is.
 
> 	I need timed intervals with reliable lower bounds.  Let's say
> 	I call ktime_get twice, maybe once in an interrupt handler and
> 	once in an hrtimer callback (not necessarily on the same CPU).
> 	Some action has to be taken no earlier than 1 ms after the 
> 	first call.  If the second call returns a value that is at 
> 	least 1 ms larger than the first call, is that enough of a 
> 	guarantee?  If not, how much larger does it have to be?

ktime_get() is precise. Can you explain what you are trying to solve ?
 
> 	Which has more overhead: adding and cancelling an hrtimer
> 	several times, or simply letting it expire and returning
> 	immediately from the callback?  (I wouldn't be surprised if
> 	there was no good answer.)

There is no really good answer.

Thanks,

	tglx

  reply	other threads:[~2012-05-31  7:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-30 18:38 Use of high-res timers Alan Stern
2012-05-31  7:36 ` Thomas Gleixner [this message]
2012-05-31 14:31   ` Alan Stern
2012-05-31 15:04     ` Thomas Gleixner
2012-05-31 15:26       ` Luming Yu
2012-05-31 15:27       ` Alan Stern

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=alpine.LFD.2.02.1205310932240.3231@ionos \
    --to=tglx@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=stern@rowland.harvard.edu \
    /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