From 1a2f1056dbe165805b5d1e8ed6d404ffee641041 Mon Sep 17 00:00:00 2001 From: Ben Allan Date: Thu, 12 Jul 2018 11:15:06 -0600 Subject: [PATCH] repair rate computation across resets. This repair is mathematically correct so the user can now check the sign bit to detect counter resets. The loss of information during the interval of a counter reset is the user's problem to bound. --- ldms/src/sampler/sysclassib.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ldms/src/sampler/sysclassib.c b/ldms/src/sampler/sysclassib.c index 8d1b09c23..92b83c40b 100644 --- a/ldms/src/sampler/sysclassib.c +++ b/ldms/src/sampler/sysclassib.c @@ -310,7 +310,7 @@ static int create_metric_set(const char *instance_name, char *schema_name) port->ca, port->portno); port->rate[i] = ldms_schema_metric_add(schema, metric_name, - LDMS_V_F32); + LDMS_V_D64); } } } @@ -641,21 +641,21 @@ static ldms_set_t get_set(struct ldmsd_sampler *self) */ static inline void update_metric(struct scib_port *port, int idx, uint64_t new_v, - float dt) + double dt) { uint64_t old_v = ldms_metric_get_u64(set, port->handle[idx]); if (!port->ext) new_v += old_v; ldms_metric_set_u64(set, port->handle[idx], new_v); if (sysclassib_metrics_type == SYSCLASSIB_METRICS_BOTH) { - ldms_metric_set_float(set, port->rate[idx], (new_v - old_v) / dt); + ldms_metric_set_double(set, port->rate[idx], ((double)new_v - (double)old_v) / dt); } } /** * Port query (utility function). */ -int query_port(struct scib_port *port, float dt) +int query_port(struct scib_port *port, double dt) { void *p; int rc; @@ -733,7 +733,7 @@ static int sample(struct ldmsd_sampler *self) { struct timeval *tmp; struct timeval tv_diff; - float dt; + double dt; struct scib_port *port; if (!set) { @@ -743,7 +743,7 @@ static int sample(struct ldmsd_sampler *self) gettimeofday(tv_now, 0); timersub(tv_now, tv_prev, &tv_diff); - dt = tv_diff.tv_sec + tv_diff.tv_usec / 1e06f; + dt = (double)tv_diff.tv_sec + tv_diff.tv_usec / 1.0e06; ldms_transaction_begin(set); LJI_SAMPLE(set,1);