Subject: Re: timecounters using broken TSC - PC-engines WRAP time problem
To: None <tech-kern@NetBSD.org>
From: theo borm <theo4490@borm.org>
List: tech-kern
Date: 11/29/2007 17:00:21
Joerg Sonnenberger wrote:

>On Thu, Nov 29, 2007 at 03:24:19PM +0100, theo borm wrote:
>  
>
>>It mentions VMware, and my /guess/ was that timecounters can get confused 
>>when the TSC is modified outside the netbsd scope (and that would suggest 
>>potential problems with XEN too).
>>    
>>
>
>Most modern systems just use the ACPI timer, which has a higher priority
>and is typically a lot more stable.
>
>  
>
>>>Does your system have an AMD Geode SC1100 or similiar? I found a
>>>discussion for Linux that mentioned that the TSC is broken as it is not
>>>incremented during halt.
>>>
>>> 
>>>      
>>>
>>Yes. The fact that the TSC is broken is also mentioned in the dmsg, but 
>>despite this it /is/ used.
>>    
>>
>
>Can you try boot -d and "w tsc_is_broken=1"?
>
>  
>
booting hd0a:netbsd (howto 0x40)
1824524+54500+194292 [150528+141221]=0x2429f4
Stopped at      netbsd:cpu_Debugger+0x4:        popl    %ebp
db> w tsc_is_broken=1
Nothing written.

Hmm.... Continue booting....

brouter -> gdb --write /netbsd
(gdb) set tsc_is_broken=1
(gdb) quit
brouter -> reboot

brouter -> dmesg |grep timecounter
timecounter: Timecounters tick every 10.000 msec
timecounter: Timecounter "i8254" frequency 1189200 Hz quality 100
timecounter: Timecounter "clockinterrupt" frequency 100 Hz quality 0

It seems to work. Thanks.

Is this tsc_is_broken documented? is there a kernel compilation option too?

>>I'm wondering if using the TSC rather than the i8254 by default is such a 
>>good idea. It may be more accurate than the i8254 /when/ it is working, but 
>>if the i8254 clock is more reliable, I would prefer that.
>>    
>>
>
>It is not so much a question of accuracy, but rather that the i8254
>timer is extremely slow on most systems.
>
>  
>
At > 1Mhz I wouldn't call it /extremely/ slow ;-)

It is probably a very naive question, but what use would most (ordinary) 
users have for a clock with better resolution than a microsecond? AFAIK 
this clock is not used to directly time time-critical events (such as 
outputting the next word in an audio stream), only passively, to time 
and order events that occur at their own pace, and I guess the most 
visible type of events (from a user's perspective) are timestamps of files.

regards,

Theo