Skip to contentSkip to conversation

intel-gpu-overlay: Queued/runnable/running engine stats

PATCH In review Tvrtko Ursulin 3 participants 8 messages Feb 12, 2018 – Feb 13, 2018 Library code

lore
Share & tools
lore
#0 lore raw

cover intel-gpu-overlay: Queued/runnable/running engine stats

From: Tvrtko Ursulin <[email protected]>

Show engine load and load average in intel-gpu-overlay. Matching IGT series to go with: https://patchwork.freedesktop.org/series/36926/.

Tvrtko Ursulin (2):
intel-gpu-overlay: Add engine queue stats
intel-gpu-overlay: Show 1s, 30s and 15m GPU load

 lib/igt_perf.h    | 18 ++++++++++++-
 overlay/gpu-top.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 overlay/gpu-top.h | 21 ++++++++++++++-
 overlay/overlay.c | 36 +++++++++++++++++++------
 4 files changed, 143 insertions(+), 11 deletions(-)
Signature · 6 lines
2.14.1

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#1 lore raw

PATCH 1/2 intel-gpu-overlay: Add engine queue stats

From: Tvrtko Ursulin <[email protected]>

Use new PMU engine queue stats (queued, runnable and running) and display them per engine.

---
 lib/igt_perf.h    | 18 +++++++++++++++++-
 overlay/gpu-top.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 overlay/gpu-top.h | 11 +++++++++++
 overlay/overlay.c |  9 +++++++++
 4 files changed, 79 insertions(+), 1 deletion(-)
lib/igt_perf.h +17 -1
index 7b66fc582b88..68e208941ca9 100644
@@ -35,9 +35,16 @@ enum drm_i915_pmu_engine_sample {
 	I915_SAMPLE_BUSY = 0,
 	I915_SAMPLE_WAIT = 1,
 	I915_SAMPLE_SEMA = 2,
-	I915_ENGINE_SAMPLE_MAX /* non-ABI */
+	I915_SAMPLE_QUEUED = 3,
+	I915_SAMPLE_RUNNABLE = 4,
+	I915_SAMPLE_RUNNING = 5,
 };
 
+ /* Divide counter value by divisor to get the real value. */
+#define I915_SAMPLE_QUEUED_DIVISOR (1024)
+#define I915_SAMPLE_RUNNABLE_DIVISOR (1024)
+#define I915_SAMPLE_RUNNING_DIVISOR (1024)
+
 #define I915_PMU_SAMPLE_BITS (4)
 #define I915_PMU_SAMPLE_MASK (0xf)
 #define I915_PMU_SAMPLE_INSTANCE_BITS (8)
@@ -58,6 +65,15 @@ enum drm_i915_pmu_engine_sample {
 #define I915_PMU_ENGINE_SEMA(class, instance) \
 	__I915_PMU_ENGINE(class, instance, I915_SAMPLE_SEMA)
 
+#define I915_PMU_ENGINE_QUEUED(class, instance) \
+	__I915_PMU_ENGINE(class, instance, I915_SAMPLE_QUEUED)
+
+#define I915_PMU_ENGINE_RUNNABLE(class, instance) \
+	__I915_PMU_ENGINE(class, instance, I915_SAMPLE_RUNNABLE)
+
+#define I915_PMU_ENGINE_RUNNING(class, instance) \
+	__I915_PMU_ENGINE(class, instance, I915_SAMPLE_RUNNING)
+
 #define __I915_PMU_OTHER(x) (__I915_PMU_ENGINE(0xff, 0xff, 0xf) + 1 + (x))
 
 #define I915_PMU_ACTUAL_FREQUENCY	__I915_PMU_OTHER(0)
overlay/gpu-top.c +42 -0

66 lines not on this page · raw message

overlay/gpu-top.h +11 -0
index d3cdd779760f..cb4310c82a94 100644
@@ -36,6 +36,9 @@ struct gpu_top {
 	int num_rings;
 	int have_wait;
 	int have_sema;
+	int have_queued;
+	int have_runnable;
+	int have_running;
 
 	struct gpu_top_ring {
 		const char *name;
@@ -47,6 +50,10 @@ struct gpu_top {
 			} u;
 			uint32_t payload;
 		} u;
+
+		double queued;
+		double runnable;
+		double running;
 	} ring[MAX_RINGS];
 
 	struct gpu_top_stat {
@@ -54,7 +61,11 @@ struct gpu_top {
 		uint64_t busy[MAX_RINGS];
 		uint64_t wait[MAX_RINGS];
 		uint64_t sema[MAX_RINGS];
+		uint64_t queued[MAX_RINGS];
+		uint64_t runnable[MAX_RINGS];
+		uint64_t running[MAX_RINGS];
 	} stat[2];
+
 	int count;
 };
 
overlay/overlay.c +9 -0
index 545af7bcb2f5..a639703ebcec 100644
@@ -255,6 +255,15 @@ static void show_gpu_top(struct overlay_context *ctx, struct overlay_gpu_top *gt
 		len = sprintf(txt, "%s: %3d%% busy",
 			      gt->gpu_top.ring[n].name,
 			      gt->gpu_top.ring[n].u.u.busy);
+		if (gt->gpu_top.have_queued)
+			len += sprintf(txt + len, ", qd %.2f",
+				       gt->gpu_top.ring[n].queued);
+		if (gt->gpu_top.have_runnable)
+			len += sprintf(txt + len, ", rd %.2f",
+				       gt->gpu_top.ring[n].runnable);
+		if (gt->gpu_top.have_running)
+			len += sprintf(txt + len, ", ed %.2f",
+				       gt->gpu_top.ring[n].running);
 		if (gt->gpu_top.ring[n].u.u.wait)
 			len += sprintf(txt + len, ", %d%% wait",
 				       gt->gpu_top.ring[n].u.u.wait);
Signature · 6 lines
2.14.1

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#2 lore raw

Re: [igt-dev] [PATCH i-g-t 1/2] intel-gpu-overlay: Add engine queue stats

Quoting Tvrtko Ursulin (2018-02-12 19:01:57)

Quoted 7 lines
overlay/overlay.c +0 -0
index 545af7bcb2f5..a639703ebcec 100644
@@ -255,6 +255,15 @@ static void show_gpu_top(struct overlay_context *ctx, struct overlay_gpu_top *gt
                len = sprintf(txt, "%s: %3d%% busy",
                              gt->gpu_top.ring[n].name,

overlay/overlay.c static void show_gpu_top(struct overlay_context *ctx, struct overlay_gpu_top *gt · line 266

Quoted 10 lines
overlay/overlay.c +9 -0
                              gt->gpu_top.ring[n].u.u.busy);
+               if (gt->gpu_top.have_queued)
+                       len += sprintf(txt + len, ", qd %.2f",
+                                      gt->gpu_top.ring[n].queued);
+               if (gt->gpu_top.have_runnable)
+                       len += sprintf(txt + len, ", rd %.2f",
+                                      gt->gpu_top.ring[n].runnable);
+               if (gt->gpu_top.have_running)
+                       len += sprintf(txt + len, ", ed %.2f",
+                                      gt->gpu_top.ring[n].running);

Hmm, I would like to compact this down to "%% busy (%.2f / %.2f / %.2f)" with execution, runnable, queued respectively.
-Chris
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#3 lore raw

PATCH 2/2 intel-gpu-overlay: Show 1s, 30s and 15m GPU load

In reply to Tvrtko Ursulin

From: Tvrtko Ursulin <[email protected]>

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.

---
 overlay/gpu-top.c | 37 ++++++++++++++++++++++++++++++++++++-
 overlay/gpu-top.h | 10 +++++++++-
 overlay/overlay.c | 27 +++++++++++++++++++--------
 3 files changed, 64 insertions(+), 10 deletions(-)
overlay/gpu-top.c +36 -1
index 22e9badb22c1..ca25e998e3d7 100644
@@ -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;
+}
+
 int gpu_top_update(struct gpu_top *gt)
 {
 	uint32_t data[1024];
@@ -313,6 +331,8 @@ int gpu_top_update(struct gpu_top *gt)
 		struct gpu_top_stat *s = &gt->stat[gt->count++&1];
 		struct gpu_top_stat *d = &gt->stat[gt->count&1];
 		uint64_t *sample, d_time;
+		double gpu_qd = 0.0;
+		unsigned int i;
 		int n, m;
 
 		len = read(gt->fd, data, sizeof(data));
@@ -341,6 +361,8 @@ int gpu_top_update(struct gpu_top *gt)
 
 		d_time = s->time - d->time;
 		for (n = 0; n < gt->num_rings; n++) {
+			double qd = 0.0;
+
 			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/2) / d_time;
@@ -353,6 +375,14 @@ int gpu_top_update(struct gpu_top *gt)
 			if (gt->have_running)
 				gt->ring[n].running = (double)((s->running[n] - d->running[n])) / I915_SAMPLE_RUNNING_DIVISOR * 1e9 / d_time;
 
+			qd = gt->ring[n].runnable + gt->ring[n].running;
+			gpu_qd += qd;
+
+			for (i = 0; i < NUM_LOADS; i++)
+				gt->ring[n].load[i] =
+					update_load(gt->ring[n].load[i],
+						    gt->exp[i], qd);
+
 			/* in case of rounding + sampling errors, fudge */
 			if (gt->ring[n].u.u.busy > 100)
 				gt->ring[n].u.u.busy = 100;
@@ -362,6 +392,11 @@ int gpu_top_update(struct gpu_top *gt)
 				gt->ring[n].u.u.sema = 100;
 		}
 
+		for (i = 0; i < NUM_LOADS; i++) {
+			gt->load[i] = update_load(gt->load[i], gt->exp[i],
+						  gpu_qd);
+			gt->norm_load[i] = gt->load[i] / gt->num_rings;
+		}
 		update = 1;
 	} else {
 		while ((len = read(gt->fd, data, sizeof(data))) > 0) {
overlay/gpu-top.h +9 -1
index cb4310c82a94..8fc617ce8492 100644
@@ -26,6 +26,7 @@
 #define GPU_TOP_H
 
 #define MAX_RINGS 16
+#define NUM_LOADS 3
 
 #include <stdint.h>
 
@@ -40,6 +41,11 @@ struct gpu_top {
 	int have_runnable;
 	int have_running;
 
+	double exp[NUM_LOADS];
+	double load[NUM_LOADS];
+	double norm_load[NUM_LOADS];
+	const char *load_name[NUM_LOADS];
+
 	struct gpu_top_ring {
 		const char *name;
 		union gpu_top_payload {
@@ -54,6 +60,8 @@ struct gpu_top {
 		double queued;
 		double runnable;
 		double running;
+
+		double load[NUM_LOADS];
 	} ring[MAX_RINGS];
 
 	struct gpu_top_stat {
@@ -69,7 +77,7 @@ struct gpu_top {
 	int count;
 };
 
-void gpu_top_init(struct gpu_top *gt);
+void gpu_top_init(struct gpu_top *gt, unsigned int period_us);
 int gpu_top_update(struct gpu_top *gt);
 
 #endif /* GPU_TOP_H */
overlay/overlay.c +19 -8
index a639703ebcec..30f712e4415a 100644
@@ -141,7 +141,8 @@ struct overlay_context {
 };
 
 static void init_gpu_top(struct overlay_context *ctx,
-			 struct overlay_gpu_top *gt)
+			 struct overlay_gpu_top *gt,
+			 unsigned int period_us)
 {
 	const double rgba[][4] = {
 		{ 1, 0.25, 0.25, 1 },
@@ -152,7 +153,7 @@ static void init_gpu_top(struct overlay_context *ctx,
 	int n;
 
 	cpu_top_init(&gt->cpu_top);
-	gpu_top_init(&gt->gpu_top);
+	gpu_top_init(&gt->gpu_top, period_us);
 
 	chart_init(&gt->cpu, "CPU", 120);
 	chart_set_position(&gt->cpu, PAD, PAD);
@@ -929,13 +930,13 @@ int main(int argc, char **argv)
 
 	debugfs_init();
 
-	init_gpu_top(&ctx, &ctx.gpu_top);
+	sample_period = get_sample_period(&config);
+
+	init_gpu_top(&ctx, &ctx.gpu_top, sample_period);
 	init_gpu_perf(&ctx, &ctx.gpu_perf);
 	init_gpu_freq(&ctx, &ctx.gpu_freq);
 	init_gem_objects(&ctx, &ctx.gem_objects);
 
-	sample_period = get_sample_period(&config);
-
 	i = 0;
 	while (1) {
 		ctx.time = time(NULL);
@@ -951,16 +952,26 @@ int main(int argc, char **argv)
 		show_gem_objects(&ctx, &ctx.gem_objects);
 
 		{
-			char buf[80];
+			struct gpu_top *gt = &ctx.gpu_top.gpu_top;
+			char buf[80], buf2[256];
 			cairo_text_extents_t extents;
+
 			gethostname(buf, sizeof(buf));
+			snprintf(buf2, sizeof(buf2),
+				 "%s; %u engines; load-avg %s %.2f, %s %.2f, %s %.2f",
+				 buf,
+				 gt->num_rings,
+				 gt->load_name[0], gt->load[0],
+				 gt->load_name[1], gt->load[1],
+				 gt->load_name[2], gt->load[2]);
+
 			cairo_set_source_rgb(ctx.cr, .5, .5, .5);
 			cairo_set_font_size(ctx.cr, PAD-2);
-			cairo_text_extents(ctx.cr, buf, &extents);
+			cairo_text_extents(ctx.cr, buf2, &extents);
 			cairo_move_to(ctx.cr,
 				      (ctx.width-extents.width)/2.,
 				      1+extents.height);
-			cairo_show_text(ctx.cr, buf);
+			cairo_show_text(ctx.cr, buf2);
 		}
 
 		cairo_destroy(ctx.cr);
Signature · 6 lines
2.14.1

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#4 lore raw

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

Quoting Tvrtko Ursulin (2018-02-12 19:01:58)

Quoted 4 lines

From: Tvrtko Ursulin <[email protected]>

Show total GPU loads in the window banner.

Quoted 8 lines

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.

---

All matches my understanding, at least :)

overlay/overlay.c int main(int argc, char **argv) · line 959

Quoted 10 lines
overlay/overlay.c +3 -1
@@ -951,16 +952,26 @@ int main(int argc, char **argv)
                show_gem_objects(&ctx, &ctx.gem_objects);
 
                {
-                       char buf[80];
+                       struct gpu_top *gt = &ctx.gpu_top.gpu_top;
+                       char buf[80], buf2[256];
                        cairo_text_extents_t extents;
+
                        gethostname(buf, sizeof(buf));

len = strlen(buf);
snprintf(buf + len, sizeof(buf) - len, ?
-Chris
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#5 lore raw

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

In reply to Tvrtko Ursulin

Quoting Tvrtko Ursulin (2018-02-12 19:01:58)

Quoted 192 lines

From: Tvrtko Ursulin <[email protected]>

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.

---
 overlay/gpu-top.c | 37 ++++++++++++++++++++++++++++++++++++-
 overlay/gpu-top.h | 10 +++++++++-
 overlay/overlay.c | 27 +++++++++++++++++++--------
 3 files changed, 64 insertions(+), 10 deletions(-)
overlay/gpu-top.c +36 -1
index 22e9badb22c1..ca25e998e3d7 100644
@@ -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;
+}
+
 int gpu_top_update(struct gpu_top *gt)
 {
        uint32_t data[1024];
@@ -313,6 +331,8 @@ int gpu_top_update(struct gpu_top *gt)
                struct gpu_top_stat *s = &gt->stat[gt->count++&1];
                struct gpu_top_stat *d = &gt->stat[gt->count&1];
                uint64_t *sample, d_time;
+               double gpu_qd = 0.0;
+               unsigned int i;
                int n, m;
 
                len = read(gt->fd, data, sizeof(data));
@@ -341,6 +361,8 @@ int gpu_top_update(struct gpu_top *gt)
 
                d_time = s->time - d->time;
                for (n = 0; n < gt->num_rings; n++) {
+                       double qd = 0.0;
+
                        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/2) / d_time;
@@ -353,6 +375,14 @@ int gpu_top_update(struct gpu_top *gt)
                        if (gt->have_running)
                                gt->ring[n].running = (double)((s->running[n] - d->running[n])) / I915_SAMPLE_RUNNING_DIVISOR * 1e9 / d_time;
 
+                       qd = gt->ring[n].runnable + gt->ring[n].running;
+                       gpu_qd += qd;
+
+                       for (i = 0; i < NUM_LOADS; i++)
+                               gt->ring[n].load[i] =
+                                       update_load(gt->ring[n].load[i],
+                                                   gt->exp[i], qd);
+
                        /* in case of rounding + sampling errors, fudge */
                        if (gt->ring[n].u.u.busy > 100)
                                gt->ring[n].u.u.busy = 100;
@@ -362,6 +392,11 @@ int gpu_top_update(struct gpu_top *gt)
                                gt->ring[n].u.u.sema = 100;
                }
 
+               for (i = 0; i < NUM_LOADS; i++) {
+                       gt->load[i] = update_load(gt->load[i], gt->exp[i],
+                                                 gpu_qd);
+                       gt->norm_load[i] = gt->load[i] / gt->num_rings;
+               }
                update = 1;
        } else {
                while ((len = read(gt->fd, data, sizeof(data))) > 0) {
overlay/gpu-top.h +9 -1
index cb4310c82a94..8fc617ce8492 100644
@@ -26,6 +26,7 @@
 #define GPU_TOP_H
 
 #define MAX_RINGS 16
+#define NUM_LOADS 3
 
 #include <stdint.h>
 
@@ -40,6 +41,11 @@ struct gpu_top {
        int have_runnable;
        int have_running;
 
+       double exp[NUM_LOADS];
+       double load[NUM_LOADS];
+       double norm_load[NUM_LOADS];
+       const char *load_name[NUM_LOADS];
+
        struct gpu_top_ring {
                const char *name;
                union gpu_top_payload {
@@ -54,6 +60,8 @@ struct gpu_top {
                double queued;
                double runnable;
                double running;
+
+               double load[NUM_LOADS];
        } ring[MAX_RINGS];
 
        struct gpu_top_stat {
@@ -69,7 +77,7 @@ struct gpu_top {
        int count;
 };
 
-void gpu_top_init(struct gpu_top *gt);
+void gpu_top_init(struct gpu_top *gt, unsigned int period_us);
 int gpu_top_update(struct gpu_top *gt);
 
 #endif /* GPU_TOP_H */
overlay/overlay.c +8 -6
index a639703ebcec..30f712e4415a 100644
@@ -141,7 +141,8 @@ struct overlay_context {
 };
 
 static void init_gpu_top(struct overlay_context *ctx,
-                        struct overlay_gpu_top *gt)
+                        struct overlay_gpu_top *gt,
+                        unsigned int period_us)
 {
        const double rgba[][4] = {
                { 1, 0.25, 0.25, 1 },
@@ -152,7 +153,7 @@ static void init_gpu_top(struct overlay_context *ctx,
        int n;
 
        cpu_top_init(&gt->cpu_top);
-       gpu_top_init(&gt->gpu_top);
+       gpu_top_init(&gt->gpu_top, period_us);
 
        chart_init(&gt->cpu, "CPU", 120);
        chart_set_position(&gt->cpu, PAD, PAD);
@@ -929,13 +930,13 @@ int main(int argc, char **argv)
 
        debugfs_init();
 
-       init_gpu_top(&ctx, &ctx.gpu_top);
+       sample_period = get_sample_period(&config);
+
+       init_gpu_top(&ctx, &ctx.gpu_top, sample_period);
        init_gpu_perf(&ctx, &ctx.gpu_perf);
        init_gpu_freq(&ctx, &ctx.gpu_freq);
        init_gem_objects(&ctx, &ctx.gem_objects);
 
-       sample_period = get_sample_period(&config);
-
        i = 0;
        while (1) {
                ctx.time = time(NULL);
@@ -951,16 +952,26 @@ int main(int argc, char **argv)
                show_gem_objects(&ctx, &ctx.gem_objects);
 
                {
-                       char buf[80];
+                       struct gpu_top *gt = &ctx.gpu_top.gpu_top;
+                       char buf[80], buf2[256];

overlay/overlay.c int main(int argc, char **argv) · line 966

Quoted 10 lines
overlay/overlay.c +8 -0
                        cairo_text_extents_t extents;
+
                        gethostname(buf, sizeof(buf));
+                       snprintf(buf2, sizeof(buf2),
+                                "%s; %u engines; load-avg %s %.2f, %s %.2f, %s %.2f",
+                                buf,
+                                gt->num_rings,
+                                gt->load_name[0], gt->load[0],
+                                gt->load_name[1], gt->load[1],
+                                gt->load_name[2], gt->load[2]);

Too much text :)

"%s: %u engines, load %.2f %.2f %.2f" worksforme

overlay/overlay.c +12 -10
index 30f712e4..91f8d523 100644
@@ -953,25 +953,27 @@ int main(int argc, char **argv)
 
                {
                        struct gpu_top *gt = &ctx.gpu_top.gpu_top;
-                       char buf[80], buf2[256];
                        cairo_text_extents_t extents;
+                       char buf[256];
 
                        gethostname(buf, sizeof(buf));
-                       snprintf(buf2, sizeof(buf2),
-                                "%s; %u engines; load-avg %s %.2f, %s %.2f, %s %.2f",
-                                buf,
-                                gt->num_rings,
-                                gt->load_name[0], gt->load[0],
-                                gt->load_name[1], gt->load[1],
-                                gt->load_name[2], gt->load[2]);
+                        if (gt->load[2] > 0) { /* gt->has_load_avg */
+                           int len = strlen(buf);
+                           snprintf(buf + len, sizeof(buf) - len,
+                                    ": %u engines, load %.2f %.2f %.2f",
+                                    gt->num_rings,
+                                    gt->load[0],
+                                    gt->load[1],
+                                    gt->load[2]);
+                        }
 
                        cairo_set_source_rgb(ctx.cr, .5, .5, .5);
                        cairo_set_font_size(ctx.cr, PAD-2);
-                       cairo_text_extents(ctx.cr, buf2, &extents);
+                       cairo_text_extents(ctx.cr, buf, &extents);
                        cairo_move_to(ctx.cr,
                                      (ctx.width-extents.width)/2.,
                                      1+extents.height);
-                       cairo_show_text(ctx.cr, buf2);
+                       cairo_show_text(ctx.cr, buf);
                }
 
                cairo_destroy(ctx.cr);

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#6 lore raw

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

In reply to Tvrtko Ursulin

Quoting Tvrtko Ursulin (2018-02-12 19:01:58)

Quoted 44 lines

From: Tvrtko Ursulin <[email protected]>

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.

---
 overlay/gpu-top.c | 37 ++++++++++++++++++++++++++++++++++++-
 overlay/gpu-top.h | 10 +++++++++-
 overlay/overlay.c | 27 +++++++++++++++++++--------
 3 files changed, 64 insertions(+), 10 deletions(-)
overlay/gpu-top.c +11 -1
index 22e9badb22c1..ca25e998e3d7 100644
@@ -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;
 

overlay/gpu-top.c static void mmio_init(struct gpu_top *gt) · line 320

Quoted 10 lines
overlay/gpu-top.c +7 -0
        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...

overlay/gpu-top.c +3 -5
index ca25e998..e40766fe 100644
@@ -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
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#7 lore raw

[igt-dev] ✗ Fi.CI.BAT: failure for intel-gpu-overlay: Queued/runnable/running engine stats

In reply to Tvrtko Ursulin
== Series Details ==

== Series Details ==

Series: intel-gpu-overlay: Queued/runnable/running engine stats
URL : https://patchwork.freedesktop.org/series/38101/
State : failure

== Summary ==

IGT patchset tested on top of latest successful build 3f62e3da85b792ff74c0420e62f2d39a09ddcc1f tests/kms_rotation_crc: Test all pixel formats on all planes.

with latest DRM-Tip kernel build CI_DRM_3757
83878f486e68 drm-tip: 2018y-02m-12d-17h-43m-07s UTC integration manifest

No testlist changes.

Test kms_pipe_crc_basic:

        Subgroup suspend-read-crc-pipe-b:
                pass       -> INCOMPLETE (fi-snb-2520m) fdo#103713
Test prime_vgem:
        Subgroup basic-fence-flip:
                fail       -> PASS       (fi-ilk-650)
                pass       -> FAIL       (fi-hsw-4770)

fdo#103713 https://bugs.freedesktop.org/show_bug.cgi?id=103713

fi-bdw-5557u     total:288  pass:265  dwarn:0   dfail:0   fail:2   skip:21  time:440s
fi-bdw-gvtdvm    total:288  pass:264  dwarn:0   dfail:0   fail:0   skip:24  time:427s
fi-blb-e6850     total:288  pass:223  dwarn:1   dfail:0   fail:0   skip:64  time:377s
fi-bsw-n3050     total:288  pass:242  dwarn:0   dfail:0   fail:0   skip:46  time:493s
fi-bwr-2160      total:288  pass:183  dwarn:0   dfail:0   fail:0   skip:105 time:290s
fi-bxt-dsi       total:288  pass:258  dwarn:0   dfail:0   fail:0   skip:30  time:485s
fi-bxt-j4205     total:288  pass:259  dwarn:0   dfail:0   fail:0   skip:29  time:492s
fi-byt-j1900     total:288  pass:253  dwarn:0   dfail:0   fail:0   skip:35  time:474s
fi-byt-n2820     total:288  pass:249  dwarn:0   dfail:0   fail:0   skip:39  time:465s
fi-cfl-s2        total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:573s
fi-cnl-y3        total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:577s
fi-elk-e7500     total:288  pass:229  dwarn:0   dfail:0   fail:0   skip:59  time:418s
fi-gdg-551       total:288  pass:179  dwarn:0   dfail:0   fail:1   skip:108 time:286s
fi-glk-1         total:288  pass:260  dwarn:0   dfail:0   fail:0   skip:28  time:516s
fi-hsw-4770      total:288  pass:258  dwarn:0   dfail:0   fail:3   skip:27  time:413s
fi-ilk-650       total:288  pass:228  dwarn:0   dfail:0   fail:0   skip:60  time:414s
fi-ivb-3520m     total:288  pass:259  dwarn:0   dfail:0   fail:0   skip:29  time:461s
fi-ivb-3770      total:288  pass:255  dwarn:0   dfail:0   fail:0   skip:33  time:416s
fi-kbl-7500u     total:288  pass:263  dwarn:1   dfail:0   fail:0   skip:24  time:459s
fi-kbl-7560u     total:288  pass:269  dwarn:0   dfail:0   fail:0   skip:19  time:493s
fi-kbl-r         total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:501s
fi-pnv-d510      total:288  pass:222  dwarn:1   dfail:0   fail:0   skip:65  time:595s
fi-skl-6260u     total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:428s
fi-skl-6600u     total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:506s
fi-skl-6700hq    total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:529s
fi-skl-6700k2    total:288  pass:264  dwarn:0   dfail:0   fail:0   skip:24  time:487s
fi-skl-6770hq    total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:480s
fi-skl-guc       total:288  pass:260  dwarn:0   dfail:0   fail:0   skip:28  time:419s
fi-skl-gvtdvm    total:288  pass:265  dwarn:0   dfail:0   fail:0   skip:23  time:430s
fi-snb-2520m     total:245  pass:211  dwarn:0   dfail:0   fail:0   skip:33 
fi-snb-2600      total:288  pass:248  dwarn:0   dfail:0   fail:0   skip:40  time:410s

Blacklisted hosts:
fi-glk-dsi total:288 pass:258 dwarn:0 dfail:0 fail:0 skip:30 time:474s

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_904/issues.html
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev