[igt-dev] [PATCH i-g-t 2/2] intel-gpu-overlay: Show 1s, 30s and 15m GPU load

Chris Wilson chris at chris-wilson.co.uk
Tue Feb 13 11:19:23 UTC 2018


Quoting Tvrtko Ursulin (2018-02-12 19:01:58)
> From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
> 
> Show total GPU loads in the window banner.
> 
> Engine load is defined as total of runnable and running requests on an
> engine.
> 
> Total, non-normalized, load is display. In other words if N engines are
> busy with exactly one request, the load will be shown as N.
> 
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
> ---
>  overlay/gpu-top.c | 37 ++++++++++++++++++++++++++++++++++++-
>  overlay/gpu-top.h | 10 +++++++++-
>  overlay/overlay.c | 27 +++++++++++++++++++--------
>  3 files changed, 64 insertions(+), 10 deletions(-)
> 
> diff --git a/overlay/gpu-top.c b/overlay/gpu-top.c
> index 22e9badb22c1..ca25e998e3d7 100644
> --- a/overlay/gpu-top.c
> +++ b/overlay/gpu-top.c
> @@ -290,17 +290,35 @@ static void mmio_init(struct gpu_top *gt)
>         }
>  }
>  
> -void gpu_top_init(struct gpu_top *gt)
> +void gpu_top_init(struct gpu_top *gt, unsigned int period_us)
>  {
> +       const double period = (double)period_us / 1e6;
> +       const double load_period[NUM_LOADS] = { 1.0, 30.0, 900.0 };
> +       const char *load_names[NUM_LOADS] = { "1s", "30s", "15m" };
> +       unsigned int i;
> +
>         memset(gt, 0, sizeof(*gt));
>         gt->fd = -1;
>  
> +       for (i = 0; i < NUM_LOADS; i++) {
> +               gt->load_name[i] = load_names[i];
> +               gt->exp[i] = period / load_period[i];
> +       }
> +
>         if (perf_init(gt) == 0)
>                 return;
>  
>         mmio_init(gt);
>  }
>  
> +static double update_load(double load, double exp, double val)
> +{
> +       load *= 1.0 - exp;
> +       load += exp * val;
> +
> +       return load;
> +}

I think you forgot the exp() here...

diff --git a/overlay/gpu-top.c b/overlay/gpu-top.c
index ca25e998..e40766fe 100644
--- a/overlay/gpu-top.c
+++ b/overlay/gpu-top.c
@@ -29,6 +29,7 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <errno.h>
+#include <math.h>
 #include <assert.h>
 
 #include "igt_perf.h"
@@ -302,7 +303,7 @@ void gpu_top_init(struct gpu_top *gt, unsigned int period_us)
 
        for (i = 0; i < NUM_LOADS; i++) {
                gt->load_name[i] = load_names[i];
-               gt->exp[i] = period / load_period[i];
+               gt->exp[i] = exp(-period / load_period[i]);
        }
 
        if (perf_init(gt) == 0)
@@ -313,10 +314,7 @@ void gpu_top_init(struct gpu_top *gt, unsigned int period_us)
 
 static double update_load(double load, double exp, double val)
 {
-       load *= 1.0 - exp;
-       load += exp * val;
-
-       return load;
+       return val + exp * (load - val);
 }
 

stops the loadavg from claiming to over 1M :)
-Chris


More information about the igt-dev mailing list