summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2013-08-27 17:35:51 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2013-08-27 17:43:46 +0100
commit177208b0d4cf64a3e2f18909a47afc5bd646a651 (patch)
tree052a0c44e0860c9a5aabb2d6bea1cb7b5d87493a
parentb1d2a78a5db34e835a323364328263f5f4c605ce (diff)
overlay: Tidy presentation of ring busy values
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--overlay/gpu-top.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/overlay/gpu-top.c b/overlay/gpu-top.c
index 1efbbfd3..77166953 100644
--- a/overlay/gpu-top.c
+++ b/overlay/gpu-top.c
@@ -292,11 +292,19 @@ int gpu_top_update(struct gpu_top *gt)
d_time = s->time - d->time;
for (n = 0; n < gt->num_rings; n++) {
- gt->ring[n].u.u.busy = 100 * (s->busy[n] - d->busy[n]) / d_time;
+ gt->ring[n].u.u.busy = (100 * (s->busy[n] - d->busy[n]) + d_time/2) / d_time;
if (gt->have_wait)
- gt->ring[n].u.u.wait = 100 * (s->wait[n] - d->wait[n]) / d_time;
+ gt->ring[n].u.u.wait = (100 * (s->wait[n] - d->wait[n]) + d_time/2) / d_time;
if (gt->have_sema)
- gt->ring[n].u.u.sema = 100 * (s->sema[n] - d->sema[n]) / d_time;
+ gt->ring[n].u.u.sema = (100 * (s->sema[n] - d->sema[n]) + d_time/2) / d_time;
+
+ /* in case of rounding + sampling errors, fudge */
+ if (gt->ring[n].u.u.busy > 100)
+ gt->ring[n].u.u.busy = 100;
+ if (gt->ring[n].u.u.wait > 100)
+ gt->ring[n].u.u.wait = 100;
+ if (gt->ring[n].u.u.sema > 100)
+ gt->ring[n].u.u.sema = 100;
}
update = 1;