public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Kingsley Cheung <kingsley@aurema.com>
To: linux-kernel@vger.kernel.org
Subject: fluctuations in /proc/stat btime field
Date: Wed, 19 Mar 2003 15:45:54 +1100	[thread overview]
Message-ID: <20030319154554.C3492@aurema.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1284 bytes --]

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.

Thanks,
-- 
		Kingsley

[-- Attachment #2: gen2cpuinfo --]
[-- Type: text/plain, Size: 804 bytes --]

processor	: 0
vendor_id	: GenuineIntel
cpu family	: 6
model		: 6
model name	: Celeron (Mendocino)
stepping	: 5
cpu MHz		: 548.544
cache size	: 128 KB
physical id	: 0
threads		: 1
fdiv_bug	: no
hlt_bug		: no
f00f_bug	: no
coma_bug	: no
fpu		: yes
fpu_exception	: yes
cpuid level	: 2
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr
bogomips	: 1094.45

processor	: 1
vendor_id	: GenuineIntel
cpu family	: 6
model		: 6
model name	: Celeron (Mendocino)
stepping	: 5
cpu MHz		: 548.544
cache size	: 128 KB
physical id	: 0
threads		: 1
fdiv_bug	: no
hlt_bug		: no
f00f_bug	: no
coma_bug	: no
fpu		: yes
fpu_exception	: yes
cpuid level	: 2
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr
bogomips	: 1094.45


[-- Attachment #3: gen2interrupts --]
[-- Type: text/plain, Size: 578 bytes --]

           CPU0       CPU1       
  0:   61761933   59169714    IO-APIC-edge  timer
  1:        163        212    IO-APIC-edge  keyboard
  2:          0          0          XT-PIC  cascade
  4:        184        160    IO-APIC-edge  serial
  8:          1          0    IO-APIC-edge  rtc
 12:          0          0    IO-APIC-edge  PS/2 Mouse
 14:    3191782    3055354    IO-APIC-edge  ide0
 15:          0          2    IO-APIC-edge  ide1
 16:   12195142   12320072   IO-APIC-level  eth0
NMI:          0          0 
LOC:  120928241  120928231 
ERR:          0
MIS:          0

[-- Attachment #4: btime.diff --]
[-- Type: text/plain, Size: 663 bytes --]

--- fs/proc/proc_misc.c.old	Wed Mar 19 15:21:20 2003
+++ fs/proc/proc_misc.c	Wed Mar 19 15:31:36 2003
@@ -250,6 +250,7 @@
 static int kstat_read_proc(char *page, char **start, off_t off,
 				 int count, int *eof, void *data)
 {
+	static unsigned long btime = 0UL;
 	int i, len;
 	extern unsigned long total_forks;
 	unsigned long jif = jiffies;
@@ -314,12 +315,15 @@
 		}
 	}
 
+	if (!btime)
+		btime = xtime.tv_sec - jif / HZ;
+
 	len += sprintf(page + len,
 		"\nctxt %lu\n"
 		"btime %lu\n"
 		"processes %lu\n",
 		nr_context_switches(),
-		xtime.tv_sec - jif / HZ,
+		btime,
 		total_forks);
 
 	return proc_calc_metrics(page, start, off, count, eof, len);

             reply	other threads:[~2003-03-19  4:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-03-19  4:45 Kingsley Cheung [this message]
2003-03-20  1:47 ` fluctuations in /proc/stat btime field Kingsley Cheung

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=20030319154554.C3492@aurema.com \
    --to=kingsley@aurema.com \
    --cc=linux-kernel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox