[Spice-devel] [PATCH 09/16] worker: move current to display

Jonathon Jongsma jjongsma at redhat.com
Tue Nov 10 08:29:07 PST 2015


ACK

On Tue, 2015-11-10 at 14:16 +0000, Frediano Ziglio wrote:
> From: Marc-André Lureau <marcandre.lureau at gmail.com>
> 
> ---
>  server/display-channel.h |  3 +++
>  server/red_worker.c      | 29 +++++++++++++++++------------
>  2 files changed, 20 insertions(+), 12 deletions(-)
> 
> diff --git a/server/display-channel.h b/server/display-channel.h
> index 76e4d11..898ff01 100644
> --- a/server/display-channel.h
> +++ b/server/display-channel.h
> @@ -282,6 +282,9 @@ struct DisplayChannel {
>      uint32_t renderers[RED_RENDERER_LAST];
>      uint32_t renderer;
>  
> +    Ring current_list; // of TreeItem
> +    uint32_t current_size;
> +
>      int enable_jpeg;
>      int jpeg_quality;
>      int enable_zlib_glz_wrap;
> diff --git a/server/red_worker.c b/server/red_worker.c
> index a51fe88..86ce7a1 100644
> --- a/server/red_worker.c
> +++ b/server/red_worker.c
> @@ -354,8 +354,6 @@ typedef struct RedWorker {
>      uint32_t n_surfaces;
>      SpiceImageSurfaces image_surfaces;
>  
> -    Ring current_list;
> -    uint32_t current_size;
>      uint32_t drawable_count;
>      uint32_t red_drawable_count;
>      uint32_t glz_drawable_count;
> @@ -1167,13 +1165,15 @@ static void
> red_flush_source_surfaces(RedWorker *worker, Drawable *drawable)
>  
>  static inline void current_remove_drawable(RedWorker *worker,
> Drawable *item)
>  {
> -    display_stream_trace_add_drawable(worker->display_channel,
> item);
> +    DisplayChannel *display = worker->display_channel;
> +
> +    display_stream_trace_add_drawable(display, item);
>      remove_shadow(&item->tree_item);
>      ring_remove(&item->tree_item.base.siblings_link);
>      ring_remove(&item->list_link);
>      ring_remove(&item->surface_list_link);
>      red_worker_drawable_unref(worker, item);
> -    worker->current_size--;
> +    display->current_size--;
>  }
>  
>  static void remove_drawable(RedWorker *worker, Drawable *drawable)
> @@ -1493,14 +1493,15 @@ static inline int is_opaque_item(TreeItem
> *item)
>  
>  static inline void __current_add_drawable(RedWorker *worker,
> Drawable *drawable, RingItem *pos)
>  {
> +    DisplayChannel *display = worker->display_channel;
>      RedSurface *surface;
>      uint32_t surface_id = drawable->surface_id;
>  
>      surface = &worker->surfaces[surface_id];
>      ring_add_after(&drawable->tree_item.base.siblings_link, pos);
> -    ring_add(&worker->current_list, &drawable->list_link);
> +    ring_add(&display->current_list, &drawable->list_link);
>      ring_add(&surface->current_list, &drawable->surface_list_link);
> -    worker->current_size++;
> +    display->current_size++;
>      drawable->refs++;
>  }
>  
> @@ -2850,7 +2851,8 @@ static inline int
> red_handle_self_bitmap(RedWorker *worker, Drawable *drawable)
>  
>  static bool free_one_drawable(RedWorker *worker, int force_glz_free)
>  {
> -    RingItem *ring_item = ring_get_tail(&worker->current_list);
> +    DisplayChannel *display = worker->display_channel;
> +    RingItem *ring_item = ring_get_tail(&display->current_list);
>      Drawable *drawable;
>      Container *container;
>  
> @@ -3301,6 +3303,7 @@ static void validate_area(RedWorker *worker,
> const SpiceRect *area, uint32_t sur
>  static void red_update_area_till(RedWorker *worker, const SpiceRect
> *area, int surface_id,
>                                   Drawable *last)
>  {
> +    DisplayChannel *display = worker->display_channel;
>      RedSurface *surface;
>      Drawable *surface_last = NULL;
>      Ring *ring;
> @@ -3315,7 +3318,7 @@ static void red_update_area_till(RedWorker
> *worker, const SpiceRect *area, int s
>  
>      if (surface_id != last->surface_id) {
>          // find the nearest older drawable from the appropriate
> surface
> -        ring = &worker->current_list;
> +        ring = &display->current_list;
>          ring_item = &last->list_link;
>          while ((ring_item = ring_next(ring, ring_item))) {
>              now = SPICE_CONTAINEROF(ring_item, Drawable, list_link);
> @@ -3604,6 +3607,7 @@ static int red_process_commands(RedWorker
> *worker, uint32_t max_pipe_size, int *
>  
>  static void red_free_some(RedWorker *worker)
>  {
> +    DisplayChannel *display = worker->display_channel;
>      int n = 0;
>      DisplayChannelClient *dcc;
>      RingItem *item, *next;
> @@ -3621,7 +3625,7 @@ static void red_free_some(RedWorker *worker)
>          }
>      }
>  
> -    while (!ring_is_empty(&worker->current_list) && n++ <
> RED_RELEASE_BUNCH_SIZE) {
> +    while (!ring_is_empty(&display->current_list) && n++ <
> RED_RELEASE_BUNCH_SIZE) {
>          free_one_drawable(worker, TRUE);
>      }
>  
> @@ -8813,6 +8817,7 @@ static void display_channel_create(RedWorker
> *worker, int migrate)
>      display_channel->renderer = RED_RENDERER_INVALID;
>      init_streams(display_channel);
>      image_cache_init(&display_channel->image_cache);
> +    ring_init(&display_channel->current_list);
>  }
>  
>  static void guest_set_client_capabilities(RedWorker *worker)
> @@ -9365,6 +9370,7 @@ static void handle_dev_wakeup(void *opaque,
> void *payload)
>  static void handle_dev_oom(void *opaque, void *payload)
>  {
>      RedWorker *worker = opaque;
> +    DisplayChannel *display = worker->display_channel;
>  
>      RedChannel *display_red_channel = &worker->display_channel
> ->common.base;
>      int ring_is_empty;
> @@ -9375,7 +9381,7 @@ static void handle_dev_oom(void *opaque, void
> *payload)
>                  worker->drawable_count,
>                  worker->red_drawable_count,
>                  worker->glz_drawable_count,
> -                worker->current_size,
> +                display->current_size,
>                  worker->display_channel ?
>                  red_channel_sum_pipes_size(display_red_channel) :
> 0);
>      while (red_process_commands(worker, MAX_PIPE_SIZE,
> &ring_is_empty)) {
> @@ -9389,7 +9395,7 @@ static void handle_dev_oom(void *opaque, void
> *payload)
>                  worker->drawable_count,
>                  worker->red_drawable_count,
>                  worker->glz_drawable_count,
> -                worker->current_size,
> +                display->current_size,
>                  worker->display_channel ?
>                  red_channel_sum_pipes_size(display_red_channel) :
> 0);
>      red_dispatcher_clear_pending(worker->red_dispatcher,
> RED_DISPATCHER_PENDING_OOM);
> @@ -9936,7 +9942,6 @@ RedWorker* red_worker_new(QXLInstance *qxl,
> RedDispatcher *red_dispatcher)
>      worker->jpeg_state = jpeg_state;
>      worker->zlib_glz_state = zlib_glz_state;
>      worker->driver_cap_monitors_config = 0;
> -    ring_init(&worker->current_list);
>      image_surface_init(worker);
>      drawables_init(worker);
>      stat_init(&worker->add_stat, add_stat_name);


More information about the Spice-devel mailing list