All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Deepak Gaur" <dgaur@cdot.in>
To: linux-mips@linux-mips.org
Subject: System clock going slow/fast with ntpdate
Date: Wed, 26 Oct 2016 14:25:24 +0530	[thread overview]
Message-ID: <20161026085306.M18729@cdot.in> (raw)
In-Reply-To: <20161026081208.M10605@cdot.in>

Hello,

I have board with MIPS 34Kc processor and linux-2.6.29 with CONFIG_HZ_250=y set in kernel configuration (i.e 250 timer
interrupts per 1 real second in /proc/interrupts). When I try to synchronize time using ntpdate command, the time gets
synchronized. This resync is being done every 5 min using cron. The clocksource is set to jiffies and is the only source
available. After some time (1 hr and more) the system clock (kernel/software) sometimes starts slowing down and sometime
goes fast. System time increments very slowly i.e 1 sec on system takes 8-9 real seconds (as per wrist watch) or fast 2
sec in 1 real second.

#date 
Tue Oct 25 15:14:05 IST 2016 
 # date 
 Tue Oct 25 15:14:05 IST 2016 
 # date 
 Tue Oct 25 15:14:05 IST 2016 
 # date 
 Tue Oct 25 15:14:05 IST 2016 
 # date 
 Tue Oct 25 15:14:05 IST 2016 
 # date 
 Tue Oct 25 15:14:05 IST 2016 
 # date 
 Tue Oct 25 15:14:05 IST 2016 
 # date 
 Tue Oct 25 15:14:05 IST 2016 
 # date 
 Tue Oct 25 15:14:05 IST 2016 
 # date 
 Tue Oct 25 15:14:06 IST 2016 
 # date 
 Tue Oct 25 15:14:06 IST 2016

(It took 10 date commands to increment from 14:05 to 15:06)

On further analysing the system we found the number of timer interrupts in /proc/interrupts has actually gone down from
250 to 40 every 1 real second

(1) Normal Operation 10 real sec watch window

cat /proc/interrupts

Start of timer  MIPS timer intr count 3856633 
 End of Timer   MIPS timer intr count 3859268

 Timing approximately 10-11 real sec, the interrupts are 263 per sec.

(2) Clock Slow (Less Timer Interrupts)
After ntpdate run for 1 hr once per 5 min

cat /proc/interrupts

 Start of timer  MIPS timer intr count 985072 
 End of Timer   MIPS timer intr count 985492

 985492 - 985072 = 420 in 10 sec (real) = 42 in 1 sec

(3) Fast Clock with ntpdate (More Timer interrupts)

Start of timer  MIPS timer intr count 4068301 
End of Timer   MIPS timer intr count 4073411 
 985492 - 985072 = 5110 in 10 sec (real) = 511 in 1 real sec

ntpdate uses ntp_adjtime()/adjtimex() GNU libc system call for changing system clock and can change it but by a very
small amount.

But the issue is it is changing system clock so much that other application have started behaving erratically, timers
are not expiring in required time etc.. and once the system clock has slowed down/fast it remains in that state.

# cat /sys/devices/system/clocksource/clocksource0/available_clocksource 
 jiffies 
  
 # cat /sys/devices/system/clocksource/clocksource0/current_clocksource   
 jiffies

We are using gcc version 4.5.2  and gnu libc

Please help me in understanding this behaviour of NTP with MIPS Linux and possible fixes if any. Is it a kernel bug or a
configuration issue?

regards,

Deepak Gaur

       reply	other threads:[~2016-10-26  8:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20161026081208.M10605@cdot.in>
2016-10-26  8:55 ` Deepak Gaur [this message]
2016-10-26  9:01   ` System clock going slow/fast with ntpdate Deepak Gaur
2016-11-01 13:49   ` Maciej W. Rozycki
2016-11-01 13:49     ` Maciej W. Rozycki
2016-11-01 16:14   ` Markus Gothe
2016-11-01 19:04     ` Maciej W. Rozycki
2016-11-01 19:04       ` Maciej W. Rozycki
2016-11-01 19:40       ` Markus Gothe
2016-11-01 20:42         ` Maciej W. Rozycki
2016-11-01 20:42           ` Maciej W. Rozycki

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=20161026085306.M18729@cdot.in \
    --to=dgaur@cdot.in \
    --cc=linux-mips@linux-mips.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 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.