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
This commit is contained in:
Justin Hibbits 2018-02-08 05:18:30 +00:00
parent 354fce2869
commit fb3d972447

View File

@ -1304,7 +1304,7 @@ print_intrcnts(unsigned long *intrcnts, unsigned long *old_intrcnts,
for (i = 0, intrcnt=intrcnts, old_intrcnt=old_intrcnts; i < nintr; i++) { for (i = 0, intrcnt=intrcnts, old_intrcnt=old_intrcnts; i < nintr; i++) {
if (intrname[0] != '\0' && (*intrcnt != 0 || aflag)) { if (intrname[0] != '\0' && (*intrcnt != 0 || aflag)) {
count = *intrcnt - *old_intrcnt; 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_open_instance("interrupt");
xo_emit("{d:name/%-*s}{ket:name/%s} " xo_emit("{d:name/%-*s}{ket:name/%s} "
"{:total/%20lu} {:rate/%10lu}\n", "{:total/%20lu} {:rate/%10lu}\n",