public inbox for linux-rt-users@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rt-tests: hwlatdetect: Add check that width is not zero
@ 2026-02-26 20:34 John Kacur
  0 siblings, 0 replies; only message in thread
From: John Kacur @ 2026-02-26 20:34 UTC (permalink / raw)
  To: linux-rt-users; +Cc: Clark Williams, Costa Shulyupin, John Kacur

Check that width is not zero before division when calculating the MTBF

Signed-off-by: John Kacur <jkacur@redhat.com>
---
 src/hwlatdetect/hwlatdetect.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/hwlatdetect/hwlatdetect.py b/src/hwlatdetect/hwlatdetect.py
index abfbb954fe75..42b9f301718a 100755
--- a/src/hwlatdetect/hwlatdetect.py
+++ b/src/hwlatdetect/hwlatdetect.py
@@ -564,8 +564,9 @@ if __name__ == '__main__':
     info(f"Samples exceeding threshold: {exceeding}")
 
     if exceeding > 1:
-        mtbf = ((float(detect.last) - float(detect.first)) * int(detect.get('window'))
-                / ((exceeding - 1) * int(detect.get('width'))))
+        width = int(detect.get('width'))
+        if width > 0:
+            mtbf = (((float(detect.last) - float(detect.first)) * int(detect.get('window'))) / ((exceeding - 1) * width))
         info(f"MTBF: {mtbf:.3f} seconds")
 
     if detect.have_msr:
-- 
2.53.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-02-26 20:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-26 20:34 [PATCH] rt-tests: hwlatdetect: Add check that width is not zero John Kacur

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox