overlay: Hide kworker threads in overview

The kworker threads are used for flip handling and other non-userspace
driver tasks. They are non-blocking and so do not impact upon how
userspace performs, but they do obscure that information in the
overview.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
diff --git a/overlay/gpu-perf.c b/overlay/gpu-perf.c
index 1d35da5..42ac44d 100644
--- a/overlay/gpu-perf.c
+++ b/overlay/gpu-perf.c
@@ -266,6 +266,7 @@
 		return 0;
 
 	wait->comm = comm;
+	wait->comm->active = true;
 	wait->seqno = sample->raw[2];
 	wait->time = sample->time;
 	wait->next = gp->wait[sample->raw[1]];
@@ -284,6 +285,8 @@
 			continue;
 
 		wait->comm->wait_time += sample->time - wait->time;
+		wait->comm->active = false;
+
 		*prev = wait->next;
 		free(wait);
 		return 1;
diff --git a/overlay/gpu-perf.h b/overlay/gpu-perf.h
index 23eba2f..3e363fb 100644
--- a/overlay/gpu-perf.h
+++ b/overlay/gpu-perf.h
@@ -26,6 +26,7 @@
 #define GPU_PERF_H
 
 #include <stdint.h>
+#include <stdbool.h>
 
 #define MAX_RINGS 4
 
@@ -48,6 +49,7 @@
 		struct gpu_perf_comm *next;
 		char name[256];
 		pid_t pid;
+		bool active;
 		int nr_requests[4];
 		void *user_data;
 
diff --git a/overlay/overlay.c b/overlay/overlay.c
index e61587f..3615466 100644
--- a/overlay/overlay.c
+++ b/overlay/overlay.c
@@ -362,6 +362,12 @@
 	for (comm = gp->gpu_perf.comm; comm; comm = comm->next) {
 		int total;
 
+		if (comm->name[0] == '\0')
+			continue;
+
+		if (strncmp(comm->name, "kworker", 7) == 0)
+			continue;
+
 		if (comm->user_data == NULL) {
 			comm->user_data = malloc(sizeof(struct chart));
 			if (comm->user_data == NULL)
@@ -387,11 +393,18 @@
 	}
 
 	range[0] = range[1] = 0;
-	for (comm = gp->gpu_perf.comm; comm; comm = comm->next)
+	for (comm = gp->gpu_perf.comm; comm; comm = comm->next) {
+		if (comm->user_data == NULL)
+			continue;
+
 		chart_get_range(comm->user_data, range);
+	}
 
 	y2 = y1 = y;
 	for (comm = gp->gpu_perf.comm; comm; comm = comm->next) {
+		if (comm->user_data == NULL)
+			continue;
+
 		chart_set_range(comm->user_data, range[0], range[1]);
 		chart_draw(comm->user_data, ctx->cr);
 		y2 += 14;
@@ -414,7 +427,7 @@
 	for (prev = &gp->gpu_perf.comm; (comm = *prev) != NULL; ) {
 		int need_comma = 0, len;
 
-		if (comm->name[0] == '\0')
+		if (comm->user_data == NULL)
 			goto skip_comm;
 
 		len = sprintf(buf, "%s:", comm->name);
@@ -467,8 +480,9 @@
 
 skip_comm:
 		memset(comm->nr_requests, 0, sizeof(comm->nr_requests));
-		if (comm->show < ctx->time - IDLE_TIME ||
-		    strcmp(comm->name, get_comm(comm->pid, buf, sizeof(buf)))) {
+		if (!comm->active &&
+		    (comm->show < ctx->time - IDLE_TIME ||
+		     strcmp(comm->name, get_comm(comm->pid, buf, sizeof(buf))))) {
 			*prev = comm->next;
 			if (comm->user_data) {
 				chart_fini(comm->user_data);