From: Saravana Kannan <skannan@codeaurora.org>
To: cpufreq <cpufreq@vger.kernel.org>,
linux-arm-msm <linux-arm-msm@vger.kernel.org>
Subject: Re: CPUfreq - udelay() interaction issues
Date: Thu, 22 Apr 2010 14:22:20 -0700 [thread overview]
Message-ID: <4BD0BE0C.3010709@codeaurora.org> (raw)
In-Reply-To: <4BCFC3D0.5080904@codeaurora.org>
Dave, Venkatesh and other maintainers,
Any comments?
Thanks,
Saravana
Saravana Kannan wrote:
> Hi,
>
> I think there are a couple of issues with cpufreq and udelay
> interaction. But that's based on my understanding of cpufreq. I have
> worked with it for sometime now, so hopefully I not completely wrong.
> So, I will list my assumptions and what I think is/are the issue(s) and
> their solutions.
>
> Please correct me if I'm wrong and let me know what you think.
>
> Assumptions:
> ============
> * Let's assume ondemand governor is being used.
> * Ondemand uses one timer per core and they have CPU affinity set.
> * For SMP, CPUfreq core expects the CPUfreq driver to adjust the per-CPU
> jiffies.
> * P1 indicates for lower CPU perfomance levels and P2 indicates a much
> higher CPU pref level (say 10 times faster).
>
> Issue 1: UP (non-SMP) scenario
> ==============================
>
> This issue is also present for SMP case, but I don't want to complicate
> this example with it. For future reference in this thread, let's call
> this "Context switch issue".
>
> Steps:
> - CPU running at P1
> - Driver context calls udelay
> - udelay does loop calculation and starts looping
> - Context switches to ondemand gov timer function
> - Ondemand gov changes CPU to P2
> - Context switches back to Driver context
> - udelay does a delay that's 10 times shorter.
>
> The last point is obviously a bad thing. I'm more concerned about ARM
> arch for the moment, but considering x86 takes a max of 20ms (20000us)
> for udelay, the above scenario looks very possible.
>
> Is there anything I missed that prevents this from happening?
>
> If this really is an issue, then one solution is to make cpufreq defer
> the freq change if some flag indicates that udelay is active. Basically,
> some kind of r/w semaphore or spinlock.
>
> Does this sound like a reasonable solution?
>
> Issue 2: SMP scenario
> =====================
>
> For future reference in this thread, let's call this "CPU affinity issue".
>
> Steps:
> - CPU0 running at P1
> - CPU1 running at P2
> - Driver context calls udelay in CPU0
> - udelay does loop calculation and starts looping
> - Driver context/thread is moved from CPU0 to CPU1
> - udelay does a delay that's 10 times shorter.
>
> Again, the last point is obviously a bad thing. Am I missing anything
> here too? Again, I care more about ARM, but x86 (which a lot more people
> might care about) also seems to be broken if it doesn't use the TSC
> method for the delay.
>
> Assuming we fix Issue 1 (or it's not present) I think an ideal solution
> for this issue is to do something like:
>
> udelay(us)
> {
> set cpu affinity to current CPU;
> Do the usual udelay code;
> restore cpu affinity status;
> }
>
> Does this sound like a reasonable solution?
>
> Thanks,
> Saravana
next prev parent reply other threads:[~2010-04-22 21:22 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-22 3:34 CPUfreq - udelay() interaction issues Saravana Kannan
2010-04-22 21:22 ` Saravana Kannan [this message]
2010-04-22 23:18 ` Thomas Renninger
2010-04-22 23:37 ` Saravana Kannan
2010-04-22 23:21 ` Saravana Kannan
2010-04-23 18:40 ` Mathieu Desnoyers
2010-04-23 19:22 ` Arjan van de Ven
2010-04-23 19:55 ` Mathieu Desnoyers
2010-04-24 18:56 ` Arjan van de Ven
2010-04-24 21:00 ` Mathieu Desnoyers
2010-04-24 23:20 ` Arjan van de Ven
2010-04-24 2:57 ` Saravana Kannan
2010-04-24 2:49 ` Saravana Kannan
2010-04-24 5:56 ` Pavel Machek
2010-04-24 13:58 ` Mathieu Desnoyers
2010-04-27 23:41 ` Saravana Kannan
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=4BD0BE0C.3010709@codeaurora.org \
--to=skannan@codeaurora.org \
--cc=cpufreq@vger.kernel.org \
--cc=linux-arm-msm@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.