public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Chris Metcalf <cmetcalf@tilera.com>
To: John Stultz <johnstul@us.ibm.com>
Cc: lkml <linux-kernel@vger.kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH 04/10] tile: convert to use clocksource_register_hz
Date: Thu, 11 Nov 2010 16:21:52 -0500	[thread overview]
Message-ID: <4CDC5E70.90102@tilera.com> (raw)
In-Reply-To: <1288642350-1599-5-git-send-email-johnstul@us.ibm.com>

On 11/1/2010 4:12 PM, John Stultz wrote:
> Convert tile to use clocksource_register_hz.
>
> Untested. Help from maintainers would be appreciated.
>
> CC: Chris Metcalf <cmetcalf@tilera.com>
> CC: Thomas Gleixner <tglx@linutronix.de>
> Signed-off-by: John Stultz <johnstul@us.ibm.com>
> ---
>  arch/tile/kernel/time.c |    5 +----
>  1 files changed, 1 insertions(+), 4 deletions(-)
>
> diff --git a/arch/tile/kernel/time.c b/arch/tile/kernel/time.c
> index 6bed820..8c06cb2 100644
> --- a/arch/tile/kernel/time.c
> +++ b/arch/tile/kernel/time.c
> @@ -76,7 +76,6 @@ static struct clocksource cycle_counter_cs = {
>  	.rating = 300,
>  	.read = clocksource_get_cycles,
>  	.mask = CLOCKSOURCE_MASK(64),
> -	.shift = 22,   /* typical value, e.g. x86 tsc uses this */
>  	.flags = CLOCK_SOURCE_IS_CONTINUOUS,
>  };

We were using clocksource_calc_mult_shift() for a while to compute both
this value and our sched_clock() value, and, like
clocksource_register_hz(), it suggested that a shift value of 31 was best.

Perhaps unsurprisingly, we saw wraparound with sched_clock(), which is why
we use a fixed shift value of "10" to avoid problems.  This is clearly
required since sched_clock() values are fairly long-lived.

I admit that I don't really understand what the wraparound implications of
using a shift of "31" for the clocksource is, but since it will cause the
clocksource to wrap around fairly quickly, I wanted to make sure this shift
value was OK for whatever uses that clocksource is put to.  (The underlying
clock in question is a 64-bit cycle counter, so with "<< 31" at e.g. 1 GHz
it will wrap negative after about four seconds.)

> @@ -89,8 +88,6 @@ void __init setup_clock(void)
>  	cycles_per_sec = hv_sysconf(HV_SYSCONF_CPU_SPEED);
>  	sched_clock_mult =
>  		clocksource_hz2mult(cycles_per_sec, SCHED_CLOCK_SHIFT);
> -	cycle_counter_cs.mult =
> -		clocksource_hz2mult(cycles_per_sec, cycle_counter_cs.shift);
>  }
>  
>  void __init calibrate_delay(void)
> @@ -105,7 +102,7 @@ void __init calibrate_delay(void)
>  void __init time_init(void)
>  {
>  	/* Initialize and register the clock source. */
> -	clocksource_register(&cycle_counter_cs);
> +	clocksource_register_hz(&cycle_counter_cs, cycles_per_sec);
>  
>  	/* Start up the tile-timer interrupt source on the boot cpu. */
>  	setup_tile_timer();
-- 
Chris Metcalf, Tilera Corp.
http://www.tilera.com


  reply	other threads:[~2010-11-11 21:21 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-01 20:12 [PATCH 00/10] clocksource_register_khz/hz cleanups (for 2.6.38) John Stultz
2010-11-01 20:12 ` [PATCH 01/10] x86: Convert untested clocksources to clocksource_register_hz/khz John Stultz
2010-11-01 20:12 ` [PATCH 02/10] ia64: convert " John Stultz
2010-11-01 20:12 ` [PATCH 03/10] cris: convert to clocksource_register_khz John Stultz
2010-11-01 20:12 ` [PATCH 04/10] tile: convert to use clocksource_register_hz John Stultz
2010-11-11 21:21   ` Chris Metcalf [this message]
2010-11-11 22:06     ` john stultz
2010-11-11 22:22       ` Peter Zijlstra
2010-11-11 23:21         ` john stultz
2010-11-11 22:17     ` john stultz
2010-11-01 20:12 ` [PATCH 05/10] parisc: convert to clocksource_register_hz/khz John Stultz
2010-11-01 20:12 ` [PATCH 06/10] microblaze: " John Stultz
2010-11-10 13:10   ` Michal Simek
2010-11-01 20:12 ` [PATCH 07/10] avr32: Convert to clocksource_register_hz John Stultz
2010-11-01 20:12 ` [PATCH 08/10] blackfin: convert " John Stultz
2010-11-01 20:12 ` [PATCH 09/10] xtensa: convert to clocksource_register_hz/khz John Stultz
2010-11-01 20:12 ` [PATCH 10/10] sparc: " John Stultz

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=4CDC5E70.90102@tilera.com \
    --to=cmetcalf@tilera.com \
    --cc=johnstul@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /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