Mesa (master): gallium/hud: add API-thread-busy for monitoring the thread load

Marek Olšák mareko at kemper.freedesktop.org
Mon Jun 26 00:22:14 UTC 2017


Module: Mesa
Branch: master
Commit: 8f4bc8a3240de6255ead042704b80a18ebcf0973
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=8f4bc8a3240de6255ead042704b80a18ebcf0973

Author: Marek Olšák <marek.olsak at amd.com>
Date:   Wed Jun 21 21:12:26 2017 +0200

gallium/hud: add API-thread-busy for monitoring the thread load

Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>

---

 src/gallium/auxiliary/hud/hud_context.c |  5 ++++-
 src/gallium/auxiliary/hud/hud_cpu.c     | 19 +++++++++++++++++--
 src/gallium/auxiliary/hud/hud_private.h |  2 +-
 3 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/src/gallium/auxiliary/hud/hud_context.c b/src/gallium/auxiliary/hud/hud_context.c
index ae2e0fb1be..9ab7822366 100644
--- a/src/gallium/auxiliary/hud/hud_context.c
+++ b/src/gallium/auxiliary/hud/hud_context.c
@@ -1150,8 +1150,11 @@ hud_parse_env_var(struct hud_context *hud, const char *env)
       else if (sscanf(name, "cpu%u%s", &i, s) == 1) {
          hud_cpu_graph_install(pane, i);
       }
+      else if (strcmp(name, "API-thread-busy") == 0) {
+         hud_thread_busy_install(pane, name, false);
+      }
       else if (strcmp(name, "main-thread-busy") == 0) {
-         hud_main_thread_busy_install(pane, name);
+         hud_thread_busy_install(pane, name, true);
       }
 #if HAVE_GALLIUM_EXTRA_HUD
       else if (sscanf(name, "nic-rx-%s", arg_name) == 1) {
diff --git a/src/gallium/auxiliary/hud/hud_cpu.c b/src/gallium/auxiliary/hud/hud_cpu.c
index 26f9fa78ee..38403f9f78 100644
--- a/src/gallium/auxiliary/hud/hud_cpu.c
+++ b/src/gallium/auxiliary/hud/hud_cpu.c
@@ -32,6 +32,7 @@
 #include "os/os_time.h"
 #include "os/os_thread.h"
 #include "util/u_memory.h"
+#include "util/u_queue.h"
 #include <stdio.h>
 #include <inttypes.h>
 #ifdef PIPE_OS_WINDOWS
@@ -231,6 +232,7 @@ hud_get_num_cpus(void)
 }
 
 struct thread_info {
+   bool main_thread;
    int64_t last_time;
    int64_t last_thread_time;
 };
@@ -243,7 +245,19 @@ query_api_thread_busy_status(struct hud_graph *gr)
 
    if (info->last_time) {
       if (info->last_time + gr->pane->period*1000 <= now) {
-         int64_t thread_now = pipe_current_thread_get_time_nano();
+         int64_t thread_now;
+
+         if (info->main_thread) {
+            thread_now = pipe_current_thread_get_time_nano();
+         } else {
+            struct util_queue_monitoring *mon = gr->pane->hud->monitored_queue;
+
+            if (mon && mon->queue)
+               thread_now = util_queue_get_thread_time_nano(mon->queue, 0);
+            else
+               thread_now = 0;
+         }
+
          unsigned percent = (thread_now - info->last_thread_time) * 100 /
                             (now - info->last_time);
 
@@ -266,7 +280,7 @@ query_api_thread_busy_status(struct hud_graph *gr)
 }
 
 void
-hud_main_thread_busy_install(struct hud_pane *pane, const char *name)
+hud_thread_busy_install(struct hud_pane *pane, const char *name, bool main)
 {
    struct hud_graph *gr;
 
@@ -282,6 +296,7 @@ hud_main_thread_busy_install(struct hud_pane *pane, const char *name)
       return;
    }
 
+   ((struct thread_info*)gr->query_data)->main_thread = main;
    gr->query_new_value = query_api_thread_busy_status;
 
    /* Don't use free() as our callback as that messes up Gallium's
diff --git a/src/gallium/auxiliary/hud/hud_private.h b/src/gallium/auxiliary/hud/hud_private.h
index 580ceb3af8..b8726da734 100644
--- a/src/gallium/auxiliary/hud/hud_private.h
+++ b/src/gallium/auxiliary/hud/hud_private.h
@@ -144,7 +144,7 @@ int hud_get_num_cpus(void);
 
 void hud_fps_graph_install(struct hud_pane *pane);
 void hud_cpu_graph_install(struct hud_pane *pane, unsigned cpu_index);
-void hud_main_thread_busy_install(struct hud_pane *pane, const char *name);
+void hud_thread_busy_install(struct hud_pane *pane, const char *name, bool main);
 void hud_pipe_query_install(struct hud_batch_query_context **pbq,
                             struct hud_pane *pane, struct pipe_context *pipe,
                             const char *name, unsigned query_type,




More information about the mesa-commit mailing list