From: John Kacur <jkacur@redhat.com>
To: linux-rt-users <linux-rt-users@vger.kernel.org>
Cc: Clark Williams <williams@redhat.com>,
Costa Shulyupin <costa.shul@redhat.com>,
John Kacur <jkacur@redhat.com>
Subject: [PATCH] rt-tests: hwlatdetect: Add check that width is not zero
Date: Thu, 26 Feb 2026 15:34:45 -0500 [thread overview]
Message-ID: <20260226203445.110762-1-jkacur@redhat.com> (raw)
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
reply other threads:[~2026-02-26 20:35 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260226203445.110762-1-jkacur@redhat.com \
--to=jkacur@redhat.com \
--cc=costa.shul@redhat.com \
--cc=linux-rt-users@vger.kernel.org \
--cc=williams@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox