Re: fluctuations in /proc/stat btime field

Kingsley Cheung
2003-03-20T01:36:59Z

On Wed, Mar 19, 2003 at 03:45:54PM +1100, Kingsley Cheung wrote:
> Hi,
>
> On a dual SMP box running SuSE-2.4.19-79 (United Linux rc4), the boot
> time in /proc/stat can vary 1 second when read. I haven't seen this
> on a UP box. Its not a major issue, but I guess its a hindrance if
> one's expecting it to never change:
>
> gen2 12:06:52 ~: grep btime /proc/stat
> btime 1046838984
> gen2 12:07:06 ~: grep btime /proc/stat
> btime 1046838984
> gen2 12:07:07 ~: grep btime /proc/stat
> btime 1046838983
> gen2 12:07:07 ~: grep btime /proc/stat
> btime 1046838983
> gen2 12:07:08 ~: grep btime /proc/stat
> btime 1046838983
> gen2 12:07:09 ~: grep btime /proc/stat
> btime 1046838984
> gen2 12:07:10 ~: grep btime /proc/stat
> btime 1046838984
> gen2 12:07:11 ~: grep btime /proc/stat
> btime 1046838983
>
> I'm not familiar with the way IO-APIC timers work or the interrupt
> timer itself, so can someone explain why this is the case? I'm
> guessing that it might simply be a timing issue between when the
> actual interrupt handling updating jiffies in do_timer and the bottom
> half updating xtime.tv_sec (see kernel/timer.c).
>
> Maybe by caching the btime value so that its only calculated once is
> the way to go. Attached is the suggested fix, as well as the output
> from /proc/cpuinfo & /proc/interrupts.
>
> If someone could get back to me on this it would be much appreciated.
>

Actually, correction: the boot-time does also fluctuate on a UP as
well. Not nice if you want absolute boot-time.

--
Kingsley