LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 01-24-2018, 11:21 AM   #1
solarfields
Senior Member
 
Registered: Feb 2006
Location: slackalaxy.com
Distribution: Slackware, CRUX
Posts: 1,449

Rep: Reputation: 997Reputation: 997Reputation: 997Reputation: 997Reputation: 997Reputation: 997Reputation: 997Reputation: 997
system time lags behind hardware time


hi to all,

i am in a bit of a puzzling situation here. I am running -current and the system time lags with 2 sec per minute behind the hardware clock. The hardware clock is correct.

Any ideas how to fix this?
 
Old 01-24-2018, 11:30 AM   #2
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
Pick a time server here: http://www.pool.ntp.org
Then
Code:
ntpdate <time server>
hwclock --systohc
# or use utc if hardware clock set to utc
hwclock --utc --systohc
 
Old 01-24-2018, 12:08 PM   #3
PROBLEMCHYLD
Senior Member
 
Registered: Apr 2015
Posts: 1,201

Rep: Reputation: Disabled
This work as well if you travel much.

https://www.linuxquestions.org/quest...4/#post5678525
 
Old 01-24-2018, 12:11 PM   #4
orbea
Senior Member
 
Registered: Feb 2015
Distribution: Slackware64-current
Posts: 1,950

Rep: Reputation: Disabled
One more relevant article.

https://docs.slackware.com/howtos:network_services:ntp
 
Old 01-24-2018, 12:12 PM   #5
solarfields
Senior Member
 
Registered: Feb 2006
Location: slackalaxy.com
Distribution: Slackware, CRUX
Posts: 1,449

Original Poster
Rep: Reputation: 997Reputation: 997Reputation: 997Reputation: 997Reputation: 997Reputation: 997Reputation: 997Reputation: 997
thanks for the hints guys, but i am not looking for a workaround.

IMHO, losing 2 seconds per minute hints of an issue with the system itself.
 
Old 01-24-2018, 12:33 PM   #6
Darth Vader
Senior Member
 
Registered: May 2008
Location: Romania
Distribution: DARKSTAR Linux 2008.1
Posts: 2,727

Rep: Reputation: 1247Reputation: 1247Reputation: 1247Reputation: 1247Reputation: 1247Reputation: 1247Reputation: 1247Reputation: 1247Reputation: 1247
I have two computers which behave this way, both being Phenom x4 on AM2+ socket over RS780 chipsets.

The cause (identified by me) was an unreliable TSC clocksource, and switching to HPET one fixed the issue.

Last edited by Darth Vader; 01-24-2018 at 01:19 PM.
 
Old 01-24-2018, 12:59 PM   #7
solarfields
Senior Member
 
Registered: Feb 2006
Location: slackalaxy.com
Distribution: Slackware, CRUX
Posts: 1,449

Original Poster
Rep: Reputation: 997Reputation: 997Reputation: 997Reputation: 997Reputation: 997Reputation: 997Reputation: 997Reputation: 997
well, i have never encountered such behaviour. Also, the computer could not synchronise its time by ntp. Maybe 2 sec per minute is too much.
 
Old 01-24-2018, 01:07 PM   #8
Darth Vader
Senior Member
 
Registered: May 2008
Location: Romania
Distribution: DARKSTAR Linux 2008.1
Posts: 2,727

Rep: Reputation: 1247Reputation: 1247Reputation: 1247Reputation: 1247Reputation: 1247Reputation: 1247Reputation: 1247Reputation: 1247Reputation: 1247
I suggest you to try another clocksource.

Basically, it is about adding in the kernel command line something like
Code:
notsc clocksource=hpet
before, you should inspect for the available options
Code:
# the available clocksources
/sys/devices/system/clocksource/clocksource0/available_clocksource

# this one will tell which clocksource you use currently (probably TSC)
/sys/devices/system/clocksource/clocksource0/current_clocksource
Be warned that anything else than TSC or HPET probably would affect seriously the responsiveness of your system.

Last edited by Darth Vader; 01-24-2018 at 01:20 PM.
 
2 members found this post helpful.
Old 01-25-2018, 03:33 AM   #9
solarfields
Senior Member
 
Registered: Feb 2006
Location: slackalaxy.com
Distribution: Slackware, CRUX
Posts: 1,449

Original Poster
Rep: Reputation: 997Reputation: 997Reputation: 997Reputation: 997Reputation: 997Reputation: 997Reputation: 997Reputation: 997
i upgraded the kernel to 4.15-rc9 and so far, it seems to fix the issue. Maybe this has something to do with it?

https://git.kernel.org/pub/scm/linux...&id2=v4.15-rc8

I am marking the thread as SOLVED, but will reopen it if any new problems arise...
 
Old 01-25-2018, 06:30 AM   #10
orbea
Senior Member
 
Registered: Feb 2015
Distribution: Slackware64-current
Posts: 1,950

Rep: Reputation: Disabled
Quote:
Originally Posted by solarfields View Post
thanks for the hints guys, but i am not looking for a workaround.

IMHO, losing 2 seconds per minute hints of an issue with the system itself.
The issue with the system is that you didn't configure ntp...
 
Old 01-25-2018, 06:52 AM   #11
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 8,792

Rep: Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656
Quote:
Originally Posted by orbea View Post
The issue with the system is that you didn't configure ntp...
Being off by 2 seconds every minute is not a lack of configuring ntp. Small drifts are to be expected, but 2 minutes every hour means there is some other issue causing that much drift. Sure, ntp can correct it whenever it syncs with the server, but it's just covering up the problem...
 
Old 01-25-2018, 07:09 AM   #12
orbea
Senior Member
 
Registered: Feb 2015
Distribution: Slackware64-current
Posts: 1,950

Rep: Reputation: Disabled
I think its still probably the best solution. I suspect other solutions would just be ignoring the elephant in the room, that older methods can be unreliable. There is a reason most if not all help on this subject is related to configuring ntp, so unless you have another solution you'd like to propose I'd appreciate it if you didn't mislead the op.

Quote:
The Time Stamp Counter was once an excellent high-resolution, low-overhead way for a program to get CPU timing information. With the advent of multi-core/hyper-threaded CPUs, systems with multiple CPUs, and hibernating operating systems, the TSC cannot be relied upon to provide accurate results — unless great care is taken to correct the possible flaws: rate of tick and whether all cores (processors) have identical values in their time-keeping registers. There is no promise that the timestamp counters of multiple CPUs on a single motherboard will be synchronized. Therefore, a program can get reliable results only by limiting itself to run on one specific CPU. Even then, the CPU speed may change because of power-saving measures taken by the OS or BIOS, or the system may be hibernated and later resumed, resetting the TSC. In those latter cases, to stay relevant, the program must re-calibrate the counter periodically.
https://en.wikipedia.org/wiki/Time_Stamp_Counter#Use
 
Old 01-25-2018, 07:24 AM   #13
solarfields
Senior Member
 
Registered: Feb 2006
Location: slackalaxy.com
Distribution: Slackware, CRUX
Posts: 1,449

Original Poster
Rep: Reputation: 997Reputation: 997Reputation: 997Reputation: 997Reputation: 997Reputation: 997Reputation: 997Reputation: 997
orbea,

i already posted my solution: upgrading to a newer kernel (4.15.0-rc9) fixed the problem. Lagging 2 seconds every minute seemed to me as an indication that something was wrong with the system itself. I can check how kernel 4.14.15 works and if it is also OK -- will write in the requests for -current.

Also, I set up ntp: it failed to sync my clock. I read somewhere that probably my clock was lagging too fast for it to 'catch up'.

Maybe it was even worse than that, my system was gradually falling some 10-15 min behind in a matter of several hours. I did not have the patience to use my stopwatch for so long...

Last edited by solarfields; 01-25-2018 at 07:28 AM.
 
Old 01-25-2018, 07:39 AM   #14
Petri Kaukasoina
Senior Member
 
Registered: Mar 2007
Posts: 1,783

Rep: Reputation: 1460Reputation: 1460Reputation: 1460Reputation: 1460Reputation: 1460Reputation: 1460Reputation: 1460Reputation: 1460Reputation: 1460Reputation: 1460
Quote:
Originally Posted by solarfields View Post
I can check how kernel 4.14.15 works and if it is also OK -- will write in the requests for -current.
This is from ChangeLog-4.14.15. (24 MHz vs 25 MHz means a little more than 2 secs a minute.)

Code:
commit 8352a3fec216b76b645f583f294efc711b3ca1bd
Author: Len Brown <len.brown@intel.com>
Date:   Fri Dec 22 00:27:55 2017 -0500

    x86/tsc: Fix erroneous TSC rate on Skylake Xeon
    
    commit b511203093489eb1829cb4de86e8214752205ac6 upstream.
    
    The INTEL_FAM6_SKYLAKE_X hardcoded crystal_khz value of 25MHZ is
    problematic:
    
     - SKX workstations (with same model # as server variants) use a 24 MHz
       crystal.  This results in a -4.0% time drift rate on SKX workstations.
    
     - SKX servers subject the crystal to an EMI reduction circuit that reduces its
       actual frequency by (approximately) -0.25%.  This results in -1 second per
       10 minute time drift as compared to network time.
    
    This issue can also trigger a timer and power problem, on configurations
    that use the LAPIC timer (versus the TSC deadline timer).  Clock ticks
    scheduled with the LAPIC timer arrive a few usec before the time they are
    expected (according to the slow TSC).  This causes Linux to poll-idle, when
    it should be in an idle power saving state.  The idle and clock code do not
    graciously recover from this error, sometimes resulting in significant
    polling and measurable power impact.
    
    Stop using native_calibrate_tsc() for INTEL_FAM6_SKYLAKE_X.
    native_calibrate_tsc() will return 0, boot will run with tsc_khz = cpu_khz,
    and the TSC refined calibration will update tsc_khz to correct for the
    difference.
    
    [ tglx: Sanitized change log ]
    
    Fixes: 6baf3d61821f ("x86/tsc: Add additional Intel CPU models to the crystal quirk list")
    Signed-off-by: Len Brown <len.brown@intel.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Cc: peterz@infradead.org
    Cc: Prarit Bhargava <prarit@redhat.com>
    Link: https://lkml.kernel.org/r/ff6dcea166e8ff8f2f6a03c17beab2cb436aa779.1513920414.git.len.brown@intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 
4 members found this post helpful.
Old 01-25-2018, 08:19 AM   #15
solarfields
Senior Member
 
Registered: Feb 2006
Location: slackalaxy.com
Distribution: Slackware, CRUX
Posts: 1,449

Original Poster
Rep: Reputation: 997Reputation: 997Reputation: 997Reputation: 997Reputation: 997Reputation: 997Reputation: 997Reputation: 997
ok, I compiled 4.14.15 and it seems the time is kept accurate. I will of course be checking this later... Thank you Petri, for the quote. And, for the record, my CPU is:

Intel(R) Xeon(R) W-2135 CPU
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
hardware clock time differs from system time after setting maxgsp Linux - Hardware 1 02-27-2009 05:24 AM
System time vs Hardware time and Daylight Savings Time Toadman Linux - General 6 03-17-2007 08:12 AM
System time vs Hardware time and Daylight Savings Time Toadman Linux - Networking 6 03-16-2007 07:14 PM
Where does RH8 daily set system time to hardware clock time smartnorman Red Hat 1 05-24-2006 02:42 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 05:35 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration