From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: scheduler clock for MXS
Date: Tue, 6 Nov 2012 22:46:24 +0000 [thread overview]
Message-ID: <20121106224624.GR28327@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <50998F94.8000908@meduna.org>
On Tue, Nov 06, 2012 at 11:30:44PM +0100, Stanislav Meduna wrote:
> On 06.11.2012 21:20, Russell King - ARM Linux wrote:
> > Well. I just tried an experiment with OMAP4:
> > [ 0.000000] sched_clock: 16 bits at 32kHz, resolution 30517ns,
> wraps every 1999ms
> > ...
> > [ 3.070404] Freeing init memory: 192K
>
>
> OK, so it is not a 16-bit problem either. So where is the
> difference? Could it be that HZ / NO_HZ is playing some
> tricks here and need to be taken into consideration?
>
> I'll try to artificially limit the counter-reading function
> on my hardware to 16 bits and look whether I can also
> reproduce this - probably on Thursday or Friday earliest
> (busy with other tasks now).
>
> If it works I'll resubmit for only the iMX.28 and someone
> who actually has the iMX.23 hardware to experiment with has
> to look at it; the best start is probably to start with
> comparing it to the working OMAP4. If it does not I'll
> try to find the culprit.
I wonder if the NO_HZ slack is preventing the sched_clock epoch update
from happening in time. Hmm.
* round_jiffies - function to round jiffies to a full second
This is probably it. With mine, it's a 32.768kHz clock, so limiting
it to 16-bit gives a wrap period of 2 seconds exactly. We take 10%
off, so the timer would be asked to fire every 1.8s, which would be
rounded up to 2 seconds. That's a little too close for comfort...
Yours on the other hand:
sched_clock: 16 bits at 32kHz, resolution 31250ns, wraps every 2047ms
says that this timer runs at _exactly_ 32kHz (are you sure? If this is
generated from a separate 32k crystal oscilator, it's most likely
32.768kHz because that's the standard crystal frequency. In any case,
this would give a wrap period of just over 2 seconds.
But remember, we take of 10%, so this would give 1843ms. Jiffy
conversion would give 185 jiffies, and rounded up to a second gives
200 jiffies, so again 2 seconds.
I suspect that your timer _does_ run at approximately 32768kHz, meaning
that it _does_ roll over at 2 second intervals. But maybe it's trimmed
to be slightly fast or maybe your kernel's idea of time is slightly
slow - either one of which would then give you this effect.
However, either way, rounding 1.8s up to 2s for a 16-bit 32768kHz
counter isn't going to give reliable results.
I think in this case, we need a version of round_jiffies() which _always_
rounds down. Unfortunately, it doesn't exist. Thomas? What are the
options here?
next prev parent reply other threads:[~2012-11-06 22:46 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <50919AFF.3060602@meduna.org>
[not found] ` <5093D8DE.70505@meduna.org>
[not found] ` <20121105025753.GA26528@S2100-06.ap.freescale.net>
2012-11-05 9:14 ` scheduler clock for MXS [Was: Re: Wakeup latency measured with SCHED_TRACER depends on HZ] Stanislav Meduna
2012-11-05 13:46 ` Shawn Guo
2012-11-05 16:09 ` Stanislav Meduna
2012-11-05 22:28 ` Russell King - ARM Linux
2012-11-06 2:40 ` Shawn Guo
2012-11-06 10:12 ` Russell King - ARM Linux
2012-11-06 13:49 ` Shawn Guo
2012-11-06 20:04 ` Russell King - ARM Linux
2012-11-06 8:34 ` scheduler clock for MXS Stanislav Meduna
2012-11-06 9:45 ` Russell King - ARM Linux
2012-11-06 13:46 ` Shawn Guo
2012-11-06 20:20 ` Russell King - ARM Linux
2012-11-06 22:30 ` Stanislav Meduna
2012-11-06 22:46 ` Russell King - ARM Linux [this message]
2012-11-07 7:13 ` Shawn Guo
2012-11-08 21:27 ` Stanislav Meduna
2012-11-08 22:11 ` Russell King - ARM Linux
2012-11-08 22:45 ` [PATCH] ARM: mxs: Setup scheduler clock Stanislav Meduna
2012-11-12 1:54 ` Shawn Guo
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=20121106224624.GR28327@n2100.arm.linux.org.uk \
--to=linux@arm.linux.org.uk \
--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).