diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2014-09-20 18:06:59 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2014-09-20 18:06:59 +0200 |
commit | 2604bc360347176323dd6706362186b97c49662c (patch) | |
tree | 13d4019e15150abd31f942045f261eeade38dc3c /sys/src/cmd/stats.c | |
parent | 19a8f66eecda455b56c6c07bd1ce75be8d2cbb82 (diff) |
stats: handle /dev/sysstat 32bit overflow in delta calculation
the numbers from /dev/sysstat overflow on 32bit, so have
to do subtraction modulo 2^32 as we calculate with 64bit
integers.
thanks mischief for reporting this.
Diffstat (limited to 'sys/src/cmd/stats.c')
-rw-r--r-- | sys/src/cmd/stats.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/sys/src/cmd/stats.c b/sys/src/cmd/stats.c index 2b70c8ad2..7f2e4508d 100644 --- a/sys/src/cmd/stats.c +++ b/sys/src/cmd/stats.c @@ -353,6 +353,10 @@ datapoint(Graph *g, int x, uvlong v, uvlong vmax) y = (y+2.)/3.; } } + if(y >= 1.) + y = 1; + if(y <= 0.) + y = 0; p.y = g->r.max.y - Dy(g->r)*y - Dot; if(p.y < g->r.min.y) p.y = g->r.min.y; @@ -830,7 +834,7 @@ swapval(Machine *m, uvlong *v, uvlong *vmax, int) void contextval(Machine *m, uvlong *v, uvlong *vmax, int init) { - *v = m->devsysstat[Context]-m->prevsysstat[Context]; + *v = (m->devsysstat[Context]-m->prevsysstat[Context])&0xffffffff; *vmax = sleeptime*m->nproc; if(init) *vmax = sleeptime; @@ -842,7 +846,7 @@ contextval(Machine *m, uvlong *v, uvlong *vmax, int init) void intrval(Machine *m, uvlong *v, uvlong *vmax, int init) { - *v = m->devsysstat[Interrupt]-m->prevsysstat[Interrupt]; + *v = (m->devsysstat[Interrupt]-m->prevsysstat[Interrupt])&0xffffffff; *vmax = sleeptime*m->nproc*10; if(init) *vmax = sleeptime*10; @@ -851,7 +855,7 @@ intrval(Machine *m, uvlong *v, uvlong *vmax, int init) void syscallval(Machine *m, uvlong *v, uvlong *vmax, int init) { - *v = m->devsysstat[Syscall]-m->prevsysstat[Syscall]; + *v = (m->devsysstat[Syscall]-m->prevsysstat[Syscall])&0xffffffff; *vmax = sleeptime*m->nproc; if(init) *vmax = sleeptime; @@ -860,7 +864,7 @@ syscallval(Machine *m, uvlong *v, uvlong *vmax, int init) void faultval(Machine *m, uvlong *v, uvlong *vmax, int init) { - *v = m->devsysstat[Fault]-m->prevsysstat[Fault]; + *v = (m->devsysstat[Fault]-m->prevsysstat[Fault])&0xffffffff; *vmax = sleeptime*m->nproc; if(init) *vmax = sleeptime; @@ -869,7 +873,7 @@ faultval(Machine *m, uvlong *v, uvlong *vmax, int init) void tlbmissval(Machine *m, uvlong *v, uvlong *vmax, int init) { - *v = m->devsysstat[TLBfault]-m->prevsysstat[TLBfault]; + *v = (m->devsysstat[TLBfault]-m->prevsysstat[TLBfault])&0xffffffff; *vmax = (sleeptime/1000)*10*m->nproc; if(init) *vmax = (sleeptime/1000)*10; @@ -878,7 +882,7 @@ tlbmissval(Machine *m, uvlong *v, uvlong *vmax, int init) void tlbpurgeval(Machine *m, uvlong *v, uvlong *vmax, int init) { - *v = m->devsysstat[TLBpurge]-m->prevsysstat[TLBpurge]; + *v = (m->devsysstat[TLBpurge]-m->prevsysstat[TLBpurge])&0xffffffff; *vmax = (sleeptime/1000)*10*m->nproc; if(init) *vmax = (sleeptime/1000)*10; |