From mboxrd@z Thu Jan 1 00:00:00 1970 From: andrey mirtchovski To: 9fans@cse.psu.edu Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: [9fans] stats.c bug Date: Wed, 18 Jun 2003 14:51:13 -0600 Topicbox-Message-UUID: cf7e8774-eacb-11e9-9e20-41e7f4b1d025 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%