Skip to contentSkip to conversation

rt-tests: oslat: convert to nanoseconds correctly

PATCH In review Marcelo Tosatti 2 participants 2 messages Feb 1, 2024 – Feb 2, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rt-tests: oslat: convert to nanoseconds correctly

With buckets of size 1us, accounting for measurements in the [1ns, 999ns] range are done to the 2us bucket (while they should be accounted in the 1us bucket):

    001 (us):	0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    002 (us):	41916187 41937649 41938461 42029055 ...
    003 (us):	969 985 958 972 964 986 970 961 973 ...

Fix this by doing a plain cycles -> nanoseconds convertion:

    001 (us):	43287555 43086678 43087427 43109974 ...
    002 (us):	983 987 985 975 982 960 993 961 992 ...
    003 (us):	9 6 7 13 9 22 3 21 3 3 8 8 10 11 3 55
src/oslat/oslat.c +1 -1
index 4bdca64..13e887d 100644
@@ -334,7 +334,7 @@ static void insert_bucket(struct thread *t, stamp_t value)
 	uint64_t extra;
 	double us;
 
-	lat = (value * g.unit_per_us + t->counter_mhz - 1) / t->counter_mhz;
+	lat = (value * g.unit_per_us) / t->counter_mhz;
 	us = (double)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";
#1 lore raw
Quoted 27 lines · Marcelo Tosatti

With buckets of size 1us, accounting for measurements in the [1ns, 999ns] range are done to the 2us bucket (while they should be accounted in the 1us bucket):

    001 (us):	0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    002 (us):	41916187 41937649 41938461 42029055 ...
    003 (us):	969 985 958 972 964 986 970 961 973 ...

Fix this by doing a plain cycles -> nanoseconds convertion:

    001 (us):	43287555 43086678 43087427 43109974 ...
    002 (us):	983 987 985 975 982 960 993 961 992 ...
    003 (us):	9 6 7 13 9 22 3 21 3 3 8 8 10 11 3 55
src/oslat/oslat.c +0 -0
index 4bdca64..13e887d 100644

src/oslat/oslat.c static void insert_bucket(struct thread *t, stamp_t value) · line 340

Quoted 8 lines
src/oslat/oslat.c +1 -1
@@ -334,7 +334,7 @@ static void insert_bucket(struct thread *t, stamp_t value)
 	uint64_t extra;
 	double us;
 
-	lat = (value * g.unit_per_us + t->counter_mhz - 1) / t->counter_mhz;
+	lat = (value * g.unit_per_us) / t->counter_mhz;
 	us = (double)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";