Re: [PATCH v2] stats: use CLOCK_THREAD_CPUTIME_ID for cpu statistics

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Acked-by: Christophe Fergeau <cfergeau@xxxxxxxxxx>

On Mon, Jan 11, 2016 at 03:45:40PM +0000, Frediano Ziglio wrote:
> Use CLOCK_THREAD_CPUTIME_ID instead of getting the clock
> with pthread_getcpuclockid.
> This avoids to call red_worker_get_clockid. This function returns
> uninitialized value at the time DisplayChannel is built resulting in setting
> statistics to CLOCK_REALTIME (which is 0) instead to cpu time as expected.
> 
> Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
> ---
>  server/display-channel.c |  2 +-
>  server/red-worker.c      | 16 ++--------------
>  server/red-worker.h      |  1 -
>  3 files changed, 3 insertions(+), 16 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..ae798ec 100644
> --- a/server/red-worker.c
> +++ b/server/red-worker.c
> @@ -67,7 +67,6 @@ struct SpiceWatch {
>  
>  struct RedWorker {
>      pthread_t thread;
> -    clockid_t clockid;
>      QXLInstance *qxl;
>      RedDispatcher *red_dispatcher;
>      int running;
> @@ -256,7 +255,7 @@ static int red_process_display(RedWorker *worker, uint32_t max_pipe_size, int *r
>  
>          if (worker->record_fd)
>              red_record_qxl_command(worker->record_fd, &worker->mem_slots, ext_cmd,
> -                                   stat_now(worker->clockid));
> +                                   stat_now(CLOCK_THREAD_CPUTIME_ID));
>  
>          stat_inc_counter(worker->command_counter, 1);
>          worker->display_poll_tries = 0;
> @@ -1348,7 +1347,7 @@ static void worker_dispatcher_record(void *opaque, uint32_t message_type, void *
>  {
>      RedWorker *worker = opaque;
>  
> -    red_record_event(worker->record_fd, 1, message_type, stat_now(worker->clockid));
> +    red_record_event(worker->record_fd, 1, message_type, stat_now(CLOCK_THREAD_CPUTIME_ID));
>  }
>  
>  static void register_callbacks(Dispatcher *dispatcher)
> @@ -1619,10 +1618,6 @@ SPICE_GNUC_NORETURN static void *red_worker_main(void *arg)
>          spice_error("failed to create timer queue");
>      }
>  
> -    if (pthread_getcpuclockid(pthread_self(), &worker->clockid)) {
> -        spice_warning("getcpuclockid failed");
> -    }
> -
>      RED_CHANNEL(worker->cursor_channel)->thread_id = pthread_self();
>      RED_CHANNEL(worker->display_channel)->thread_id = pthread_self();
>  
> @@ -1723,10 +1718,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
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel@xxxxxxxxxxxxxxxxxxxxx
> http://lists.freedesktop.org/mailman/listinfo/spice-devel

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]