From: George Anzinger <george@mvista.com>
To: Rune Torgersen <runet@innovsys.com>
Cc: linuxppc-dev@ozlabs.org, linux-kernel@vger.kernel.org
Subject: Re: clock skew on B/W G3
Date: Tue, 04 Oct 2005 12:14:24 -0700 [thread overview]
Message-ID: <4342D490.5020409@mvista.com> (raw)
In-Reply-To: <DCEAAC0833DD314AB0B58112AD99B93B859479@ismail.innsys.innovsys.com>
Rune Torgersen wrote:
>
>
>
>>-----Original Message-----
>>From: Paul Mackerras [mailto:paulus@samba.org]
>>Sent: Tuesday, October 04, 2005 07:49
>>Subject: RE: clock skew on B/W G3
>>
>>I do not believe CLOCK_TICK_RATE affects timekeeping at all on ppc or
>>ppc64 machines, but I could be wrong. Can you show us where and how
>>CLOCK_TICK_RATE affects things?
>
>
> I looked very closely at htis thing earlier this summer because of an
> embedded board that drifted quite severly (15sec a day) with a very
> accureate BITS clock as clock source.
>
> Here goes:
> In arch/ppc/kernel/time.c
> timer_interrupt() gets called every decrementer timeout (about every
> 1/CONFIG_HZ seconds, accuracy depends on how easily your decrementer
> cliock can be divided by CONFIG_HZ)
> this calls do_timer() to do the timer increment.
>
> do_timer is in kernel/timer.c and calls update_times().
> update_times() calls update_wall_time() which in turns calls
> update_wall_time_one_tick()
>
> update_wall_time_one_tick()uses tick_nsec to increment xtime.
>
> tick_nsec is defined as: (kernel/timer.c:561)
> unsigned long tick_nsec = TICK_NSEC;
>
> TICK_NSEC is defined as: (include/linux/jiffies.h:64)
> #define TICK_NSEC (SH_DIV (1000000UL * 1000, ACTHZ, 8))
>
> ACTHZ is defined as: (include/linux/jiffies.h:61)
> #define ACTHZ (SH_DIV (CLOCK_TICK_RATE, LATCH, 8))
>
> LATCH is defined as: (include/linux/jiffies.h:46)
> #define LATCH ((CLOCK_TICK_RATE + HZ/2) / HZ)
>
> which means that tick_nsec depends on CLOCK_TICK_RATE to get its value.
>
> defined as:
> #define CLOCK_TICK_RATE 1193180 /* Underlying HZ */
But this is defined in include/asm/???.h so you should be able to set something more to your liking
(or rather to your archs liking). It is true that it SHOULD be defined as it is used to define
TICK_NSEC which is used to define the jiffies<-->timeval/timespec conversions which would be VERY
slow it it were a variable.
George
--
>
> this clock is completely wrong for most/all ppc.
> It happens to generate a tick_nsec of 999848 which is close enough to
> 1000000 that most people does not notice.
> (tick_nsec is number of nsec per timer tick)
>
> When HZ is 250, TICK_NSEC becomes 4000250.
> While this might not completely explain a 20% change in clock sped, it
> it clearly not acurate either.
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
--
George Anzinger george@mvista.com
HRT (High-res-timers): http://sourceforge.net/projects/high-res-timers/
WARNING: multiple messages have this Message-ID (diff)
From: George Anzinger <george@mvista.com>
To: Rune Torgersen <runet@innovsys.com>
Cc: Paul Mackerras <paulus@samba.org>, Marc <marvin24@gmx.de>,
linuxppc-dev@ozlabs.org, linux-kernel@vger.kernel.org
Subject: Re: clock skew on B/W G3
Date: Tue, 04 Oct 2005 12:14:24 -0700 [thread overview]
Message-ID: <4342D490.5020409@mvista.com> (raw)
In-Reply-To: <DCEAAC0833DD314AB0B58112AD99B93B859479@ismail.innsys.innovsys.com>
Rune Torgersen wrote:
>
>
>
>>-----Original Message-----
>>From: Paul Mackerras [mailto:paulus@samba.org]
>>Sent: Tuesday, October 04, 2005 07:49
>>Subject: RE: clock skew on B/W G3
>>
>>I do not believe CLOCK_TICK_RATE affects timekeeping at all on ppc or
>>ppc64 machines, but I could be wrong. Can you show us where and how
>>CLOCK_TICK_RATE affects things?
>
>
> I looked very closely at htis thing earlier this summer because of an
> embedded board that drifted quite severly (15sec a day) with a very
> accureate BITS clock as clock source.
>
> Here goes:
> In arch/ppc/kernel/time.c
> timer_interrupt() gets called every decrementer timeout (about every
> 1/CONFIG_HZ seconds, accuracy depends on how easily your decrementer
> cliock can be divided by CONFIG_HZ)
> this calls do_timer() to do the timer increment.
>
> do_timer is in kernel/timer.c and calls update_times().
> update_times() calls update_wall_time() which in turns calls
> update_wall_time_one_tick()
>
> update_wall_time_one_tick()uses tick_nsec to increment xtime.
>
> tick_nsec is defined as: (kernel/timer.c:561)
> unsigned long tick_nsec = TICK_NSEC;
>
> TICK_NSEC is defined as: (include/linux/jiffies.h:64)
> #define TICK_NSEC (SH_DIV (1000000UL * 1000, ACTHZ, 8))
>
> ACTHZ is defined as: (include/linux/jiffies.h:61)
> #define ACTHZ (SH_DIV (CLOCK_TICK_RATE, LATCH, 8))
>
> LATCH is defined as: (include/linux/jiffies.h:46)
> #define LATCH ((CLOCK_TICK_RATE + HZ/2) / HZ)
>
> which means that tick_nsec depends on CLOCK_TICK_RATE to get its value.
>
> defined as:
> #define CLOCK_TICK_RATE 1193180 /* Underlying HZ */
But this is defined in include/asm/???.h so you should be able to set something more to your liking
(or rather to your archs liking). It is true that it SHOULD be defined as it is used to define
TICK_NSEC which is used to define the jiffies<-->timeval/timespec conversions which would be VERY
slow it it were a variable.
George
--
>
> this clock is completely wrong for most/all ppc.
> It happens to generate a tick_nsec of 999848 which is close enough to
> 1000000 that most people does not notice.
> (tick_nsec is number of nsec per timer tick)
>
> When HZ is 250, TICK_NSEC becomes 4000250.
> While this might not completely explain a 20% change in clock sped, it
> it clearly not acurate either.
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
--
George Anzinger george@mvista.com
HRT (High-res-timers): http://sourceforge.net/projects/high-res-timers/
next prev parent reply other threads:[~2005-10-04 19:44 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-10-04 15:15 clock skew on B/W G3 Rune Torgersen
2005-10-04 15:15 ` Rune Torgersen
2005-10-04 19:14 ` George Anzinger [this message]
2005-10-04 19:14 ` George Anzinger
-- strict thread matches above, loose matches on Subject: below --
2005-10-04 19:22 Rune Torgersen
2005-10-04 19:22 ` Rune Torgersen
2005-10-03 14:18 Rune Torgersen
2005-10-03 14:18 ` Rune Torgersen
2005-10-04 6:14 ` Marc
2005-10-04 6:14 ` Marc
2005-10-04 22:10 ` Benjamin Herrenschmidt
2005-10-04 22:10 ` Benjamin Herrenschmidt
2005-10-04 22:14 ` Benjamin Herrenschmidt
2005-10-04 22:14 ` Benjamin Herrenschmidt
2005-10-05 6:34 ` Marc
2005-10-05 6:34 ` Marc
2005-10-04 12:48 ` Paul Mackerras
2005-10-04 12:48 ` Paul Mackerras
2005-10-01 12:29 marvin24
2005-10-02 16:46 ` Marc
2005-10-02 16:46 ` Marc
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=4342D490.5020409@mvista.com \
--to=george@mvista.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=runet@innovsys.com \
/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.