All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pat Campbell <plc@novell.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: xen-devel@lists.xensource.com,
	"Daniel P. Berrange" <berrange@redhat.com>
Subject: Re: [RFC]Dynamic modes support for PV xenfb (included)
Date: Tue, 05 Feb 2008 16:38:06 -0700	[thread overview]
Message-ID: <47A8F35E.9050604@novell.com> (raw)
In-Reply-To: <87wspjlogu.fsf@pike.pond.sub.org>

Markus Armbruster wrote:
> Pat Campbell <plc@novell.com> writes:
>   
cut out a whole bunch to address the need to protect some variables.
>
>   
>> +
>> +	xenfb_send_event(info, &event);
>>  }
>>  
>>  static int xenfb_queue_full(struct xenfb_info *info)
>> @@ -209,6 +250,16 @@ static void xenfb_update_screen(struct x
>>  	xenfb_do_update(info, x1, y1, x2 - x1, y2 - y1);
>>  }
>>  
>> +static void xenfb_resize_screen(struct xenfb_info *info)
>> +{
>> +	if (xenfb_queue_full(info))
>> +		return;
>> +
>> +	info->resize_dpy = 0;
>> +	xenfb_do_resize(info);
>> +	xenfb_refresh(info, 0, 0, info->xres, info->yres);
>>     
>
> Hmm, ugly.  See next comment.
>
>   
>> +}
>> +
>>  static int xenfb_thread(void *data)
>>  {
>>  	struct xenfb_info *info = data;
>> @@ -217,6 +268,9 @@ static int xenfb_thread(void *data)
>>  		if (info->dirty) {
>>  			info->dirty = 0;
>>  			xenfb_update_screen(info);
>> +		}
>> +		if (info->resize_dpy) {
>> +			xenfb_resize_screen(info);
>>  		}
>>     
>
> Both screen resizes and dirtying don't go to the backend immediately.
> Instead, they accumulate in struct xenfb_info (dirty rectangle and
> resize_dpy flag) until they get pushed by xenfb_thread().
>
> The way things work, a resize triggers three events:
>
> 1. The update event for the dirty rectangle.  In theory, the dirty
> rectangle could be clean, but I expect it to be quite dirty in
> practice, as user space typically redraws everything right after a
> resize.
>
> 2. The resize event.
>
> 3. Another update event, because xenfb_resize_screen() dirties the
> whole screen.  This event is delayed until the next iteration of
> xenfb_thread()'s loop.
>
> I'd rather do it like this: decree that resize events count as whole
> screen updates.  Make xenfb_resize_screen() clear the dirty rectangle
> (optional, saves an update event).  Test resize_dpy before dirty.
>
> Also: you access resize_dpy, xres, yres and fb_stride from multiple
> threads without synchronization.  I fear that's not safe.  Don't you
> have to protect them with a spinlock, like dirty_lock protects the
> dirty rectangle?  Could reuse dirty_lock, I guess.
>
>   
Don't need to protect these three:
  fb_stride: Eliminated, now using fb_info->fixed.line_len which is read
only after probe()
  xres, yres:
     Set in xenfb_set_par(), read only in all other threads. 

resize_dpy:
While thinking about this variable it occurred to me that a resize would
invalidate any screen updates that are in the queue.  Resize from 
xenfb_thread() was done so that I could ensure that the resize did not
get lost due to a queue full situation. So,  if I clear the queue,
cons=prod, I can add in the resize event packet directly from
xenfb_set_par() getting  rid of resizing from within the thread.  Change
would require a new spinlock to protect the queue but would eliminate
resize_dpy.

Setting cons=prod should be safe.  Worst case is when a clear occurs
while backend is in the event for loop, loop process events it did not
need to. 

xenfb_resize_screen()  becomes:   (called directly from xenfb_set_par())
    spin_lock_irqsave(&info->queue_lock, flags);
    info->page->out_cons = info->page->out_prod;
    spin_unlock_irqrestore(&info->queue_lock, flags);
    xenfb_do_resize(info);
    xenfb_refresh(info, 0, 0, info->xres, info->yres);

xenfb_send_event() becomes:
    spin_lock_irqsave(&info->queue_lock, flags);
    prod = info->page->out_prod;
    /* caller ensures !xenfb_queue_full() */
    mb();           /* ensure ring space available */
    XENFB_OUT_RING_REF(info->page, prod) = *event;
    wmb();          /* ensure ring contents visible */
    info->page->out_prod = prod + 1;
    spin_unlock_irqrestore(&info->queue_lock, flags);

Thoughts on this approach?

Pat

  reply	other threads:[~2008-02-05 23:38 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-04 18:49 [RFC]Dynamic modes support for PV xenfb (included) Pat Campbell
2008-02-05  9:52 ` Markus Armbruster
2008-02-05 23:38   ` Pat Campbell [this message]
2008-02-06 15:49     ` Markus Armbruster
  -- strict thread matches above, loose matches on Subject: below --
2008-03-09 21:19 [RFC] Dynamic " Pat Campbell
2008-03-09 21:29 ` Samuel Thibault
2008-03-10 12:36 ` Samuel Thibault
2008-03-10 16:16 ` Samuel Thibault
2008-03-10 16:36   ` Samuel Thibault
2008-03-12 17:04 ` Markus Armbruster
2008-03-13 13:05   ` Pat Campbell
2008-03-13 19:53     ` Pat Campbell
2008-03-14 16:39     ` Markus Armbruster
2008-01-28  0:48 Pat Campbell
2008-01-28  8:07 ` Keir Fraser
2008-01-30  9:43 ` Markus Armbruster
2008-01-30 13:41   ` Pat Campbell
2008-01-30 17:45     ` Markus Armbruster
2008-01-30 20:27       ` Pat Campbell
2008-01-31  8:22         ` Gerd Hoffmann
2008-01-31  8:50           ` Markus Armbruster
2008-01-31  9:06         ` Markus Armbruster
2008-01-30 20:43 ` Daniel P. Berrange
2008-02-28 10:36 ` Keir Fraser
2008-02-28 11:36   ` Markus Armbruster
2007-12-31 12:27 Pat Campbell
2008-01-02 10:51 ` Gerd Hoffmann
     [not found] <476133BC0200001800606E1D@sinclair.provo.novell.com>
     [not found] ` <476999300200001800607A16@sinclair.provo.novell.com>
2007-12-20  5:20   ` Pat Campbell
2007-12-23 21:58     ` Mark Williamson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=47A8F35E.9050604@novell.com \
    --to=plc@novell.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.