Commit a7e60062 authored by Bryan O'Donoghue's avatar Bryan O'Donoghue Committed by Greg Kroah-Hartman

greybus: loopback: remove redundant timestamping

It is of more interest to graphing system performance to base our
timestamps on the time it takes a greybus_operation_sync() to complete.
Higher level timestamping code is less accurate and not relevant to
throughput and latency characterization.
Signed-off-by: default avatarBryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent 9612f2bc
...@@ -43,8 +43,6 @@ struct gb_loopback { ...@@ -43,8 +43,6 @@ struct gb_loopback {
struct gb_loopback_stats latency; struct gb_loopback_stats latency;
struct gb_loopback_stats throughput; struct gb_loopback_stats throughput;
struct gb_loopback_stats requests_per_second; struct gb_loopback_stats requests_per_second;
struct timeval ts;
struct timeval te;
u64 elapsed_nsecs; u64 elapsed_nsecs;
u32 error; u32 error;
}; };
...@@ -180,11 +178,9 @@ static struct attribute *loopback_attrs[] = { ...@@ -180,11 +178,9 @@ static struct attribute *loopback_attrs[] = {
}; };
ATTRIBUTE_GROUPS(loopback); ATTRIBUTE_GROUPS(loopback);
static int gb_loopback_sink(struct gb_loopback *gb, static int gb_loopback_sink(struct gb_loopback *gb, u32 len)
struct timeval *tping, u32 len)
{ {
struct timeval ts, te; struct timeval ts, te;
u64 elapsed_nsecs;
struct gb_loopback_transfer_request *request; struct gb_loopback_transfer_request *request;
int retval; int retval;
...@@ -199,18 +195,15 @@ static int gb_loopback_sink(struct gb_loopback *gb, ...@@ -199,18 +195,15 @@ static int gb_loopback_sink(struct gb_loopback *gb,
request, len + sizeof(*request), NULL, 0); request, len + sizeof(*request), NULL, 0);
do_gettimeofday(&te); do_gettimeofday(&te);
elapsed_nsecs = timeval_to_ns(&te) - timeval_to_ns(&ts); gb->elapsed_nsecs = timeval_to_ns(&te) - timeval_to_ns(&ts);
*tping = ns_to_timeval(elapsed_nsecs);
kfree(request); kfree(request);
return retval; return retval;
} }
static int gb_loopback_transfer(struct gb_loopback *gb, static int gb_loopback_transfer(struct gb_loopback *gb, u32 len)
struct timeval *tping, u32 len)
{ {
struct timeval ts, te; struct timeval ts, te;
u64 elapsed_nsecs;
struct gb_loopback_transfer_request *request; struct gb_loopback_transfer_request *request;
struct gb_loopback_transfer_response *response; struct gb_loopback_transfer_response *response;
int retval; int retval;
...@@ -231,8 +224,7 @@ static int gb_loopback_transfer(struct gb_loopback *gb, ...@@ -231,8 +224,7 @@ static int gb_loopback_transfer(struct gb_loopback *gb,
request, len + sizeof(*request), request, len + sizeof(*request),
response, len + sizeof(*response)); response, len + sizeof(*response));
do_gettimeofday(&te); do_gettimeofday(&te);
elapsed_nsecs = timeval_to_ns(&te) - timeval_to_ns(&ts); gb->elapsed_nsecs = timeval_to_ns(&te) - timeval_to_ns(&ts);
*tping = ns_to_timeval(elapsed_nsecs);
if (retval) if (retval)
goto gb_error; goto gb_error;
...@@ -247,18 +239,16 @@ static int gb_loopback_transfer(struct gb_loopback *gb, ...@@ -247,18 +239,16 @@ static int gb_loopback_transfer(struct gb_loopback *gb,
return retval; return retval;
} }
static int gb_loopback_ping(struct gb_loopback *gb, struct timeval *tping) static int gb_loopback_ping(struct gb_loopback *gb)
{ {
struct timeval ts, te; struct timeval ts, te;
u64 elapsed_nsecs;
int retval; int retval;
do_gettimeofday(&ts); do_gettimeofday(&ts);
retval = gb_operation_sync(gb->connection, GB_LOOPBACK_TYPE_PING, retval = gb_operation_sync(gb->connection, GB_LOOPBACK_TYPE_PING,
NULL, 0, NULL, 0); NULL, 0, NULL, 0);
do_gettimeofday(&te); do_gettimeofday(&te);
elapsed_nsecs = timeval_to_ns(&te) - timeval_to_ns(&ts); gb->elapsed_nsecs = timeval_to_ns(&te) - timeval_to_ns(&ts);
*tping = ns_to_timeval(elapsed_nsecs);
return retval; return retval;
} }
...@@ -324,7 +314,6 @@ static void gb_loopback_reset_stats(struct gb_loopback *gb) ...@@ -324,7 +314,6 @@ static void gb_loopback_reset_stats(struct gb_loopback *gb)
memcpy(&gb->throughput, &reset, sizeof(struct gb_loopback_stats)); memcpy(&gb->throughput, &reset, sizeof(struct gb_loopback_stats));
memcpy(&gb->requests_per_second, &reset, memcpy(&gb->requests_per_second, &reset,
sizeof(struct gb_loopback_stats)); sizeof(struct gb_loopback_stats));
memset(&gb->ts, 0, sizeof(struct timeval));
} }
static void gb_loopback_update_stats(struct gb_loopback_stats *stats, u64 val) static void gb_loopback_update_stats(struct gb_loopback_stats *stats, u64 val)
...@@ -375,8 +364,7 @@ static void gb_loopback_throughput_update(struct gb_loopback *gb, u32 latency) ...@@ -375,8 +364,7 @@ static void gb_loopback_throughput_update(struct gb_loopback *gb, u32 latency)
gb_loopback_update_stats(&gb->throughput, throughput); gb_loopback_update_stats(&gb->throughput, throughput);
} }
static void gb_loopback_calculate_stats(struct gb_loopback *gb, static void gb_loopback_calculate_stats(struct gb_loopback *gb)
struct timeval *tlat)
{ {
u32 lat; u32 lat;
u64 tmp; u64 tmp;
...@@ -397,7 +385,6 @@ static void gb_loopback_calculate_stats(struct gb_loopback *gb, ...@@ -397,7 +385,6 @@ static void gb_loopback_calculate_stats(struct gb_loopback *gb,
static int gb_loopback_fn(void *data) static int gb_loopback_fn(void *data)
{ {
int error = 0; int error = 0;
struct timeval tlat = {0, 0};
struct gb_loopback *gb = (struct gb_loopback *)data; struct gb_loopback *gb = (struct gb_loopback *)data;
while (1) { while (1) {
...@@ -416,21 +403,15 @@ static int gb_loopback_fn(void *data) ...@@ -416,21 +403,15 @@ static int gb_loopback_fn(void *data)
continue; continue;
} }
} }
if (gb->ts.tv_usec == 0 && gb->ts.tv_sec == 0)
do_gettimeofday(&gb->ts);
if (gb->type == GB_LOOPBACK_TYPE_PING) if (gb->type == GB_LOOPBACK_TYPE_PING)
error = gb_loopback_ping(gb, &tlat); error = gb_loopback_ping(gb);
else if (gb->type == GB_LOOPBACK_TYPE_TRANSFER) else if (gb->type == GB_LOOPBACK_TYPE_TRANSFER)
error = gb_loopback_transfer(gb, &tlat, gb->size); error = gb_loopback_transfer(gb, gb->size);
else if (gb->type == GB_LOOPBACK_TYPE_SINK) else if (gb->type == GB_LOOPBACK_TYPE_SINK)
error = gb_loopback_sink(gb, &tlat, gb->size); error = gb_loopback_sink(gb, gb->size);
if (error) if (error)
gb->error++; gb->error++;
do_gettimeofday(&gb->te); gb_loopback_calculate_stats(gb);
gb->elapsed_nsecs = timeval_to_ns(&gb->te) -
timeval_to_ns(&gb->ts);
gb_loopback_calculate_stats(gb, &tlat);
gb->ts = gb->te;
if (gb->ms_wait) if (gb->ms_wait)
msleep(gb->ms_wait); msleep(gb->ms_wait);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment