# AMD AM2 X2 Timing problems [SOLVED]

## qQsh

I am using AMD AM2 X2 5600+ (mobo: ASUS M2NPV-VM with nForce 430 chipset) on Gentoo Linux server and i got exactly the same timing problems which are expecting Windows users before they install "AMD Dual-core optimizer". Errors are like "system time went backwards".

The question is - what "AMD Dual-core optimizer for windows" actually does and how to get same effect under Linux? Maybe i need to do some magic with timers options in kernel configuration? I am using gentoo-sources-2.6.22-r8 and there is config: http://pastebin.ca/812075

Thanks.

Some info:

```
Portage 2.1.3.9 (default-linux/x86/no-nptl, gcc-4.1.2, glibc-2.5-r4, 2.6.22-gentoo-r8-shal3r i686)

=================================================================

System uname: 2.6.22-gentoo-r8-shal3r i686 AMD Athlon(tm) 64 X2 Dual Core Processor 5600+

Timestamp of tree: Sat, 13 Oct 2007 11:30:01 +0000

distcc 2.18.3 i686-pc-linux-gnu (protocols 1 and 2) (default port 3632) [disabled]

app-shells/bash:     3.2_p17

dev-lang/python:     2.4.4-r5

dev-python/pycrypto: 2.0.1-r6

sys-apps/baselayout: 1.12.9-r2

sys-apps/sandbox:    1.2.17

sys-devel/autoconf:  2.61-r1

sys-devel/automake:  1.6.3, 1.10

sys-devel/binutils:  2.17-r1

sys-devel/gcc-config: 1.3.16

sys-devel/libtool:   1.5.24

virtual/os-headers:  2.6.22-r2

ACCEPT_KEYWORDS="x86"

CBUILD="i686-pc-linux-gnu"

CFLAGS="-march=k8 -O2 -pipe -fomit-frame-pointer"

CHOST="i686-pc-linux-gnu"

CONFIG_PROTECT="/etc"

CONFIG_PROTECT_MASK="/etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/php/apache2-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/cli-php5/ext-active/ /etc/terminfo /etc/udev/rules.d"

CXXFLAGS="-march=k8 -O2 -pipe -fomit-frame-pointer"

DISTDIR="/usr/portage/distfiles"

FEATURES="distlocks metadata-transfer parallel-fetch sandbox sfperms strict unmerge-orphans userfetch"

GENTOO_MIRRORS="http://ftp.linux.ee/pub/gentoo/distfiles/ http://mirror.uni-c.dk/gentoo/ ftp://gentoo.mirrored.ca/ ftp://mirror.nutsmaas.nl/gentoo/ http://mirror.uni-c.dk/gentoo/ http://gentoo.mirrored.ca/"

LINGUAS="unicode en lv"

MAKEOPTS="-j6"

PKGDIR="/usr/portage/packages"

PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --delete-after --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --filter=H_**/files/digest-*"

PORTAGE_TMPDIR="/var/tmp"

PORTDIR="/usr/portage"

SYNC="rsync://rsync.gentoo.org/gentoo-portage"

USE="alsa apache2 apm arts authfile berkdb bitmap-fonts cli cracklib crypt cups curl dri eds emboss encode foomaticdb fortran gd gdbm gif gpm gstreamer gtk2 iconv imlib isdnlog kde libwww mad midi mikmod motif mp3 mpeg mudflap mysql ncurses nls ogg opengl openmp oss pam pcre perl pppd python qt3 qt4 quicktime readline reflection session spl tcpd truetype truetype-fonts type1-fonts unicode vorbis x86 xml xml2 xorg xv zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1 emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mulaw multi null plug rate route share shm softvol" ELIBC="glibc" INPUT_DEVICES="keyboard" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="unicode en lv" USERLAND="GNU" VIDEO_CARDS="apm ark chips cirrus cyrix dummy fbdev glint i128 i740 i810 imstt mach64 mga neomagic nsc nv r128 radeon rendition s3 s3virge savage siliconmotion sis sisusb tdfx tga trident tseng v4l vesa vga via vmware voodoo"

Unset:  CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, LDFLAGS, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, PORTDIR_OVERLAY
```

Last edited by qQsh on Tue Dec 11, 2007 11:11 pm; edited 1 time in total

----------

## energyman76b

well, dmesg would have been much more helpfull.

But to add something useless: I have never seen something like that on a 64bit install with vanilla kernel.org kernels ....

----------

## qQsh

Thanks for reply. 

Everything is in 32bit mode.

And there is dmesg: http://pastebin.ca/812467

----------

## energyman76b

>notsc: Kernel compiled with CONFIG_X86_TSC, cannot disable TSC.

and there it is. The TSC is unstable on AMD64. So the kernel must use some other time source. APIC, PM-timer or HPET.

Please build a kernel with all three of them enabled.

Is there a reason why you don't use a 64bit system?

(and while your are at it, remove microcode update and other intel-only crap from your config. smaller kernel = better kernel).

----------

## qQsh

I could not find any way to disable TSC. Then I asked some people in IRC that`s what i got:

<intr80_> This is a known problem, yes.

<intr80_> when processes migrate between cpus, they may experience shifting of time.

<avx> no need to disable TSC to use HPET or anything

<avx> HPET and friends should be used if they're selected if you have support for them, so it won't care about any other timing mechanism

Any ideas?

BTW, i don`t use 64bit system on this box because it`s for some daemon apps which work better on 32bit.Last edited by qQsh on Tue Dec 11, 2007 9:49 pm; edited 1 time in total

----------

## energyman76b

from my dmesg:

[    0.000000] Marking TSC unstable due to TSCs unsynchronized

and then it is never ever mentioned again. Or used. And I don't experience any timing related problems.

My idea: try latest 2.6.23 kernel BUT NOT gentoo. And maybe switch to a 64bit based system. Just in case. Get a boot cd/dvd and look for the same problems you have now.

----------

## qQsh

The same with vanilla-sources-2.6.23 . Still getting errors like "system time went backwards" or "WARNING! system time difference <= 0"

~ # dmesg | grep -i tsc

~ #  

Any other ideas? What exactly affects that "Marking TSC unstable due to TSCs unsynchronized" ?

----------

## micmac

Hi!

Have a look at /sys/devices/system/clocksource/clocksource0/available_clocksource. There should be multiple entries, for instance acpi_pm (needs ACPI support of course) and possibly HPET (enable it in both kernel and BIOS). The kernel will switch to a different clocksoure automatically. current_clocksource will tell you what source is used right now. Also try disabling any spread spectrum options in your BIOS (some older nforce chip hat time issues with it).

----------

## qQsh

```
rush linux-2.6.23 # cat /sys/devices/system/clocksource/clocksource0/available_clocksource

jiffies tsc

rush linux-2.6.23 # cat /sys/devices/system/clocksource/clocksource0/current_clocksource

jiffies
```

I cannot look in BIOS because this BOX is remote. What`s that "jiffies" and is it ok?

----------

## energyman76b

 *qQsh wrote:*   

> The same with vanilla-sources-2.6.23 . Still getting errors like "system time went backwards" or "WARNING! system time difference <= 0"
> 
> ~ # dmesg | grep -i tsc
> 
> ~ #  
> ...

 

it says that the kernel does not use the tsc because the tsc values between the cores differ.

do you have hpet and acpi pm_timer turned on in your kernel config?

----------

## qQsh

Now i got:

```
rush # zgrep TIMER /proc/config.gz

CONFIG_HIGH_RES_TIMERS=y

CONFIG_X86_CYCLONE_TIMER=y

CONFIG_HPET_TIMER=y

CONFIG_X86_PM_TIMER=y

CONFIG_HANGCHECK_TIMER=y

rush ~ # cat /sys/devices/system/clocksource/clocksource0/available_clocksource

hpet acpi_pm jiffies tsc

rush ~ # cat /sys/devices/system/clocksource/clocksource0/current_clocksource

hpet
```

And it works! Really big thanks to all of you! I love this community  :Smile: .

----------

## energyman76b

 *qQsh wrote:*   

> Now i got:
> 
> rush # zgrep TIMER /proc/config.gz
> 
> CONFIG_HIGH_RES_TIMERS=y
> ...

 

yay! that is great - and you should not get any more 'system time went backwards' errors anymore (btw - cyclone doesn't ring a bell, you should try disabling it. Hangcheck timer is not a timer - it just posts a message and does other stuff if your kernel is hung for a long period of time.)

----------

