linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: tcminyard@gmail.com (Corey Minyard)
To: linux-arm-kernel@lists.infradead.org
Subject: How to get better precision out of getrusage on the ARM?
Date: Fri, 1 Jan 2016 12:14:41 -0600	[thread overview]
Message-ID: <5686C211.5040606@gmail.com> (raw)
In-Reply-To: <CAF_dkJBOf87J__X9Gdpb_b0P9NzS44w-bhRaUi+z0EKXLkg_5g@mail.gmail.com>

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.

-corey

On 12/30/2015 09:52 AM, Patrick Doyle wrote:
> On Wed, Dec 30, 2015 at 10:00 AM, Patrick Doyle <wpdster@gmail.com> wrote:
>> Continuing on...
>> I now have a CLOCKSOURCE_OF_DECLARED()'ed 10 MHz clock source running
>> on my ARM processor (Atmel SAMA5D2 Xplained board).  It registers
>> itself through sched_clock_register() to provide a high resolution
>> sched clock.  Once I turned on "Full dynticks CPU time accounting"
>> (CONFIG_VIRT_CPU_ACCOUNTING_GEN), I was able to get better than jiffy
>> resolution from my calls to getrusage(RUSAGE_THREAD,..).  But things
>> still aren't quite right.  I am using getrusage() to provide some
>> runtime profile information to an existing application (that was
>> ported to run on Linux instead of a custom RTOS).  I have code that
>> looks like:
>>
>> tick()
>> // commented out code that used to do something
>> tock()
>>
>> where tick() & tock() are my profile "start" and "stop" points that
>> call getrusage() to record and and accumulate time spent between calls
>> to tick() & tock().  Most of the time, I get a delta of 0 between the
>> two calls, which I expect.  But occasionally, I get a delta ranging
>> between 800us and 1000us, which I don't understand at all.  It seems
>> like my thread is being "charged" for time spent doing something else.
>> Perhaps an interrupt occurred and its time got charged to my thread;
>> perhaps a higher priority thread ran for 1ms, I don't know (yet).
>>
>> Does anybody have any suggestions as to where I might look, or as to
>> what kernel CONFIG options might make the most sense for an
>> application such as this?
>>
>> --wpd
> A couple of more (confusing) data points...
> - Changing the tick rate to 100Hz results in deltas as extreme as 9400us.
> - Using clock_gettime(CLOCK_THREAD_CPUTIME_ID,...) instead of
> getrusage(RUSAGE_THREAD,...) gives much more believable numbers in the
> 15-25us range, but still with a few bizarre excursions to 41, 69, and
> 172us (for one random test case).
>
> --wpd
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2016-01-01 18:14 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-22 14:30 How to get better precision out of getrusage on the ARM? Patrick Doyle
2015-12-22 14:49 ` Russell King - ARM Linux
2015-12-22 14:57   ` Patrick Doyle
2015-12-22 15:13     ` Russell King - ARM Linux
2015-12-22 16:28       ` Patrick Doyle
2015-12-22 21:23         ` Patrick Doyle
2015-12-30 15:00           ` Patrick Doyle
2015-12-30 15:52             ` Patrick Doyle
2016-01-01 18:14               ` Corey Minyard [this message]
2016-01-04 15:46                 ` Patrick Doyle
2016-01-19  4:50                 ` Yang, Wenyou
2016-01-19 14:36                   ` Patrick Doyle
2016-01-20  1:24                     ` Yang, Wenyou
2016-01-20 14:35                     ` Corey Minyard
2016-01-19  0:16             ` Alexandre Belloni
2016-01-19 14:19               ` Patrick Doyle

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=5686C211.5040606@gmail.com \
    --to=tcminyard@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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;
as well as URLs for NNTP newsgroup(s).