Date: Thu, 8 Feb 2018 05:18:30 +0000 (UTC) From: Justin Hibbits <jhibbits@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r329013 - head/usr.bin/vmstat Message-ID: <201802080518.w185IUxl071676@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jhibbits Date: Thu Feb 8 05:18:30 2018 New Revision: 329013 URL: https://svnweb.freebsd.org/changeset/base/329013 Log: Temporarily widen count for interrupt rate calculations on 32-bit archs If the interrupt count is very high (greater than ~42M), notably on one-shot execution on long running systems, the intermediate multiplication step in the rate calculation will overflow the width of a 32-bit architecture long (32 bits), causing the rest of the calculation to calculate with a truncated value, and report very low rates (sometimes 0). MFC after: 2 weeks Modified: head/usr.bin/vmstat/vmstat.c Modified: head/usr.bin/vmstat/vmstat.c ============================================================================== --- head/usr.bin/vmstat/vmstat.c Thu Feb 8 03:12:25 2018 (r329012) +++ head/usr.bin/vmstat/vmstat.c Thu Feb 8 05:18:30 2018 (r329013) @@ -1304,7 +1304,7 @@ print_intrcnts(unsigned long *intrcnts, unsigned long for (i = 0, intrcnt=intrcnts, old_intrcnt=old_intrcnts; i < nintr; i++) { if (intrname[0] != '\0' && (*intrcnt != 0 || aflag)) { count = *intrcnt - *old_intrcnt; - rate = (count * 1000 + period_ms / 2) / period_ms; + rate = ((uint64_t)count * 1000 + period_ms / 2) / period_ms; xo_open_instance("interrupt"); xo_emit("{d:name/%-*s}{ket:name/%s} " "{:total/%20lu} {:rate/%10lu}\n",
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201802080518.w185IUxl071676>