public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Richard Henderson <rth7680@gmail.com>
To: john stultz <johnstul@us.ibm.com>
Cc: ink@jurassic.park.msu.ru, lkml <linux-kernel@vger.kernel.org>,
	linux-alpha@vger.kernel.org
Subject: Re: [PATCH] Convert alpha to use arch_gettimeoffset()
Date: Fri, 12 Jun 2009 00:03:26 -0700	[thread overview]
Message-ID: <4A31FDBE.3030506@gmail.com> (raw)
In-Reply-To: <1244758210.7192.5.camel@localhost.localdomain>

john stultz wrote:
> I suspect the alpha arch could even be further improved to provide and
> rpcc() based clocksource, but not having the hardware, I don't feel
> comfortable attempting the more complicated conversion (but I'd be glad
> to help if anyone else is interested).

Unfortunately this isn't possible.  The rpcc value is only 32-bits wide,
and so rolls over in approx 3 to 4 seconds.  Thus all the contortions to
try and use the truncated value for sub 1 second adjustments.

> +	delta_cycles = rpcc() - state.last_time;
> +	partial_tick = state.partial_tick;
>  	/*
>  	 * usec = cycles * ticks_per_cycle * 2**48 * 1e6 / (2**48 * ticks)
>  	 *	= cycles * (s_t_p_c) * 1e6 / (2**48 * ticks)
> @@ -448,62 +437,9 @@ do_gettimeofday(struct timeval *tv)
>  	delta_usec = ((delta_usec / ((1UL << (FIX_SHIFT-6-1)) * HZ)) + 1) / 2;
>  #endif
...
> +	return delta_usec * 1000;

If we're going to be computing nsec now, we might as well adjust
the computation here.

   nsec = cycles * ticks_per_cycle * 1e9 / HZ
        = cycles * s_t_p_c * 1e9 / (2**48 * HZ)
        = cycles * s_t_p_c * 1953125 / (2**39 * HZ)

   delta_nsec = delta_cycles*state.scaled_ticks_per_cycle + partial_tick;
   delta_nsec *= 1953125
   delta_nsec /= HZ << (FIX_SHIFT - 9 - 1);
   delta_nsec = (delta_nsec + 1) / 2;

As far as I can tell, the range of the dividend is about 7e17,
which still fits in an unsigned long.


r~


  parent reply	other threads:[~2009-06-12  7:03 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-11 22:10 [PATCH] Convert alpha to use arch_gettimeoffset() john stultz
2009-06-11 22:21 ` Dialup Jon Norstog
2009-06-11 22:52 ` [PATCH] Convert m32r " john stultz
2009-06-12  7:03 ` Richard Henderson [this message]
2009-06-12 18:41   ` [PATCH] Convert alpha " john stultz
2009-06-16 17:45     ` Richard Henderson
2009-06-17 15:29       ` Ivan Kokshaysky
2009-07-17  0:09 ` [RESEND][PATCH] Convert m32r " john stultz
2009-07-17  0:17 ` [PATCH] Convert cris " john stultz
2009-07-17  0:20 ` [PATCH] Convert m68k " john stultz
2009-07-17  0:25 ` [PATCH] Convert blackfin " john stultz
2009-07-17  2:26   ` Mike Frysinger
2009-07-17  5:17     ` john stultz
2009-07-17  5:33     ` john stultz
2009-07-20  8:24       ` Mike Frysinger

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=4A31FDBE.3030506@gmail.com \
    --to=rth7680@gmail.com \
    --cc=ink@jurassic.park.msu.ru \
    --cc=johnstul@us.ibm.com \
    --cc=linux-alpha@vger.kernel.org \
    --cc=linux-kernel@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