How to get better precision out of getrusage on the ARM?

Patrick Doyle wpdster at gmail.com
Mon Jan 4 07:46:31 PST 2016


On Fri, Jan 1, 2016 at 1:14 PM, Corey Minyard <tcminyard at gmail.com> wrote:
> Those numbers are statistical, if a tick occurs while something is running,
> that something is assigned the entire timer tick.  So as you have found, you
> can get some pretty unusual numbers on this, especially with short
> intervals.
>
> I have some patches at https://sourceforge.net/projects/microstate that add
> the ability to do accurate accounting of time, if you really need that.
Thank you Corey,
That makes sense.  I have found that using
clock_gettime(CLOCK_THREAD_CPUTIME_ID, ...) provides the information I
require.  I was confused by the accounting of timer ticks, and
especially by the fact that the accounting changed from exactly 1000us
(or 10000us) to a range centered about 1000us as I fiddled with config
parameters.  I felt sure that one of those config options would result
in accounting only such time to a thread as the thread used.
clock_gettime() returns a thread specific timer that I can use.

At this point, I remain confused/disappointed by the 3us time interval
between calls to clock_gettime().  That feels like a long time for a
pair of context switches into the kernel to get the thread timer, but
I guess that's what it is (on my 500 MHz Cortex-A5).

--wpd



More information about the linux-arm-kernel mailing list