9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: andrey mirtchovski <mirtchov@cpsc.ucalgary.ca>
To: 9fans@cse.psu.edu
Subject: [9fans] stats.c bug
Date: Wed, 18 Jun 2003 14:51:13 -0600	[thread overview]
Message-ID: <Pine.LNX.4.44.0306181420040.31535-100000@fbsd.cpsc.ucalgary.ca> (raw)

there is a small bug with stats.c's readnum() routine -- the numbers for
context switches, system calls and interrupts are unsigned long (I believe)
but are converted using strtol().

if a machine is left running cpu-heavy applications for a long time (say,
a week) those numbers will overflow and strtol() will return LONG_MAX as the
value. the net effect is that stats.c will not display context, syscalls and
interrupts properly.

here's a sample cat /dev/systat:


          0  2530252355  3182187863  2996662559     3944850           0           0           0          99           0
          0  2530252917  3182188061  2996663328     3944996           0           0           0          98           0
          0  2530253045  3182188170  2996663495     3945138           0           0           0          99           0
          0  2530253224  3182188295  2996663728     3945284           0           0           0         100           0



there is also a new entry (the 10th number) reported by /dev/sysstat, which
is undocumented in the man pages. in the kernel source (port/portdat.h) it
is documented as:

	ulong	avg_inintr;	/* avg time per clock tick in interrupt handlers */

i took the liberty of modifying stats.c to include this statistic (note:
i have not modified the manpage, nor added an argument option to invoke this
from the command line -- i figured since 'idle' isn't there yet i'd better
leave this for other people to decide).

andrey


plan9% diff stats.c /sys/src/cmd/stats.c
45d44
< 	InIntr,
65,66c64,65
< 	long		devsysstat[10];
< 	long		prevsysstat[10];
---
> 	long		devsysstat[9];
> 	long		prevsysstat[9];
108d106
< 	Minintr,
129d126
< 	"add  in intr ",
150d146
< 	inintrval(Machine*, long*, long*, int),
171d166
< 	inintrval,
434c429
< 		a[i] = strtoul(p, &p, 10);
---
> 		a[i] = strtol(p, &p, 10);
676c671
< 		present[Minintr] | present[Msyscall] | present[Mtlbmiss] | present[Mtlbpurge];
---
> 		present[Msyscall] | present[Mtlbmiss] | present[Mtlbpurge];
829,835d823
< 	*vmax = 100;
< }
<
< void
< inintrval(Machine *m, long *v, long *vmax, int)
< {
< 	*v = m->devsysstat[InIntr];
plan9%







             reply	other threads:[~2003-06-18 20:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-18 20:51 andrey mirtchovski [this message]
2003-06-18 20:59 ` Russ Cox
2003-06-18 21:57   ` andrey mirtchovski

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=Pine.LNX.4.44.0306181420040.31535-100000@fbsd.cpsc.ucalgary.ca \
    --to=mirtchov@cpsc.ucalgary.ca \
    --cc=9fans@cse.psu.edu \
    /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;
as well as URLs for NNTP newsgroup(s).