From: Rafael Folco <rfolco@redhat.com>
To: williams@redhat.com, jkacur@redhat.com
Cc: linux-rt-users@vger.kernel.org
Subject: [PATCH] Change min/max to float numbers
Date: Thu, 6 Feb 2025 06:16:22 -0300 [thread overview]
Message-ID: <3a9f0f10-2e7a-4eb6-b094-e5492b43505f@redhat.com> (raw)
Make min/max consistent with avg by recording the latency samples
as float numbers instead of integers.
Signed-off-by: Rafael Folco <rfolco@redhat.com>
---
src/oslat/oslat.c | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/src/oslat/oslat.c b/src/oslat/oslat.c
index 9e5a08a..6d4a9cb 100644
--- a/src/oslat/oslat.c
+++ b/src/oslat/oslat.c
@@ -159,9 +159,9 @@ struct thread {
stamp_t frc_stop;
cycles_t runtime;
stamp_t *buckets;
- uint64_t minlat;
+ double minlat;
/* Maximum latency detected */
- uint64_t maxlat;
+ double maxlat;
/*
* The extra part of the interruptions that cannot be put into even the
* biggest bucket. We'll use this to calculate a more accurate average at
@@ -330,12 +330,11 @@ static float cycles_to_sec(const struct thread *t, uint64_t cycles)
static void insert_bucket(struct thread *t, stamp_t value)
{
int index;
- unsigned int lat;
uint64_t extra;
- double us;
+ double lat, us;
- lat = (value * g.unit_per_us) / t->counter_mhz;
- us = (double)lat / g.unit_per_us;
+ lat = (double)(value * g.unit_per_us) / t->counter_mhz;
+ us = lat / g.unit_per_us;
if (!g.preheat && g.trace_threshold && us >= g.trace_threshold) {
char *line = "%s: Trace threshold (%d us) triggered on cpu %d with %.*f us!\n";
tracemark(line, g.app_name, g.trace_threshold, t->core_i,
@@ -526,10 +525,10 @@ static void write_summary(struct thread *t)
(j == g.bucket_size - 1) ? " (including overflows)" : "");
}
- putfieldp("Minimum", t[i].minlat, " (us)");
+ putfield("Minimum", t[i].minlat, ".3lf", " (us)");
putfield("Average", t[i].average, ".3lf", " (us)");
- putfieldp("Maximum", t[i].maxlat, " (us)");
- putfieldp("Max-Min", t[i].maxlat - t[i].minlat, " (us)");
+ putfield("Maximum", t[i].maxlat, ".3lf", " (us)");
+ putfield("Max-Min", t[i].maxlat - t[i].minlat, ".3lf", " (us)");
putfield("Duration", cycles_to_sec(&(t[i]), t[i].runtime),
".3f", " (sec)");
printf("\n");
@@ -547,9 +546,9 @@ static void write_summary_json(FILE *f, void *data)
fprintf(f, " \"%lu\": {\n", i);
fprintf(f, " \"cpu\": %d,\n", t[i].core_i);
fprintf(f, " \"freq\": %d,\n", t[i].counter_mhz);
- fprintf(f, " \"min\": %" PRIu64 ",\n", t[i].minlat);
+ fprintf(f, " \"min\": %3lf,\n", t[i].minlat);
fprintf(f, " \"avg\": %3lf,\n", t[i].average);
- fprintf(f, " \"max\": %" PRIu64 ",\n", t[i].maxlat);
+ fprintf(f, " \"max\": %3lf,\n", t[i].maxlat);
fprintf(f, " \"duration\": %.3f,\n",
cycles_to_sec(&(t[i]), t[i].runtime));
fprintf(f, " \"histogram\": {");
--
2.47.1
next reply other threads:[~2025-02-06 9:16 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-06 9:16 Rafael Folco [this message]
2025-02-06 12:00 ` [PATCH] Change min/max to float numbers Sebastian Andrzej Siewior
2025-02-06 15:02 ` Rafael Folco
2025-02-06 15:09 ` Sebastian Andrzej Siewior
2025-02-06 15:24 ` Rafael Folco
2025-02-06 15:36 ` Sebastian Andrzej Siewior
2025-02-06 16:22 ` Rafael Folco
2025-02-06 21:23 ` Crystal Wood
2025-02-07 14:20 ` Rafael Folco
2025-02-07 23:23 ` Crystal Wood
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=3a9f0f10-2e7a-4eb6-b094-e5492b43505f@redhat.com \
--to=rfolco@redhat.com \
--cc=jkacur@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.