public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* Measuring system call times, elapsed and cpu
@ 2007-09-18 23:02 Mike Mason
  2007-09-19  2:36 ` Stone, Joshua I
  0 siblings, 1 reply; 4+ messages in thread
From: Mike Mason @ 2007-09-18 23:02 UTC (permalink / raw)
  To: systemtap

I'm writing a script that attempts to measure how long it takes system calls to finish.  It uses gettimeofday_ns() to get the time at entry and exit, then calculates the delta.  Simple.  It occurred me, however, that a system call can start on one cpu and finish on another.  Now I'm wondering if I can rely on gettimeofday_ns() for this type of measurement.  If not, is there a better way to do this?

I'd also like to break down the system call latency into cpu and wait times.  I thought of calculating the delta of utime+stime from task_struct to get cpu time, then subtracting that from the overall delta to get wait time.  Should this work or am I missing something?

Thanks,
Mike

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

* RE: Measuring system call times, elapsed and cpu
  2007-09-18 23:02 Measuring system call times, elapsed and cpu Mike Mason
@ 2007-09-19  2:36 ` Stone, Joshua I
  2007-09-19 20:32   ` Mike Mason
  0 siblings, 1 reply; 4+ messages in thread
From: Stone, Joshua I @ 2007-09-19  2:36 UTC (permalink / raw)
  To: Mike Mason, systemtap

Mike Mason wrote:
> I'm writing a script that attempts to measure how long it takes
> system calls to finish.  It uses gettimeofday_ns() to get the time at
> entry and exit, then calculates the delta.  Simple.  It occurred me,
> however, that a system call can start on one cpu and finish on
> another.  Now I'm wondering if I can rely on gettimeofday_ns() for
> this type of measurement.  If not, is there a better way to do this?

It should work, with the caveat of bug #3916.  The gettimeofday results
are system time, so they should be consistent across CPUs.

> I'd also like to break down the system call latency into cpu and wait
> times.  I thought of calculating the delta of utime+stime from
> task_struct to get cpu time, then subtracting that from the overall
> delta to get wait time.  Should this work or am I missing something?

This will include any time while you were context-switched away -- is
that your intention?


Josh

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

* Re: Measuring system call times, elapsed and cpu
  2007-09-19  2:36 ` Stone, Joshua I
@ 2007-09-19 20:32   ` Mike Mason
  2007-09-19 21:06     ` Stone, Joshua I
  0 siblings, 1 reply; 4+ messages in thread
From: Mike Mason @ 2007-09-19 20:32 UTC (permalink / raw)
  To: Stone, Joshua I; +Cc: systemtap

Stone, Joshua I wrote:
> Mike Mason wrote:
>> I'm writing a script that attempts to measure how long it takes
>> system calls to finish.  It uses gettimeofday_ns() to get the time at
>> entry and exit, then calculates the delta.  Simple.  It occurred me,
>> however, that a system call can start on one cpu and finish on
>> another.  Now I'm wondering if I can rely on gettimeofday_ns() for
>> this type of measurement.  If not, is there a better way to do this?
> 
> It should work, with the caveat of bug #3916.  The gettimeofday results
> are system time, so they should be consistent across CPUs.
> 
>> I'd also like to break down the system call latency into cpu and wait
>> times.  I thought of calculating the delta of utime+stime from
>> task_struct to get cpu time, then subtracting that from the overall
>> delta to get wait time.  Should this work or am I missing something?
> 
> This will include any time while you were context-switched away -- is
> that your intention?

Poor choice of words on my part.  I meant cpu and non-cpu time, not cpu and wait time.

Now that I think about it some more, utime and stime aren't fine grained enough.  They're only updated every timer tick.  Is there some other way to measure real cpu time between function entry and exit?

Mike

> 
> 
> Josh

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

* RE: Measuring system call times, elapsed and cpu
  2007-09-19 20:32   ` Mike Mason
@ 2007-09-19 21:06     ` Stone, Joshua I
  0 siblings, 0 replies; 4+ messages in thread
From: Stone, Joshua I @ 2007-09-19 21:06 UTC (permalink / raw)
  To: Mike Mason; +Cc: systemtap

Mike Mason wrote:
> Now that I think about it some more, utime and stime aren't fine
> grained enough.  They're only updated every timer tick.  Is there
> some other way to measure real cpu time between function entry and
> exit?

CFS offers better precision through task_utime() and task_stime(), but
those don't appear to be exported.

Josh

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

end of thread, other threads:[~2007-09-19 17:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-18 23:02 Measuring system call times, elapsed and cpu Mike Mason
2007-09-19  2:36 ` Stone, Joshua I
2007-09-19 20:32   ` Mike Mason
2007-09-19 21:06     ` Stone, Joshua I

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).