[Spice-devel] [PATCH] stats: use CLOCK_THREAD_CPUTIME_ID for cpu statistics

Frediano Ziglio fziglio at redhat.com
Wed Dec 16 01:45:23 PST 2015


Avoid to call red_worker_get_clockid. This function returns uninitialized
value at the timer DisplayChannel is build resulting in setting
statistics to CLOCK_REALTIME (which is 0) instead to cpu time as expected.

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 server/display-channel.c | 2 +-
 server/red-worker.c      | 7 -------
 server/red-worker.h      | 1 -
 3 files changed, 1 insertion(+), 9 deletions(-)

diff --git a/server/display-channel.c b/server/display-channel.c
index ec4ca10..3bf065c 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -2041,7 +2041,7 @@ DisplayChannel* display_channel_new(RedWorker *worker, int migrate, int stream_v
         &cbs, dcc_handle_message);
     spice_return_val_if_fail(display, NULL);
 
-    clockid_t stat_clock = red_worker_get_clockid(worker);
+    clockid_t stat_clock = CLOCK_THREAD_CPUTIME_ID;
     stat_init(&display->add_stat, "add", stat_clock);
     stat_init(&display->exclude_stat, "exclude", stat_clock);
     stat_init(&display->__exclude_stat, "__exclude", stat_clock);
diff --git a/server/red-worker.c b/server/red-worker.c
index dfaf4ba..839ef49 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -1723,10 +1723,3 @@ RedChannel* red_worker_get_display_channel(RedWorker *worker)
 
     return RED_CHANNEL(worker->display_channel);
 }
-
-clockid_t red_worker_get_clockid(RedWorker *worker)
-{
-    spice_return_val_if_fail(worker, 0);
-
-    return worker->clockid;
-}
diff --git a/server/red-worker.h b/server/red-worker.h
index 1f0cd99..91533e1 100644
--- a/server/red-worker.h
+++ b/server/red-worker.h
@@ -97,7 +97,6 @@ bool       red_worker_run(RedWorker *worker);
 QXLInstance* red_worker_get_qxl(RedWorker *worker);
 RedChannel* red_worker_get_cursor_channel(RedWorker *worker);
 RedChannel* red_worker_get_display_channel(RedWorker *worker);
-clockid_t red_worker_get_clockid(RedWorker *worker);
 RedMemSlotInfo* red_worker_get_memslot(RedWorker *worker);
 
 void red_drawable_unref(RedWorker *worker, RedDrawable *red_drawable,
-- 
2.4.3



More information about the Spice-devel mailing list