public inbox for linux-sh@vger.kernel.org
 help / color / mirror / Atom feed
From: john stultz <johnstul@us.ibm.com>
To: linux-sh@vger.kernel.org
Subject: Re: [PATCH v2] sh_tmu: compute mult and shift before registration
Date: Mon, 07 Jun 2010 19:28:08 +0000	[thread overview]
Message-ID: <1275938888.3114.9.camel@localhost.localdomain> (raw)
In-Reply-To: <1275342348-22499-1-git-send-email-aurelien@aurel32.net>

On Mon, 2010-06-07 at 16:06 +0900, Magnus Damm wrote:
> Hi everyone,
> 
> [Added clock source hackers to CC]
> 
> On Wed, Jun 2, 2010 at 5:23 PM, Paul Mundt <lethal@linux-sh.org> wrote:
> > On Mon, May 31, 2010 at 11:45:48PM +0200, Aurelien Jarno wrote:
> >> Since commit 98962465ed9e6ea99c38e0af63fe1dcb5a79dc25 ("nohz: Prevent
> >> clocksource wrapping during idle"), the CPU of an R2D board never goes
> >> to idle. This commit assumes that mult and shift are assigned before
> >> the clocksource is registered. As a consequence the safe maximum sleep
> >> time is negative and the CPU never goes into idle.
> >>
> >> This patch fixes the problem by moving mult and shift initialization
> >> from sh_tmu_clocksource_enable() to sh_tmu_register_clocksource().
> >>
> >> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
> >
> > Applied, thanks.
> >
> > I've made a similar change for the sh_cmt driver, too.
> >
> > Both of these should show up in the next 2.6.34-stable release.
> 
> Thanks for this!
> 
> However, with the CMT patch applied the clock seems to run too fast.
> Requesting a 5 second sleep results in less than a second. The
> LED-based heart beat is really busy! =)
> 
> Switching back to a jiffies-based clock source work arounds the
> problem. This is regardless of the CONFIG_NO_HZ setting.
> 
> Proposal:
> 
> Since the clock frequency of the clock provided by the clock framework
> may vary when it is disabled, perhaps it's good to keep the existing
> CMT code as-is and instead work towards updating the generic clock
> source code to calculate values after the clock source has been
> enabled.
> 
> The problem is that we don't know the frequency of the timers at
> registration time. So most of the clock source calculation happens
> after enable today. I added the ->enable() and ->disable() callbacks
> last year to solve this ordering issue. The cs->max_idle_ns variable
> seems to be a special case though.
> 
> Perhaps cs->max_idle_ns can be calculated after the clock source has
> been enabled, for instance inside timerkeeper_setup_internals()?
> 
> Or are there better ways to deal with this?

I recently ran into this issue when looking to convert clocksources from
using clocksource_register() to clocksource_register_hz()/khz().

The point of those patches are to try to remove the mult/shift
calculation from the clocksource driver code, keeping that logic in the
timekeeping core (which will allow for better optimization of other
values like max_idle_ns).

So I'd suggest a generic method to the effect of
"__clocksource_update_hz/khz" which can allow clocksource drivers to
update the freq in enable call path. This can then hook into the
timekeeping core so we update things there.

Does that sound reasonable?

The timekeeping code really isn't expecting clocksource values to change
under it. So we'll also have to carefully review some of the max_idle_ns
users to make sure they can handle the change.

thanks
-john




  parent reply	other threads:[~2010-06-07 19:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-31 21:45 [PATCH v2] sh_tmu: compute mult and shift before registration Aurelien Jarno
2010-06-02  8:23 ` Paul Mundt
2010-06-02  9:10 ` Aurelien Jarno
2010-06-07  7:06 ` Magnus Damm
2010-06-07 19:28 ` john stultz [this message]
2010-06-10  6:20 ` Magnus Damm
2010-06-10 19:27 ` john stultz
2010-06-11  3:03 ` john stultz
2010-06-11  4:38 ` Magnus Damm
2010-06-11  5:02 ` Magnus Damm
2010-06-11  6:01 ` Paul Mundt
2010-06-11  6:33 ` Aurelien Jarno

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=1275938888.3114.9.camel@localhost.localdomain \
    --to=johnstul@us.ibm.com \
    --cc=linux-sh@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox