Bug 14131 - Idle-time in /proc/uptime wrong
Summary: Idle-time in /proc/uptime wrong
Status: CLOSED OBSOLETE
Alias: None
Product: Timers
Classification: Unclassified
Component: Other (show other bugs)
Hardware: All Linux
: P1 low
Assignee: john stultz
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-09-06 12:19 UTC by Johan van Baarlen
Modified: 2012-06-13 16:45 UTC (History)
1 user (show)

See Also:
Kernel Version: 2.6.30.5
Subsystem:
Regression: No
Bisected commit-id:


Attachments
test patch to make /proc/uptime and /proc/stat use same idle calculation (1008 bytes, patch)
2012-01-23 21:08 UTC, john stultz
Details | Diff

Description Johan van Baarlen 2009-09-06 12:19:29 UTC
On my 2.6.30.5 kernel (custom compiled, x86_64), idle secs in /proc/uptime is counting magnitudes slower than it should. Can't say which kernel was last to work fine, took all my systems straight from 2.6.25.10 to 2.6.30.5 before I noticed this little bug.

/proc/uptime:
852863.53 1469.57

/proc/stat:
#     user    nice   system   idle    iowait  irq     softirq
cpu  4071827 348323 9027259 312735370 13759721 514537 715147 0 0
cpu0 1005162  42263 1877666  79928559  2091566 147005 200858 0 0
cpu1  758446 101285 2262592  77679311  4350283  57242  83892 0 0
cpu2 1668611  96271 3056564  75858419  3995871 260496 356803 0 0
cpu3  639608 108504 1830437  79269081  3322001  49794  73594 0 0

Computing back from numbers in /proc/stat, the idletime in /proc/uptime should read 781838.43 instead of 1469.57
Comment 1 john stultz 2010-01-05 01:39:17 UTC
I'm not seeing this on a 2.6.31 kernel. Are you still seeing this with any more recent kernels?
Comment 2 Johan van Baarlen 2010-07-25 14:33:11 UTC
Sorry john for the long delay in following up - I did not exactly rank this as high-priority and never noticed you posted a response.

Latest kernel I have running is a 2.6.31, and this oddity is definitely showing there.

[root@backup2 ~]# cat /proc/uptime; cat  /proc/stat  | grep cpu
2592026.88 2569.52
cpu  11818453 10108 22715895 959211273 40687278 976152 1473425 0 0
cpu0 3146061 1410 4115859 250600571 340377 381680 637221 0 0
cpu1 1126544 3014 3020324 251840161 3042936 69833 120339 0 0
cpu2 1385205 1235 2265371 254987993 555561 8976 18794 0 0
cpu3 6160643 4449 13314341 201782548 36748404 515663 697071 0 0

allcpuidle / numcores / kernelfreq = 959211273 / 4 / 100 = 2398028, this box only sees activity twice a day so about 90% idle CPU sounds perfect.
Comment 3 john stultz 2012-01-23 21:07:41 UTC
Johan: My apologies for such a long delay between updates. Just trying to run over the bug backlog.

I'm still unable to reproduce this on three different x86_64 machines.

That said, looking at the code, I can see that proc/stat and proc/uptime use different methods to calculate idle.
Comment 4 john stultz 2012-01-23 21:08:35 UTC
Created attachment 72181 [details]
test patch to make /proc/uptime and /proc/stat use same idle calculation

Give this a whirl and let me know if it seems to resolve the issue.

Note You need to log in before you can comment on or make changes to this bug.