PVFB: Add refresh period to XenStore parameters?
Hello,
Sometimes the backend of PVFB knows that it doesn't need permanent refresh, when the window is minimized for instance (no refresh at all), or the administration tools know that the window is thumnailed, and so a slow refresh rate is fine. Also, some users may want to tune the refresh rate according to the smoothness they would like, balanced with the CPU time that requires.
I've played with that idea a bit and it seems to work fine, saving computations and communications. I'm now wondering about the interface:
it looks to me like it could be as simple as a "refresh-period" node in the backend part of XenStore: the front-end would watch it, and update the timing of its internal refresh loop, xenfb_fps in the case of Linux' xenfb for instance. A period of 0 would mean that no refresh is needed (e.g. minimized window)
Samuel
Hello,
There was no comment on my proposition below, should I consider that it means people are fine with it? :)
Samuel
Quoted 14 lines · Samuel Thibault, le Fri 29 Feb 2008 12:08:07 +0000, a écrit :
Sometimes the backend of PVFB knows that it doesn't need permanent refresh, when the window is minimized for instance (no refresh at all), or the administration tools know that the window is thumnailed, and so a slow refresh rate is fine. Also, some users may want to tune the refresh rate according to the smoothness they would like, balanced with the CPU time that requires.
I've played with that idea a bit and it seems to work fine, saving computations and communications. I'm now wondering about the interface:
it looks to me like it could be as simple as a "refresh-period" node in the backend part of XenStore: the front-end would watch it, and update the timing of its internal refresh loop,xenfb_fpsin the case of Linux' xenfb for instance. A period of 0 would mean that no refresh is needed (e.g. minimized window)
Quoted 8 lines · Samuel Thibault
Hello,
Sometimes the backend of PVFB knows that it doesn't need permanent refresh, when the window is minimized for instance (no refresh at all), or the administration tools know that the window is thumnailed, and so a slow refresh rate is fine. Also, some users may want to tune the refresh rate according to the smoothness they would like, balanced with the CPU time that requires.
Can you quantify the CPU time savings? Are you sure they're worth the extra complexity?
Are you sure the ability to control the rate is required? Why isn't it sufficient to be able to switch updates off?
Quoted 9 lines
I've played with that idea a bit and it seems to work fine, saving computations and communications. I'm now wondering about the interface:
it looks to me like it could be as simple as a "refresh-period" node in the backend part of XenStore: the front-end would watch it, and update the timing of its internal refresh loop,xenfb_fpsin the case of Linux' xenfb for instance. A period of 0 would mean that no refresh is needed (e.g. minimized window)Samuel
Another option is to send a suitable message through the ring. That's how the dynamic mode patch (not yet merged) communicates resolution change, albeit in the other direction.
The pvops PVFB uses fb_defio. I think we can change the refresh period there by changing xenfb_defio.delay, but that doesn't exactly look like something the API wants us to do.
Hello,
Quoted 9 lines · Markus Armbruster, le Mon 03 Mar 2008 19:03:46 +0100, a écrit :
Quoted 6 lines · Samuel Thibault
Sometimes the backend of PVFB knows that it doesn't need permanent refresh, when the window is minimized for instance (no refresh at all), or the administration tools know that the window is thumnailed, and so a slow refresh rate is fine. Also, some users may want to tune the refresh rate according to the smoothness they would like, balanced with the CPU time that requires.
Can you quantify the CPU time savings?
Something like 6% CPU on my test machine (by just slowing down from 30ms to 1000ms interval).
In my case, I'm using PVFB to expose the stubdomain qemu display. The problem is that every 30ms, qemu wakes up to memcmp() the whole video memory with a shadow buffer so as to track changes. If it knew that the window is minimized or reduced, it could stop or increase that polling interval. With SDL and vnc, it can, but when going through PVFB that information is lost.
Quoted 1 line
Are you sure they're worth the extra complexity?
At least watching a simple integer in XenStore is not very complex.
Note that this may not be a requirement, just the backend telling the frontend what he'd prefer to see. If it's difficult for the frontend to change the rate, then it can just ignore it, and the user won't be so happy, that's all.
Quoted 2 lines
Are you sure the ability to control the rate is required? Why isn't it sufficient to be able to switch updates off?
Being able to choose the smoothness of the interface is really a good user experience. To my feeling, the current 30ms default rate of qemu (7% CPU) is not so smooth (people don't use 30Hz monitors, to they? ;). I usually prefer spending e.g. 14% CPU to get a 10ms rate, but of course I don't want that CPU time to be used when the viewer is off screen. Other people won't feel that need and can save CPU% by slowing it down.
Also, in other cases, you just need to have a snapshot of the VMs, so a 1s rate (or even 10s) makes sense.
Quoted 1 line
Another option is to send a suitable message through the ring.
Yes, but then it's hard for management tools (e.g. a gui that manages VMs) to tune it, while a xenstore value is pretty easy to tinker with.
Quoted 3 lines
The pvops PVFB uses
fb_defio. I think we can change the refresh period there by changing xenfb_defio.delay, but that doesn't exactly look like something the API wants us to do.
Then that frontend may just ignore the rate. It's much less of a concern, since that frontend doesn't use an active polling loop, and thus consumes no CPU if nothing happens in the guest.
Samuel
Turning off refresh on minimized windows certainly sounds worth it to me. Let's not forget that even though it currently may save "only" 6% CPU, the current VGA emulation only has 4 MB of video RAM. This will need to increase in the future up to at least a factor of 8 if we want to be able to support all resolutions that modern monitors can handle. I know there are more efficient update code than a complete memcmp() in the works, and that will probably be needed before we can do 2560x1600x32 double-buffered in guests at any reasonable CPU usage, but with those in place, needless updates is probably going to be a good thing to avoid.
Moreover, since I've been working with Xen in a client environment I know that being able to set the refresh rate higher than 30 Hz would also be a very welcome thing. The current unaccelerated VESA is actually surprisingly fast, and I the 30 Hz refresh is probably the main cause of people perceiving the client graphics as slow.
Just my 2 cents.
Quoted 61 lines · Samuel Thibault
Hello,
Quoted 3 lines · Markus Armbruster, le Mon 03 Mar 2008 19:03:46 +0100, a écrit :
Quoted 2 lines · Samuel Thibault
Sometimes the backend of PVFB knows that it doesn't need permanent refresh, when the window is minimized for instance (no refresh at
all),
Quoted 1 line
Quoted 1 line
or the administration tools know that the window is thumnailed, and so
a
Quoted 2 lines
Quoted 2 lines
slow refresh rate is fine. Also, some users may want to tune the refresh rate according to the smoothness they would like, balanced
with
Quoted 3 lines
Quoted 1 line
the CPU time that requires.
Can you quantify the CPU time savings?
Something like 6% CPU on my test machine (by just slowing down from 30ms to 1000ms interval).
In my case, I'm using PVFB to expose the stubdomain qemu display. The problem is that every 30ms, qemu wakes up to
memcmp()the whole video memory with a shadow buffer so as to track changes. If it knew that the window is minimized or reduced, it could stop or increase that polling interval. With SDL and vnc, it can, but when going through PVFB that information is lost.Quoted 1 line
Are you sure they're worth the extra complexity?
At least watching a simple integer in XenStore is not very complex.
Note that this may not be a requirement, just the backend telling the frontend what he'd prefer to see. If it's difficult for the frontend to change the rate, then it can just ignore it, and the user won't be so happy, that's all.
Quoted 2 lines
Are you sure the ability to control the rate is required? Why isn't it sufficient to be able to switch updates off?
Being able to choose the smoothness of the interface is really a good user experience. To my feeling, the current 30ms default rate of qemu (7% CPU) is not so smooth (people don't use 30Hz monitors, to they? ;). I usually prefer spending e.g. 14% CPU to get a 10ms rate, but of course I don't want that CPU time to be used when the viewer is off screen. Other people won't feel that need and can save CPU% by slowing it down.
Also, in other cases, you just need to have a snapshot of the VMs, so a 1s rate (or even 10s) makes sense.
Quoted 1 line
Another option is to send a suitable message through the ring.
Yes, but then it's hard for management tools (e.g. a gui that manages VMs) to tune it, while a xenstore value is pretty easy to tinker with.
Quoted 3 lines
The pvops PVFB uses
fb_defio. I think we can change the refresh period there by changing xenfb_defio.delay, but that doesn't exactly look like something the API wants us to do.Then that frontend may just ignore the rate. It's much less of a concern, since that frontend doesn't use an active polling loop, and thus consumes no CPU if nothing happens in the guest.
Quoted 7 lines
Samuel
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 10 lines · Samuel Thibault
Hello,
Quoted 7 lines · Markus Armbruster, le Mon 03 Mar 2008 19:03:46 +0100, a écrit :
Quoted 6 lines · Samuel Thibault
Sometimes the backend of PVFB knows that it doesn't need permanent refresh, when the window is minimized for instance (no refresh at all), or the administration tools know that the window is thumnailed, and so a slow refresh rate is fine. Also, some users may want to tune the refresh rate according to the smoothness they would like, balanced with the CPU time that requires.
I'm not sure I understand how this is supposed to work. Commonly, my display is somewhere else, and all the backend knows of it is a VNC connection. It has no idea what I do with my VNC viewer window. Can you explain?
Quoted 8 lines
Quoted 1 line
Can you quantify the CPU time savings?
Something like 6% CPU on my test machine (by just slowing down from 30ms to 1000ms interval).
In my case, I'm using PVFB to expose the stubdomain qemu display. The problem is that every 30ms, qemu wakes up to
memcmp()the whole video memory with a shadow buffer so as to track changes. If it knew that the
Wait a second! You're talking about *your* frontend here, aren't you?
Maintaining a shadow copy in the frontend (which requires compare and copy) to minimize copying in the backend sounds pretty self-defeating to me. Why is this a good idea?
Why not refrain from sending update messages and have the backend simply redisplay everything? tools/ioemu/hw/xenfb.c doesn't implement that mode, but it shouldn't be hard. And then you could control the refresh rate solely in the backend, without having to communicate with the frontend.
Quoted 4 lines
window is minimized or reduced, it could stop or increase that polling interval. With SDL and vnc, it can, but when going through PVFB that information is lost.
Quoted 8 lines
Quoted 1 line
Are you sure they're worth the extra complexity?
At least watching a simple integer in XenStore is not very complex.
Note that this may not be a requirement, just the backend telling the frontend what he'd prefer to see. If it's difficult for the frontend to change the rate, then it can just ignore it, and the user won't be so happy, that's all.
I'm concerned that we're papering over performance problems instead of solving them.
Quoted 10 lines
Quoted 2 lines
Are you sure the ability to control the rate is required? Why isn't it sufficient to be able to switch updates off?
Being able to choose the smoothness of the interface is really a good user experience. To my feeling, the current 30ms default rate of qemu (7% CPU) is not so smooth (people don't use 30Hz monitors, to they? ;). I usually prefer spending e.g. 14% CPU to get a 10ms rate, but of course I don't want that CPU time to be used when the viewer is off screen. Other people won't feel that need and can save CPU% by slowing it down.
Quoted 7 lines
Also, in other cases, you just need to have a snapshot of the VMs, so a 1s rate (or even 10s) makes sense.
Quoted 1 line
Another option is to send a suitable message through the ring.
Yes, but then it's hard for management tools (e.g. a gui that manages VMs) to tune it, while a xenstore value is pretty easy to tinker with.
Depends on who does the tinkering. If its the backend, then nothing is easier than sending a message through the ring.
On the other hand, if this is just a hack to make a particular frontend less inefficient, then using XenStore at least keeps it out of the PVFB protocol.
Quoted 9 lines
Quoted 3 lines
The pvops PVFB uses
fb_defio. I think we can change the refresh period there by changing xenfb_defio.delay, but that doesn't exactly look like something the API wants us to do.Then that frontend may just ignore the rate. It's much less of a concern, since that frontend doesn't use an active polling loop, and thus consumes no CPU if nothing happens in the guest.
Samuel
Quoted 10 lines · Markus Armbruster, le Tue 04 Mar 2008 15:32:57 +0100, a écrit :
Quoted 8 lines · Samuel Thibault
Quoted 7 lines · Markus Armbruster, le Mon 03 Mar 2008 19:03:46 +0100, a écrit :
Quoted 6 lines · Samuel Thibault
Sometimes the backend of PVFB knows that it doesn't need permanent refresh, when the window is minimized for instance (no refresh at all), or the administration tools know that the window is thumnailed, and so a slow refresh rate is fine. Also, some users may want to tune the refresh rate according to the smoothness they would like, balanced with the CPU time that requires.
Quoted 3 lines
I'm not sure I understand how this is supposed to work. Commonly, my display is somewhere else, and all the backend knows of it is a VNC connection
Ok.
Quoted 1 line
It has no idea what I do with my VNC viewer window.
There is already a heuristic in that case, see the backoff: label in vnc.c.
Quoted 9 lines
Quoted 8 lines
Quoted 1 line
Can you quantify the CPU time savings?
Something like 6% CPU on my test machine (by just slowing down from 30ms to 1000ms interval).
In my case, I'm using PVFB to expose the stubdomain qemu display. The problem is that every 30ms, qemu wakes up to
memcmp()the whole video memory with a shadow buffer so as to track changes. If it knew that the
Quoted 5 lines
Wait a second! You're talking about *your* frontend here, aren't you?
Maintaining a shadow copy in the frontend (which requires compare and copy) to minimize copying in the backend sounds pretty self-defeating to me. Why is this a good idea?
Because in my case the domain is HVM, and I don't want to trap the writes to the video RAM since that's awfully slow.
Quoted 2 lines
Why not refrain from sending update messages and have the backend simply redisplay everything?
Because as explained above, I can't avoid a shadow copy.
Quoted 11 lines
Quoted 8 lines
Quoted 1 line
Are you sure they're worth the extra complexity?
At least watching a simple integer in XenStore is not very complex.
Note that this may not be a requirement, just the backend telling the frontend what he'd prefer to see. If it's difficult for the frontend to change the rate, then it can just ignore it, and the user won't be so happy, that's all.
I'm concerned that we're papering over performance problems instead of solving them.
Mmm, I'm afraid my english couldn't understand that sentence.
Quoted 9 lines
Quoted 2 lines
Yes, but then it's hard for management tools (e.g. a gui that manages VMs) to tune it, while a xenstore value is pretty easy to tinker with.
Depends on who does the tinkering. If its the backend, then nothing is easier than sending a message through the ring.
On the other hand, if this is just a hack to make a particular frontend less inefficient, then using XenStore at least keeps it out of the PVFB protocol.
But the backend still needs to notify the frontend when it should switch modes. Another way to go would be to only add to the PVFB protocol some "expose on/off" events, and let the front-end decide of the rate to adopt.
Samuel
Quoted 4 lines · Samuel Thibault, le Tue 04 Mar 2008 14:49:52 +0000, a écrit :
Quoted 3 lines · Markus Armbruster, le Tue 04 Mar 2008 15:32:57 +0100, a écrit :
Depends on who does the tinkering. If its the backend, then nothing is easier than sending a message through the ring.
Quoted 8 lines
Quoted 3 lines
On the other hand, if this is just a hack to make a particular frontend less inefficient, then using XenStore at least keeps it out of the PVFB protocol.
But the backend still needs to notify the frontend when it should switch modes. Another way to go would be to only add to the PVFB protocol some "expose on/off" events, and let the front-end decide of the rate to adopt.
Mmm, that said, the backend remains the most close for the user to select the refresh rate.
Samuel
Quoted 37 lines · Samuel Thibault
Quoted 10 lines · Markus Armbruster, le Tue 04 Mar 2008 15:32:57 +0100, a écrit :
Quoted 8 lines · Samuel Thibault
Quoted 7 lines · Markus Armbruster, le Mon 03 Mar 2008 19:03:46 +0100, a écrit :
Quoted 6 lines · Samuel Thibault
Sometimes the backend of PVFB knows that it doesn't need permanent refresh, when the window is minimized for instance (no refresh at all), or the administration tools know that the window is thumnailed, and so a slow refresh rate is fine. Also, some users may want to tune the refresh rate according to the smoothness they would like, balanced with the CPU time that requires.
Quoted 3 lines
I'm not sure I understand how this is supposed to work. Commonly, my display is somewhere else, and all the backend knows of it is a VNC connection
Ok.
Quoted 1 line
It has no idea what I do with my VNC viewer window.
There is already a heuristic in that case, see the backoff: label in
vnc.c.Quoted 9 lines
Quoted 8 lines
Quoted 1 line
Can you quantify the CPU time savings?
Something like 6% CPU on my test machine (by just slowing down from 30ms to 1000ms interval).
In my case, I'm using PVFB to expose the stubdomain qemu display. The problem is that every 30ms, qemu wakes up to
memcmp()the whole video memory with a shadow buffer so as to track changes. If it knew that theQuoted 5 lines
Wait a second! You're talking about *your* frontend here, aren't you?
Maintaining a shadow copy in the frontend (which requires compare and copy) to minimize copying in the backend sounds pretty self-defeating to me. Why is this a good idea?
Quoted 7 lines
Because in my case the domain is HVM, and I don't want to trap the writes to the video RAM since that's awfully slow.
Quoted 2 lines
Why not refrain from sending update messages and have the backend simply redisplay everything?
Because as explained above, I can't avoid a shadow copy.
I imagine (perhaps naively):
* The domU writes to a framebuffer provided by the frontend.
* The framebuffer (not a copy of it) can be shared with the backend, which only reads.
* If the frontend can track changes efficiently, it sends update messages to the backend, which can use them to only redisplay changed areas.
Else the backend needs to assume the worst and periodically redisplay everything. It is free to maintain a shadow copy to track changes and minimize redisplay, if that turns out to be faster.
What's wrong with that?
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 1 line
Are you sure they're worth the extra complexity?
At least watching a simple integer in XenStore is not very complex.
Note that this may not be a requirement, just the backend telling the frontend what he'd prefer to see. If it's difficult for the frontend to change the rate, then it can just ignore it, and the user won't be so happy, that's all.
Quoted 4 lines
Quoted 2 lines
I'm concerned that we're papering over performance problems instead of solving them.
Mmm, I'm afraid my english couldn't understand that sentence.
Sorry about that, let me try again. I'm concerned that we're working around serious performance problems instead of solving them properly.
[...]
Quoted 18 lines · Markus Armbruster, le Tue 04 Mar 2008 16:48:20 +0100, a écrit :
Quoted 17 lines · Samuel Thibault
Quoted 9 lines · Markus Armbruster, le Tue 04 Mar 2008 15:32:57 +0100, a écrit :
Quoted 3 lines
In my case, I'm using PVFB to expose the stubdomain qemu display. The problem is that every 30ms, qemu wakes up to
memcmp()the whole video memory with a shadow buffer so as to track changes. If it knew that theWait a second! You're talking about *your* frontend here, aren't you?
Maintaining a shadow copy in the frontend (which requires compare and copy) to minimize copying in the backend sounds pretty self-defeating to me. Why is this a good idea?
Because in my case the domain is HVM, and I don't want to trap the writes to the video RAM since that's awfully slow.
Quoted 2 lines
Why not refrain from sending update messages and have the backend simply redisplay everything?
Quoted 8 lines
Quoted 1 line
Because as explained above, I can't avoid a shadow copy.
I imagine (perhaps naively):
* The domU writes to a framebuffer provided by the frontend.
* The framebuffer (not a copy of it) can be shared with the backend, which only reads.
Well, that's not always the case, when the guest is in text mode for instance, the PV shared buffer is converted from the guest text buffer.
Quoted 9 lines
* If the frontend can track changes efficiently, it sends update messages to the backend, which can use them to only redisplay changed areas.
Else the backend needs to assume the worst and periodically redisplay everything. It is free to maintain a shadow copy to track changes and minimize redisplay, if that turns out to be faster.
What's wrong with that?
Well, that was actually my next target :)
(but for that we badly need the resize/redepth support).
However, that doesn't solve something that still bugs me, which is that the VGA emulation layer wakes up every 30ms to just notice that the width/height/depth registers didn't change etc. even if the actual window is not shown.
Samuel
Quoted 23 lines · Samuel Thibault
Quoted 22 lines · Markus Armbruster, le Tue 04 Mar 2008 16:48:20 +0100, a écrit :
Quoted 11 lines · Samuel Thibault
Quoted 9 lines · Markus Armbruster, le Tue 04 Mar 2008 15:32:57 +0100, a écrit :
Quoted 3 lines
In my case, I'm using PVFB to expose the stubdomain qemu display. The problem is that every 30ms, qemu wakes up to
memcmp()the whole video memory with a shadow buffer so as to track changes. If it knew that theWait a second! You're talking about *your* frontend here, aren't you?
Maintaining a shadow copy in the frontend (which requires compare and copy) to minimize copying in the backend sounds pretty self-defeating to me. Why is this a good idea?
Quoted 7 lines
Because in my case the domain is HVM, and I don't want to trap the writes to the video RAM since that's awfully slow.
Quoted 2 lines
Why not refrain from sending update messages and have the backend simply redisplay everything?
Because as explained above, I can't avoid a shadow copy.
I imagine (perhaps naively):
Quoted 7 lines
Quoted 4 lines
* The domU writes to a framebuffer provided by the frontend.
* The framebuffer (not a copy of it) can be shared with the backend, which only reads.
Well, that's not always the case, when the guest is in text mode for instance, the PV shared buffer is converted from the guest text buffer.
Optimize for the common case. Which I figure is a 32 bpp framebuffer.
Anyway, compare and copy for some legacy 80x25 text mode shouldn't eat that much CPU.
Quoted 4 lines
Quoted 4 lines
* If the frontend can track changes efficiently, it sends update messages to the backend, which can use them to only redisplay changed areas.
Quoted 8 lines
Quoted 5 lines
Else the backend needs to assume the worst and periodically redisplay everything. It is free to maintain a shadow copy to track changes and minimize redisplay, if that turns out to be faster.
What's wrong with that?
Well, that was actually my next target :)
(but for that we badly need the resize/redepth support).
We'll see another iteration of the patch soon, I hope.
Quoted 6 lines
However, that doesn't solve something that still bugs me, which is that the VGA emulation layer wakes up every 30ms to just notice that the width/height/depth registers didn't change etc. even if the actual window is not shown.
Samuel
Quoted 11 lines · Markus Armbruster, le Tue 04 Mar 2008 18:06:26 +0100, a écrit :
Quoted 8 lines · Samuel Thibault
Quoted 4 lines · Markus Armbruster, le Tue 04 Mar 2008 16:48:20 +0100, a écrit :
* The domU writes to a framebuffer provided by the frontend.
* The framebuffer (not a copy of it) can be shared with the backend, which only reads.
Well, that's not always the case, when the guest is in text mode for instance, the PV shared buffer is converted from the guest text buffer.
Optimize for the common case. Which I figure is a 32 bpp framebuffer.
Cirrus VGA is 24bpp max :)
Quoted 2 lines
Anyway, compare and copy for some legacy 80x25 text mode shouldn't eat that much CPU.
Yes.
By my "that's not always the case", I actually expressed the need for the offset feature.
Samuel
Quoted 8 lines · Samuel Thibault
Quoted 7 lines · Markus Armbruster, le Tue 04 Mar 2008 18:06:26 +0100, a écrit :
Quoted 6 lines · Samuel Thibault
Quoted 4 lines · Markus Armbruster, le Tue 04 Mar 2008 16:48:20 +0100, a écrit :
* The domU writes to a framebuffer provided by the frontend.
* The framebuffer (not a copy of it) can be shared with the backend, which only reads.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Well, that's not always the case, when the guest is in text mode for instance, the PV shared buffer is converted from the guest text buffer.
Optimize for the common case. Which I figure is a 32 bpp framebuffer.
Cirrus VGA is 24bpp max :)
I read that as a sign that you're abusing the PVFB stuff for something it wasn't meant to do: emulating some craptastic piece of vintage junk :)
Quoted 9 lines
Quoted 2 lines
Anyway, compare and copy for some legacy 80x25 text mode shouldn't eat that much CPU.
Yes.
By my "that's not always the case", I actually expressed the need for the offset feature.
Samuel
Let's await the next round of the dynamic mode patch, then see how an offset could fit in there.
Quoted 13 lines · Markus Armbruster, le Wed 05 Mar 2008 09:03:51 +0100, a écrit :
Quoted 11 lines · Samuel Thibault
Quoted 10 lines · Markus Armbruster, le Tue 04 Mar 2008 18:06:26 +0100, a écrit :
Quoted 8 lines · Samuel Thibault
Quoted 4 lines · Markus Armbruster, le Tue 04 Mar 2008 16:48:20 +0100, a écrit :
* The domU writes to a framebuffer provided by the frontend.
* The framebuffer (not a copy of it) can be shared with the backend, which only reads.
Well, that's not always the case, when the guest is in text mode for instance, the PV shared buffer is converted from the guest text buffer.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Optimize for the common case. Which I figure is a 32 bpp framebuffer.
Cirrus VGA is 24bpp max :)
I read that as a sign that you're abusing the PVFB stuff for something it wasn't meant to do: emulating some craptastic piece of vintage junk :)
Yep, ask the qemu developper who chose that model.
Samuel
Hello,
Getting back to that old issue.
Quoted 11 lines · Samuel Thibault, le Tue 04 Mar 2008 16:12:20 +0000, a écrit :
Quoted 3 lines
* If the frontend can track changes efficiently, it sends update messages to the backend, which can use them to only redisplay changed areas.
Well, that was actually my next target :)
(but for that we badly need the resize/redepth support).However, that doesn't solve something that still bugs me, which is that the VGA emulation layer wakes up every 30ms to just notice that the width/height/depth registers didn't change etc. even if the actual window is not shown.
What could be done is to make the backend set request-update to 0 when the window is minimized, which makes the frontend understand that there is temporarily no need to send updates any more, and set it back to 1 when the window is restored. Would that be OK?
Samuel
Quoted 15 lines · Samuel Thibault, le Thu 01 May 2008 18:55:36 +0100, a écrit :
Getting back to that old issue.
Quoted 11 lines · Samuel Thibault, le Tue 04 Mar 2008 16:12:20 +0000, a écrit :
Quoted 3 lines
* If the frontend can track changes efficiently, it sends update messages to the backend, which can use them to only redisplay changed areas.
Well, that was actually my next target :)
(but for that we badly need the resize/redepth support).However, that doesn't solve something that still bugs me, which is that the VGA emulation layer wakes up every 30ms to just notice that the width/height/depth registers didn't change etc. even if the actual window is not shown.
Quoted 4 lines
What could be done is to make the backend set request-update to 0 when the window is minimized, which makes the frontend understand that there is temporarily no need to send updates any more, and set it back to 1 when the window is restored. Would that be OK?
Here is how it would be implemented:
ioemu: transmit idleness information to avoid useless polls
extras/mini-os/fbfront.c +16 -3
@@ -243,6 +243,8 @@ struct fbfront_dev {char *backend;int request_update; +struct xenbus_event *volatile events; +int width;int height;int depth;
@@ -377,6 +379,8 @@ done:xenbus_unwatch_path (XBT_NIL , path);snprintf (path,sizeof (path),"%s/request-update" , dev->backend); + dev->events =NULL ; +xenbus_watch_path_token (XBT_NIL , path, path, &dev->events); dev->request_update =xenbus_read_integer (path); err =xenbus_printf (XBT_NIL , nodename,"state" ,"%u" ,4 );/* connected */
@@ -407,12 +411,20 @@ static void fbfront_out_event(struct fbfnotify_remote_via_evtchn (dev->evtchn); } +int fbfront_update_requested (struct fbfront_dev *dev) +{ +struct xenbus_event *event; +while ((event = dev->events)) { + dev->events = event->next; + dev->request_update =xenbus_read_integer (event->path); +xfree (event); + } +return dev->request_update; +} +void fbfront_update (struct fbfront_dev *dev,int x,int y,int width,int height) {struct xenfb_update update; - -if (dev->request_update <=0 ) -return ;if (x <0 ) { width += x;
@@ -461,6 +473,7 @@ void shutdown_fbfront(struct fbfront_devprintk ("close fb: backend at %s\n" ,dev->backend); +xenbus_unwatch_path_token (XBT_NIL , path, path);snprintf (path,sizeof (path),"%s/state" , dev->backend); err =xenbus_printf (XBT_NIL , nodename,"state" ,"%u" ,5 );/* closing */ xenbus_wait_for_value (path,"5" );
extras/mini-os/include/fbfront.h +1 -0
@@ -36,6 +36,7 @@ int fbfront_open(struct fbfront_dev *devint fbfront_open (struct fbfront_dev *dev);#endif +int fbfront_update_requested (struct fbfront_dev *dev);void fbfront_update (struct fbfront_dev *dev,int x,int y,int width,int height);void fbfront_resize (struct fbfront_dev *dev,int width,int height,int stride,int depth,int offset);
tools/ioemu/hw/xenfb.c +30 -1
@@ -59,6 +59,7 @@ struct xenfb {int offset;/* offset of the framebuffer */ int abs_pointer_wanted;/* Whether guest supports absolute pointer */ int button_state;/* Last seen pointer button state */ +int requested_update;/* Did we request update */ char protocol[64 ];/* frontend protocol */ };
@@ -706,7 +707,8 @@ static int xenfb_read_frontend_fb_configif (xenfb_xs_scanf1 (xenfb->xsh, xenfb->fb.otherend,"protocol" ,"%63s" , xenfb->protocol) <0 ) xenfb->protocol[0 ] ='\0' ; -xenfb_xs_printf (xenfb->xsh, xenfb->fb.nodename,"request-update" ,"1" ); +xenfb_xs_printf (xenfb->xsh, xenfb->fb.nodename,"request-update" , xenfb->ds->idle ?"0" :"1" ); + xenfb->requested_update = !xenfb->ds->idle;/* TODO check for permitted ranges */ fb_page = xenfb->fb.page;
@@ -1189,6 +1191,17 @@ static void xenfb_update(void *opaque)static void xenfb_update (void *opaque) {struct xenfb *xenfb = opaque; +if (xenfb->ds->idle) { +if (xenfb->requested_update) { +xenfb_xs_printf (xenfb->xsh, xenfb->fb.nodename,"request-update" ,"0" ); + xenfb->requested_update =0 ; + } + }else { +if (!xenfb->requested_update) { +xenfb_xs_printf (xenfb->xsh, xenfb->fb.nodename,"request-update" ,"1" ); + xenfb->requested_update =1 ; + } + } }/* QEMU display state changed, so refresh the framebuffer copy */
@@ -1318,7 +1331,22 @@ static void xenfb_pv_setdata(DisplayStatstatic void xenfb_pv_refresh (DisplayState *ds) { +struct fbfront_dev *fb_dev = ds->opaque; +vga_hw_update (); + +if (!fb_dev) +return ; + +if (fbfront_update_requested (fb_dev)) { +/* Back to default interval */ + ds->gui_timer_interval =0 ; + ds->idle =0 ; + }else { +/* Sleeping interval */ + ds->gui_timer_interval =500 ; + ds->idle =1 ; + } }static void xenfb_kbd_handler (void *opaque)
@@ -1447,6 +1475,7 @@ int xenfb_pv_display_init(DisplayState * ds->dpy_colourdepth = xenfb_pv_colourdepth; ds->dpy_setdata = xenfb_pv_setdata; ds->dpy_refresh = xenfb_pv_refresh; + ds->opaque =NULL ;return 0 ; }
tools/ioemu/sdl.c +2 -0
@@ -696,9 +696,11 @@ static void sdl_refresh(DisplayState *dsif (ev->active.gain) {/* Back to default interval */ ds->gui_timer_interval =0 ; + ds->idle =0 ; }else {/* Sleeping interval */ ds->gui_timer_interval =500 ; + ds->idle =1 ; } }break ;
tools/ioemu/vl.c +2 -0
@@ -4467,6 +4467,8 @@ void dumb_display_init(DisplayState *ds) ds->dpy_resize = dumb_resize; ds->dpy_colourdepth =NULL ; ds->dpy_refresh = dumb_refresh; + ds->gui_timer_interval =500 ; + ds->idle =1 ; }/***********************************************************/
tools/ioemu/vl.h +1 -0
@@ -939,6 +939,7 @@ struct DisplayState {void *opaque;uint32_t *palette;uint64_t gui_timer_interval; +int idle;int shared_buf;
tools/ioemu/vnc.c +27 -20
77 lines not on this page · raw message
Quoted 21 lines · Samuel Thibault
Quoted 15 lines · Samuel Thibault, le Thu 01 May 2008 18:55:36 +0100, a écrit :
Getting back to that old issue.
Quoted 11 lines · Samuel Thibault, le Tue 04 Mar 2008 16:12:20 +0000, a écrit :
Quoted 3 lines
* If the frontend can track changes efficiently, it sends update messages to the backend, which can use them to only redisplay changed areas.
Well, that was actually my next target :)
(but for that we badly need the resize/redepth support).However, that doesn't solve something that still bugs me, which is that the VGA emulation layer wakes up every 30ms to just notice that the width/height/depth registers didn't change etc. even if the actual window is not shown.
Quoted 4 lines
What could be done is to make the backend set request-update to 0 when the window is minimized, which makes the frontend understand that there is temporarily no need to send updates any more, and set it back to 1 when the window is restored. Would that be OK?
Quoted 6 lines
Here is how it would be implemented:
ioemu: transmit idleness information to avoid useless polls
Signed-off-by Samuel Thibault <[email protected]>
Any particular reason for going through xenstore instead of the event rings?
If I read your patch correctly, xenfb_read_frontend_fb_config() sets request-update in xenstore depending on xenfb->ds->idle, during startup. The only place that changes it is xenfb_update(), which is #ifdef CONFIG_STUBDOM.
What if ds->idle is true when xenfb_read_frontend_fb_config() runs during startup of the ordinary (!CONFIG_STUBDOM) backend? Can this happen? If not, why?
Other than that, the change seems to affect only Mini-OS and CONFIG_STUBDOM, which are both outside the area of my expertise (and frankly, interest).
Quoted 2 lines · Markus Armbruster, le Mon 05 May 2008 10:26:14 +0200, a écrit :
Any particular reason for going through xenstore instead of the event rings?
Just because it exists.
Quoted 4 lines
If I read your patch correctly,
xenfb_read_frontend_fb_config()sets request-update in xenstore depending onxenfb->ds->idle, during startup. The only place that changes it isxenfb_update(), which is #ifdefCONFIG_STUBDOM.
Err, no, it is not #ifdef CONFIG_STUBDOM.
Quoted 3 lines
What if
ds->idleis true whenxenfb_read_frontend_fb_config()runs during startup of the ordinary (!CONFIG_STUBDOM) backend? Can this happen?
Yes it can, when running a vnc server for instance. And when later on a client connects, on next iteration of xenfb_update() the frontend will be notified.
Quoted 3 lines
Other than that, the change seems to affect only Mini-OS and
CONFIG_STUBDOM, which are both outside the area of my expertise (and frankly, interest).
Well, that could be used in the linux frontend to disable the timer too. That may interest e.g. laptop users.
Samuel
Quoted 5 lines · Samuel Thibault
Quoted 2 lines · Markus Armbruster, le Mon 05 May 2008 10:26:14 +0200, a écrit :
Any particular reason for going through xenstore instead of the event rings?
Just because it exists.
Sufficient reason for climbing mountains, if you're so inclined, but is it sane guidance for software development?
So far, PVFB uses xenstore *only* for device initialization and shutdown. For normal operations, we communicate through the event rings. Therefore, there's just one place dealing with events related to device initialization and shutdown (in the fb frontend:xenfb_backend_changed()), and just one place dealing with all other events (fb frontend: xenfb_event_handler()).
I fear mixing in more communication channels without a technical need just adds complexity for no real gain.
Quoted 6 lines
Quoted 4 lines
If I read your patch correctly,
xenfb_read_frontend_fb_config()sets request-update in xenstore depending onxenfb->ds->idle, during startup. The only place that changes it isxenfb_update(), which is #ifdefCONFIG_STUBDOM.Err, no, it is not #ifdef
CONFIG_STUBDOM.
Oops, you're right. You'll have to update its comment, by the way.
Quoted 8 lines
Quoted 3 lines
What if
ds->idleis true whenxenfb_read_frontend_fb_config()runs during startup of the ordinary (!CONFIG_STUBDOM) backend? Can this happen?Yes it can, when running a vnc server for instance. And when later on a client connects, on next iteration of
xenfb_update()the frontend will be notified.
Quoted 8 lines
Quoted 3 lines
Other than that, the change seems to affect only Mini-OS and
CONFIG_STUBDOM, which are both outside the area of my expertise (and frankly, interest).Well, that could be used in the linux frontend to disable the timer too. That may interest e.g. laptop users.
Samuel
The frontend should not send any events unless something's drawing on the display. And when something's drawing on the display, the guest, and therefore the laptop, is already burning processor cycles, and whether disabling sending updates saves any battery power is not obvious. Of course, if you can demonstrate it does...
Anyway, I'm not opposed to the feature.
Quoted 9 lines · Markus Armbruster, le Mon 05 May 2008 11:58:53 +0200, a écrit :
Quoted 6 lines
Quoted 3 lines
Other than that, the change seems to affect only Mini-OS and
CONFIG_STUBDOM, which are both outside the area of my expertise (and frankly, interest).Well, that could be used in the linux frontend to disable the timer too. That may interest e.g. laptop users.
The frontend should not send any events unless something's drawing on the display.
Agreed.
Quoted 2 lines
And when something's drawing on the display, the guest, and therefore the laptop, is already burning processor cycles,
Agreed.
Quoted 2 lines
and whether disabling sending updates saves any battery power is not obvious.
Disabling _sending_ updates does not, yes.
Quoted 1 line
Of course, if you can demonstrate it does...
Disabling _having to care_ whether some updates should be sent _do_ save battery. Now, contrary to what I thought, it happens that linux' xenfb is not using a periodic timer but a triggered timer, so it does not in that case indeed.
Samuel
Hello,
Something like this then?
ioemu: transmit idleness information to avoid useless polls
extras/mini-os/fbfront.c +36 -0
@@ -249,11 +249,41 @@ struct fbfront_dev {int stride;int mem_length;int offset; + +int status; };void fbfront_handler (evtchn_port_t port,struct pt_regs *regs,void *data) { +struct fbfront_dev *dev = data; +struct xenfb_page *page = dev->page; +uint32_t prod, cons; +int i; +wake_up (&fbfront_queue); + prod = page->in_prod; + +if (prod == page->in_cons) +return ; + +rmb ();/* ensure we see ring contents up to prod */ + +for (i =0 , cons = page->in_cons; cons != prod; i++, cons++) { +union xenfb_in_event *event = &XENFB_IN_RING_REF (page, cons); +switch (event->type) { +case XENFB_TYPE_BACKEND_STATUS : + dev->status = event->status.status; +printk ("got status %d\n" , dev->status); +break ; +default : +/* ignore */ +break ; + } + } +mb ();/* ensure we got ring contents */ + page->in_cons = cons; + +notify_remote_via_evtchn (dev->evtchn); }struct fbfront_dev *init_fbfront (char *nodename,unsigned long *mfns,int width,int height,int depth,int stride,int n)
@@ -292,6 +322,7 @@ struct fbfront_dev *init_fbfront(char *n dev->stride = s->line_length = stride; dev->mem_length = s->mem_length = n *PAGE_SIZE ; dev->offset =0 ; + dev->status =XENFB_BACKEND_STATUS_ACTIVE ;const int max_pd =sizeof (s->pd) /sizeof (s->pd[0 ]);unsigned long mapped =0 ;
@@ -405,6 +436,11 @@ static void fbfront_out_event(struct fbfwmb ();/* ensure ring contents visible */ page->out_prod = prod +1 ;notify_remote_via_evtchn (dev->evtchn); +} + +int fbfront_status (struct fbfront_dev *dev) +{ +return dev->status; }void fbfront_update (struct fbfront_dev *dev,int x,int y,int width,int height)
extras/mini-os/include/fbfront.h +1 -0
@@ -36,6 +36,7 @@ int fbfront_open(struct fbfront_dev *devint fbfront_open (struct fbfront_dev *dev);#endif +int fbfront_status (struct fbfront_dev *dev);void fbfront_update (struct fbfront_dev *dev,int x,int y,int width,int height);void fbfront_resize (struct fbfront_dev *dev,int width,int height,int stride,int depth,int offset);
tools/ioemu/hw/xenfb.c +64 -1
105 lines not on this page · raw message
tools/ioemu/sdl.c +2 -0
@@ -696,9 +696,11 @@ static void sdl_refresh(DisplayState *dsif (ev->active.gain) {/* Back to default interval */ ds->gui_timer_interval =0 ; + ds->idle =0 ; }else {/* Sleeping interval */ ds->gui_timer_interval =500 ; + ds->idle =1 ; } }break ;
tools/ioemu/vl.c +2 -0
@@ -4467,6 +4467,8 @@ void dumb_display_init(DisplayState *ds) ds->dpy_resize = dumb_resize; ds->dpy_colourdepth =NULL ; ds->dpy_refresh = dumb_refresh; + ds->gui_timer_interval =500 ; + ds->idle =1 ; }/***********************************************************/
tools/ioemu/vl.h +1 -0
@@ -939,6 +939,7 @@ struct DisplayState {void *opaque;uint32_t *palette;uint64_t gui_timer_interval; +int idle;int shared_buf;
tools/ioemu/vnc.c +27 -20
77 lines not on this page · raw message
xen/include/public/io/fbif.h +17 -1
@@ -80,14 +80,30 @@ union xenfb_out_event/* * Frontends should ignore unknown in events. -* No in events currently defined. */ + +/* +* Backend idleness report +* Backend sends it when the output window is somehow non visible +* (minimized, no client, etc.) +*/ +#define XENFB_TYPE_BACKEND_STATUS 1 + +#define XENFB_BACKEND_STATUS_IDLE 0 +#define XENFB_BACKEND_STATUS_ACTIVE 1 + +struct xenfb_backend_status +{ +uint8_t type;/* XENFB_TYPE_BACKEND_STATUS */ +uint8_t status;/* XENFB_BACKEND_STATUS_* */ +};#define XENFB_IN_EVENT_SIZE 40union xenfb_in_event {uint8_t type; +struct xenfb_backend_status status;char pad[XENFB_IN_EVENT_SIZE ]; };
Quoted 3 lines · Samuel Thibault
Hello,
Something like this then?
Yes. Comments inline.
extras/mini-os/fbfront.c struct fbfront_dev { · line 253
Quoted 13 lines
ioemu: transmit idleness information to avoid useless polls
Signed-off-by Samuel Thibault <[email protected]>diff -r
32342f2b5742extras/mini-os/fbfront.cextras/mini-os/fbfront.c +2
-0@@ -249,11 +249,41 @@ struct fbfront_dev {int stride;int mem_length;int offset; + +int status;
Suggest a more descriptive name, or, if you can't think of any, a descriptive comment.
Oh, see comments on fbif.h below.
Quoted 8 lines
extras/mini-os/fbfront.c +4
-0};void fbfront_handler (evtchn_port_t port,struct pt_regs *regs,void *data) { +struct fbfront_dev *dev = data; +struct xenfb_page *page = dev->page; +uint32_t prod, cons; +int i;
extras/mini-os/fbfront.c struct fbfront_dev { · line 271
Quoted 10 lines
extras/mini-os/fbfront.c +9
-0+wake_up (&fbfront_queue); + prod = page->in_prod; + +if (prod == page->in_cons) +return ; + +rmb ();/* ensure we see ring contents up to prod */ + +for (i =0 , cons = page->in_cons; cons != prod; i++, cons++) {
Purpose of i ?
extras/mini-os/fbfront.c struct fbfront_dev { · line 279
Quoted 8 lines
extras/mini-os/fbfront.c +8
-0+union xenfb_in_event *event = &XENFB_IN_RING_REF (page, cons); +switch (event->type) { +case XENFB_TYPE_BACKEND_STATUS : + dev->status = event->status.status; +printk ("got status %d\n" , dev->status); +break ; +default : +/* ignore */
Suggest /* ignore unknown events */
Quoted 45 lines
extras/mini-os/fbfront.c +13
-0+break ; + } + } +mb ();/* ensure we got ring contents */ + page->in_cons = cons; + +notify_remote_via_evtchn (dev->evtchn); }struct fbfront_dev *init_fbfront (char *nodename,unsigned long *mfns,int width,int height,int depth,int stride,int n)@@ -292,6 +322,7 @@ struct fbfront_dev *init_fbfront(char *n dev->stride = s->line_length = stride; dev->mem_length = s->mem_length = n *PAGE_SIZE ; dev->offset =0 ; + dev->status =XENFB_BACKEND_STATUS_ACTIVE ;const int max_pd =sizeof (s->pd) /sizeof (s->pd[0 ]);unsigned long mapped =0 ;@@ -405,6 +436,11 @@ static void fbfront_out_event(struct fbfwmb ();/* ensure ring contents visible */ page->out_prod = prod +1 ;notify_remote_via_evtchn (dev->evtchn); +} + +int fbfront_status (struct fbfront_dev *dev) +{ +return dev->status; }void fbfront_update (struct fbfront_dev *dev,int x,int y,int width,int height)diff -r
32342f2b5742extras/mini-os/include/fbfront.hextras/mini-os/include/fbfront.h +1
-0@@ -36,6 +36,7 @@ int fbfront_open(struct fbfront_dev *devint fbfront_open (struct fbfront_dev *dev);#endif +int fbfront_status (struct fbfront_dev *dev);void fbfront_update (struct fbfront_dev *dev,int x,int y,int width,int height);void fbfront_resize (struct fbfront_dev *dev,int width,int height,int stride,int depth,int offset);diff -r
32342f2b5742tools/ioemu/hw/xenfb.c
tools/ioemu/hw/xenfb.c struct xenfb { · line 62
Quoted 4 lines
tools/ioemu/hw/xenfb.c +1
-0@@ -59,6 +59,7 @@ struct xenfb {int offset;/* offset of the framebuffer */ int abs_pointer_wanted;/* Whether guest supports absolute pointer */ int button_state;/* Last seen pointer button state */ +int notified_active;/* Did we request update */
Tab, please, if it's not too much trouble. Mixing tabs and spaces for indentation makes diffs unnecessarily hard to read.
Quoted 20 lines
tools/ioemu/hw/xenfb.c +13
-0char protocol[64 ];/* frontend protocol */ };@@ -536,6 +537,40 @@ static void xenfb_on_fb_event(struct xenxc_evtchn_notify (xenfb->evt_xch, xenfb->fb.port); } +static int xenfb_queue_full (struct xenfb *xenfb) +{ +struct xenfb_page *page = xenfb->fb.page; +uint32_t cons, prod; + + prod = page->in_prod; + cons = page->in_cons; +return prod - cons ==XENFB_IN_RING_LEN ; +} + +static void xenfb_send_event (struct xenfb *xenfb,union xenfb_in_event *event) +{ +uint32_t prod;
tools/ioemu/hw/xenfb.c static void xenfb_on_fb_event(struct xen · line 562
Quoted 10 lines
tools/ioemu/hw/xenfb.c +10
-0+struct xenfb_page *page = xenfb->fb.page; + + prod = page->in_prod; +/* caller ensures !xenfb_queue_full() */ +xen_mb ();/* ensure ring space available */ +XENFB_IN_RING_REF (page, prod) = *event; +xen_wmb ();/* ensure ring contents visible */ + page->in_prod = prod +1 ; + +xc_evtchn_notify (xenfb->evt_xch, xenfb->fb.port);
Ditto.
tools/ioemu/hw/xenfb.c static void xenfb_on_fb_event(struct xen · line 567
Quoted 5 lines
tools/ioemu/hw/xenfb.c +5
-0+} + +static void xenfb_send_status (struct xenfb *xenfb,int active) +{ +union xenfb_in_event event;
Please memset(&event, 0, sizeof(event))
Makes backward-compatible evolution of the protocol so much easier, and removes all doubts about leaking potentially sensitive bits.
Quoted 27 lines
tools/ioemu/hw/xenfb.c +9
-1+ event.type =XENFB_TYPE_BACKEND_STATUS ; + event.status.status = active ?XENFB_BACKEND_STATUS_ACTIVE + :XENFB_BACKEND_STATUS_IDLE ; +xenfb_send_event (xenfb, &event); +} +static void xenfb_on_kbd_event (struct xenfb *xenfb) {struct xenkbd_page *page = xenfb->kbd.page;@@ -707,6 +742,7 @@ static int xenfb_read_frontend_fb_config xenfb->protocol) < 0) xenfb->protocol[0 ] ='\0' ;xenfb_xs_printf (xenfb->xsh, xenfb->fb.nodename,"request-update" ,"1" ); + xenfb->notified_active =1 ;/* TODO check for permitted ranges */ fb_page = xenfb->fb.page;@@ -1185,10 +1221,21 @@ static void xenfb_guest_copy(struct xenfdpy_update (xenfb->ds, x, y, w, h); } -/* Periodic update of display, no need for any in our case */ +/* Periodic update of display, just announce idleness to the front end */ static void xenfb_update (void *opaque) {struct xenfb *xenfb = opaque; +if (xenfb->ds->idle) {
tools/ioemu/hw/xenfb.c static void xenfb_guest_copy(struct xenf · line 1238
Quoted 10 lines
tools/ioemu/hw/xenfb.c +10
-0+if (xenfb->notified_active && !xenfb_queue_full (xenfb)) { +xenfb_send_status (xenfb,0 ); + xenfb->notified_active =0 ; + } + }else { +if (!xenfb->notified_active && !xenfb_queue_full (xenfb)) { +xenfb_send_status (xenfb,1 ); + xenfb->notified_active =1 ; + } + }
This breaks if we ever support frontends without feature-update. Worth a comment.
tools/ioemu/hw/xenfb.c static void xenfb_guest_copy(struct xenf · line 1241
Quoted 3 lines
tools/ioemu/hw/xenfb.c +0
-0}/* QEMU display state changed, so refresh the framebuffer copy */
[CONFIG_STUBDOM stuff snipped, I'm too ignorant about that to comment...]
tools/ioemu/sdl.c
Quoted 3 lines
diff -r
32342f2b5742tools/ioemu/sdl.ctools/ioemu/sdl.c +0
-0
[more snippage due to ignorance...]
tools/ioemu/vl.h
Quoted 3 lines
diff -r
32342f2b5742tools/ioemu/vl.htools/ioemu/vl.h +0
-0
[ditto...]
Quoted 1 line
diff -r
32342f2b5742tools/ioemu/vnc.c
[ditto...]
Quoted 15 lines
diff -r
32342f2b5742xen/include/public/io/fbif.hxen/include/public/io/fbif.h +6
-1@@ -80,14 +80,30 @@ union xenfb_out_event/* * Frontends should ignore unknown in events. -* No in events currently defined. */ + +/* +* Backend idleness report +* Backend sends it when the output window is somehow non visible +* (minimized, no client, etc.) +*/
xen/include/public/io/fbif.h union xenfb_out_event · line 99
Quoted 10 lines
xen/include/public/io/fbif.h +10
-0+#define XENFB_TYPE_BACKEND_STATUS 1 + +#define XENFB_BACKEND_STATUS_IDLE 0 +#define XENFB_BACKEND_STATUS_ACTIVE 1 + +struct xenfb_backend_status +{ +uint8_t type;/* XENFB_TYPE_BACKEND_STATUS */ +uint8_t status;/* XENFB_BACKEND_STATUS_* */ +};
I'm not entirely happy with the protocol defined here.
1. Encoding of idleness
If idleness is and will remain boolean, I'd rather encode it the old-fashioned C way as zero / non-zero, because that removes all doubt on how to interpret funny status values.
If you want to reserve funny status values for future extensions of the notion "idleness", then you need to document that here, along with what frontends should do for values they don't know.
2. Names
If the message is intended just for reporting idleness, it should be called something like BACKEND_IDLE instead of STATUS.
If it is meant to be extensible for reporting status other than idleness, the member status isn't named properly. If the member holds just idleness, it should be named is_idle (if yes/no), idleness (if more than two values), or something like that. If idleness is yes/no, you could also encode it as a bit in a status word instead.
Aside: going through the ring requires us to write down the protocol here. You didn't (have to) do that when you went through xenstore. Guess what I like better :)
Quoted 10 lines
xen/include/public/io/fbif.h +1
-0#define XENFB_IN_EVENT_SIZE 40union xenfb_in_event {uint8_t type; +struct xenfb_backend_status status;char pad[XENFB_IN_EVENT_SIZE ]; };
Quoted 7 lines · Markus Armbruster
Quoted 3 lines · Samuel Thibault
Hello,
Something like this then?
Yes. Comments inline.
Also, needs to be re-synced with tip now that the minios "fix thread safety" changeset 17576 is in xen-unstable.
-- Keir
Quoted 3 lines · Markus Armbruster, le Tue 06 May 2008 15:50:08 +0200, a écrit :
Quoted 1 line
+ for (i = 0, cons =
page->in_cons; cons != prod; i++, cons++) {Purpose of i ?
It was needed in the case of kbd, but not here indeed.
Quoted 4 lines
Quoted 1 line
+ int
notified_active; /* Did we request update */Tab, please, if it's not too much trouble. Mixing tabs and spaces for indentation makes diffs unnecessarily hard to read.
I agree and fixed it, the problem is just that xen has various indentation/tab practices, so no default configuration can work :)
Quoted 9 lines
Quoted 9 lines
xen/include/public/io/fbif.h +9
-0+/* +* Backend idleness report +* Backend sends it when the output window is somehow non visible +* (minimized, no client, etc.) +*/ +#define XENFB_TYPE_BACKEND_STATUS 1 + +#define XENFB_BACKEND_STATUS_IDLE 0 +#define XENFB_BACKEND_STATUS_ACTIVE 1
Quoted 8 lines
xen/include/public/io/fbif.h union xenfb_out_event · line 99
Quoted 6 lines
xen/include/public/io/fbif.h +6
-0+ +struct xenfb_backend_status +{ +uint8_t type;/* XENFB_TYPE_BACKEND_STATUS */ +uint8_t status;/* XENFB_BACKEND_STATUS_* */ +};I'm not entirely happy with the protocol defined here.
Right, I'm not sure of what we would ideally want to express. I can see three use cases:
- The output is fully active, we want frequent update notification (that is the assumed permanent state up to now)
- The output is not visible, update notification is useless.
- The output is visible in reduced conditions, for instance a thumbnail in a VMs management tool, update notification don't really need to be sent often. We could have the backend explicitely request updates from the frontend when it wants a new thumbnail (this is needed e.g. in HVM text mode, in which the guest output is not directly mapped through PVFB, so an explicit refresh is needed).
Instead of expressing idleness or "status", maybe we could rather express whether periodic update notifications are wanted or not, and let the backend request an explicit update notification when it feels the need for one (low-frequency thumbnail update). It has the advantage of only talking about the PVFB protocol itself and not something around it (idleness of the actual output). That is also backward compatible in that a frontend which doesn't know these two events will just continue sending periodic update notifications, which is fine for the backend.
Samuel
Quoted 7 lines · Samuel Thibault
Quoted 3 lines · Markus Armbruster, le Tue 06 May 2008 15:50:08 +0200, a écrit :
Quoted 1 line
+ for (i = 0, cons =
page->in_cons; cons != prod; i++, cons++) {Purpose of i ?
It was needed in the case of kbd, but not here indeed.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
+ int
notified_active; /* Did we request update */Tab, please, if it's not too much trouble. Mixing tabs and spaces for indentation makes diffs unnecessarily hard to read.
I agree and fixed it, the problem is just that xen has various indentation/tab practices, so no default configuration can work :)
I know...
Quoted 40 lines
Quoted 9 lines
Quoted 9 lines
xen/include/public/io/fbif.h +9
-0+/* +* Backend idleness report +* Backend sends it when the output window is somehow non visible +* (minimized, no client, etc.) +*/ +#define XENFB_TYPE_BACKEND_STATUS 1 + +#define XENFB_BACKEND_STATUS_IDLE 0 +#define XENFB_BACKEND_STATUS_ACTIVE 1Quoted 8 lines
xen/include/public/io/fbif.h union xenfb_out_event · line 99
Quoted 6 lines
xen/include/public/io/fbif.h +6
-0+ +struct xenfb_backend_status +{ +uint8_t type;/* XENFB_TYPE_BACKEND_STATUS */ +uint8_t status;/* XENFB_BACKEND_STATUS_* */ +};I'm not entirely happy with the protocol defined here.
Right, I'm not sure of what we would ideally want to express. I can see three use cases:
- The output is fully active, we want frequent update notification (that is the assumed permanent state up to now)
- The output is not visible, update notification is useless.
- The output is visible in reduced conditions, for instance a thumbnail in a VMs management tool, update notification don't really need to be sent often. We could have the backend explicitely request updates from the frontend when it wants a new thumbnail (this is needed e.g. in HVM text mode, in which the guest output is not directly mapped through PVFB, so an explicit refresh is needed).Instead of expressing idleness or "status", maybe we could rather express whether periodic update notifications are wanted or not, and let the backend request an explicit update notification when it feels the need for one (low-frequency thumbnail update). It has the advantage of only talking about the PVFB protocol itself and not something around it (idleness of the actual output). That is also backward compatible in that a frontend which doesn't know these two events will just continue sending periodic update notifications, which is fine for the backend.
Quoted 1 line
Samuel
I think that's a better way to define this feature.
Quoted 10 lines · Markus Armbruster, le Tue 06 May 2008 18:50:04 +0200, a écrit :
Quoted 8 lines
Instead of expressing idleness or "status", maybe we could rather express whether periodic update notifications are wanted or not, and let the backend request an explicit update notification when it feels the need for one (low-frequency thumbnail update). It has the advantage of only talking about the PVFB protocol itself and not something around it (idleness of the actual output). That is also backward compatible in that a frontend which doesn't know these two events will just continue sending periodic update notifications, which is fine for the backend.
I think that's a better way to define this feature.
More precisely, we could have an UPDATE_PERIOD event which carries an advice from the backend about how often the frontend should sent update notifications (0 if periodic notification is not useful), and a REQUEST_UPDATE event that requests a one-time update notification? The latter could even contain the requested area? (not sure whether it'd be really useful considering the added complexity, though).
Samuel
Quoted 12 lines · Samuel Thibault
Quoted 10 lines · Markus Armbruster, le Tue 06 May 2008 18:50:04 +0200, a écrit :
Quoted 8 lines
Instead of expressing idleness or "status", maybe we could rather express whether periodic update notifications are wanted or not, and let the backend request an explicit update notification when it feels the need for one (low-frequency thumbnail update). It has the advantage of only talking about the PVFB protocol itself and not something around it (idleness of the actual output). That is also backward compatible in that a frontend which doesn't know these two events will just continue sending periodic update notifications, which is fine for the backend.
I think that's a better way to define this feature.
Quoted 8 lines
More precisely, we could have an
UPDATE_PERIODevent which carries an advice from the backend about how often the frontend should sent update notifications (0 if periodic notification is not useful), and aREQUEST_UPDATEevent that requests a one-time update notification? The latter could even contain the requested area? (not sure whether it'd be really useful considering the added complexity, though).Samuel
I figure your UPDATE_PERIOD advice event is a sensible way to solve your problem. Frontends are free to use the advice as they see fit.
Why do you need REQUEST_UPDATE? Perhaps because your frontend doesn't want to keep the shared framebuffer up-to-date?
Quoted 2 lines · Markus Armbruster, le Wed 07 May 2008 16:43:38 +0200, a écrit :
Why do you need
REQUEST_UPDATE? Perhaps because your frontend doesn't want to keep the shared framebuffer up-to-date?
Yes, because it is expensive.
Samuel
Quoted 7 lines · Samuel Thibault
Quoted 2 lines · Markus Armbruster, le Wed 07 May 2008 16:43:38 +0200, a écrit :
Why do you need
REQUEST_UPDATE? Perhaps because your frontend doesn't want to keep the shared framebuffer up-to-date?Yes, because it is expensive.
Samuel
Strictly speaking, frame buffer update and update notification events are separate things.
The PVFB protocol (tacitly) assumes that the framebuffer shared by the frontend gets updated as the guest draws in it. The update notification event is (designed to be) optional. The backend doesn't actually implement the optionality, it simply bails out when it can't get update notifications.
What you seem to need is *not* a way to control *notifications*, but a way to control *updates*. Because your shared framebuffer isn't really a framebuffer, but some shadow of the real framebuffer. Correct?
This is of course all semantic fine print, but getting that wrong can be very confusing.
So, if I'm guessing right and you need to control updates, then what about this: have an fb in event to advise on updates. It contains a suggested update frequency. Frontends that always keep the framebuffer in sync ignore it. Frontends that don't keep it in sync should immediately update it (and send an update notification for that), and use the update frequency to guide updates until further notice.
One could put the area to be updated into the event, but I can't see practical applications for that.
I believe this is pretty close to what you have in mind. But I could be wrong.
Hello,
Quoted 2 lines · Markus Armbruster, le Thu 08 May 2008 10:25:32 +0200, a écrit :
Strictly speaking, frame buffer update and update notification events are separate things.
Right, let's call the first one "refresh".
Quoted 4 lines
What you seem to need is *not* a way to control *notifications*, but a way to control *updates*. Because your shared framebuffer isn't really a framebuffer, but some shadow of the real framebuffer. Correct?
Yes. Here is an updated patch.
pvfb/ioemu: transmit refresh interval advice from backend to frontend which permits the frontend to avoid useless polls.
extras/mini-os/fbfront.c +55 -0
@@ -255,11 +255,55 @@ struct fbfront_dev {int offset;xenbus_event_queue events; + +#ifdef HAVE_LIBC +int fd; +#endif };void fbfront_handler (evtchn_port_t port,struct pt_regs *regs,void *data) { +#ifdef HAVE_LIBC +struct fbfront_dev *dev = data; +int fd = dev->fd; + + files[fd].read =1 ; +#endif wake_up (&fbfront_queue); +} + +int fbfront_receive (struct fbfront_dev *dev,union xenfb_in_event *buf,int n) +{ +struct xenfb_page *page = dev->page; +uint32_t prod, cons; +int i; + +#ifdef HAVE_LIBC + files[dev->fd].read =0 ; +mb ();/* Make sure to let the handler set read to 1 before we start looking at the ring */ +#endif + + prod = page->in_prod; + +if (prod == page->in_cons) +return 0 ; + +rmb ();/* ensure we see ring contents up to prod */ + +for (i =0 , cons = page->in_cons; i < n && cons != prod; i++, cons++) +memcpy (buf + i, &XENFB_IN_RING_REF (page, cons),sizeof (*buf)); + +mb ();/* ensure we got ring contents */ + page->in_cons = cons; +notify_remote_via_evtchn (dev->evtchn); + +#ifdef HAVE_LIBC +if (cons != prod) +/* still some events to read */ + files[dev->fd].read =1 ; +#endif + +return i; }struct fbfront_dev *init_fbfront (char *nodename,unsigned long *mfns,int width,int height,int depth,int stride,int n)
@@ -482,3 +526,14 @@ void shutdown_fbfront(struct fbfront_devfree (dev->backend);free (dev); } + +#ifdef HAVE_LIBC +int fbfront_open (struct fbfront_dev *dev) +{ + dev->fd =alloc_fd (FTYPE_FB ); +printk ("fb_open(%s) -> %d\n" , dev->nodename, dev->fd); + files[dev->fd].fb.dev = dev; +return dev->fd; +} +#endif +
extras/mini-os/include/fbfront.h +3 -0
@@ -1,4 +1,5 @@#include <xen/io/kbdif.h> +#include <xen/io/fbif.h> #include <wait.h> /* from <linux/input.h> */
@@ -36,6 +37,8 @@ int fbfront_open(struct fbfront_dev *devint fbfront_open (struct fbfront_dev *dev);#endif +int fbfront_receive (struct fbfront_dev *dev,union xenfb_in_event *buf,int n); +extern struct wait_queue_head fbfront_queue;void fbfront_update (struct fbfront_dev *dev,int x,int y,int width,int height);void fbfront_resize (struct fbfront_dev *dev,int width,int height,int stride,int depth,int offset);
extras/mini-os/include/lib.h +4 -0
@@ -141,6 +141,7 @@ enum fd_type {FTYPE_TAP ,FTYPE_BLK ,FTYPE_KBD , + FTYPE_FB, };#define MAX_EVTCHN_PORTS 16
@@ -175,6 +176,9 @@ extern struct file {struct {struct kbdfront_dev *dev; } kbd; +struct { +struct fbfront_dev *dev; + } fb;struct {/* To each xenbus FD is associated a queue of watch events for this * FD. */
extras/mini-os/kernel.c +43 -22
111 lines not on this page · raw message
extras/mini-os/lib/sys.c +20 -0
@@ -249,6 +251,16 @@ int read(int fd, void *buf, size_t nbyte }return ret *sizeof (union xenkbd_in_event ); } +case FTYPE_FB : { +int ret, n; + n = nbytes /sizeof (union xenfb_in_event ); + ret =fbfront_receive (files[fd].fb.dev, buf, n); +if (ret <=0 ) { + errno =EAGAIN ; +return -1 ; + } +return ret *sizeof (union xenfb_in_event ); + }case FTYPE_NONE :case FTYPE_XENBUS :case FTYPE_EVTCHN :
@@ -290,6 +302,7 @@ int write(int fd, const void *buf, size_case FTYPE_EVTCHN :case FTYPE_BLK :case FTYPE_KBD : +case FTYPE_FB :break ; }printk ("write(%d): Bad descriptor\n" , fd);
@@ -348,6 +361,7 @@ int fsync(int fd) {case FTYPE_TAP :case FTYPE_BLK :case FTYPE_KBD : +case FTYPE_FB :break ; }printk ("fsync(%d): Bad descriptor\n" , fd);
@@ -392,6 +406,10 @@ int close(int fd)return 0 ;case FTYPE_KBD :shutdown_kbdfront (files[fd].kbd.dev); + files[fd].type =FTYPE_NONE ; +return 0 ; +case FTYPE_FB : +shutdown_fbfront (files[fd].fb.dev); files[fd].type =FTYPE_NONE ;return 0 ;case FTYPE_NONE :
@@ -485,6 +503,7 @@ int fstat(int fd, struct stat *buf)case FTYPE_TAP :case FTYPE_BLK :case FTYPE_KBD : +case FTYPE_FB :break ; }
@@ -513,6 +532,7 @@ int ftruncate(int fd, off_t length)case FTYPE_TAP :case FTYPE_BLK :case FTYPE_KBD : +case FTYPE_FB :break ; }
@@ -624,6 +644,7 @@ static const char file_types[] = { [FTYPE_TAP] = 'T', [FTYPE_BLK] = 'B', [FTYPE_KBD] = 'K', + [FTYPE_FB] = 'G', };#ifdef LIBC_DEBUG static void dump_set (int nfds,fd_set *readfds,fd_set *writefds,fd_set *exceptfds,struct timeval *timeout)
@@ -732,6 +753,7 @@ static int select_poll(int nfds, fd_setcase FTYPE_TAP :case FTYPE_BLK :case FTYPE_KBD : +case FTYPE_FB :if (FD_ISSET (i, readfds)) {if (files[i].read) n++;
tools/ioemu/hw/xenfb.c +135 -31
299 lines not on this page · raw message
tools/ioemu/sdl.c +2 -0
@@ -696,9 +696,11 @@ static int select_poll(int nfds, fd_setif (ev->active.gain) {/* Back to default interval */ ds->gui_timer_interval =0 ; + ds->idle =0 ; }else {/* Sleeping interval */ ds->gui_timer_interval =500 ; + ds->idle =1 ; } }break ;
tools/ioemu/vl.c +2 -2
@@ -130,8 +130,6 @@#else #define DEFAULT_RAM_SIZE 128#endif -/* in ms */ -#define GUI_REFRESH_INTERVAL 30/* Max number of USB devices that can be specified on the commandline. */ #define MAX_USB_CMDLINE 8
@@ -4467,6 +4465,8 @@ void dumb_display_init(DisplayState *ds) ds->dpy_resize = dumb_resize; ds->dpy_colourdepth =NULL ; ds->dpy_refresh = dumb_refresh; + ds->gui_timer_interval =500 ; + ds->idle =1 ; }/***********************************************************/
tools/ioemu/vl.h +4 -0
@@ -929,6 +929,9 @@ extern struct soundhw soundhw[];#define VGA_RAM_SIZE (8192 * 1024) +/* in ms */ +#define GUI_REFRESH_INTERVAL 30 +struct DisplayState {uint8_t *data;int linesize;
@@ -939,6 +942,7 @@ struct DisplayState {void *opaque;uint32_t *palette;uint64_t gui_timer_interval; +int idle;int shared_buf;
tools/ioemu/vnc.c +27 -20
77 lines not on this page · raw message
xen/include/public/io/fbif.h +14 -2
@@ -79,15 +79,27 @@ union xenfb_out_event/* In events (backend -> frontend) */ /* -* Frontends should ignore unknown in events. -* No in events currently defined. +* Framebuffer refresh period advice +* Backend sends it to advise the frontend the period of refresh it should use, +* i.e how often it should take care to update the FB with its internal state. +* +* If the frontend uses the advice, it should refresh and send an update event +* in response to this event. */ +#define XENFB_TYPE_REFRESH_PERIOD 1 + +struct xenfb_refresh_period +{ +uint8_t type;/* XENFB_TYPE_UPDATE_PERIOD */ +uint32_t period;/* period of refresh, in ms, 0 if no refresh is needed */ +};#define XENFB_IN_EVENT_SIZE 40union xenfb_in_event {uint8_t type; +struct xenfb_refresh_period refresh_period;char pad[XENFB_IN_EVENT_SIZE ]; };
Quoted 6 lines · Samuel Thibault
Hello,
Quoted 2 lines · Markus Armbruster, le Thu 08 May 2008 10:25:32 +0200, a écrit :
Strictly speaking, frame buffer update and update notification events are separate things.
Quoted 8 lines
Right, let's call the first one "refresh".
Quoted 4 lines
What you seem to need is *not* a way to control *notifications*, but a way to control *updates*. Because your shared framebuffer isn't really a framebuffer, but some shadow of the real framebuffer. Correct?
Yes. Here is an updated patch.
Looks like we're down to clarifying comments. See inline.
Quoted 5 lines
pvfb/ioemu: transmit refresh interval advice from backend to frontend which permits the frontend to avoid useless polls.
Signed-off-by Samuel Thibault <[email protected]>
[diff extras/mini-os/... I got nothing useful to say about that...]
Quoted 74 lines
diff -r
b0d7780794ebtools/ioemu/hw/xenfb.ctools/ioemu/hw/xenfb.c +42
-1@@ -59,6 +59,7 @@ struct xenfb {int offset;/* offset of the framebuffer */ int abs_pointer_wanted;/* Whether guest supports absolute pointer */ int button_state;/* Last seen pointer button state */ +int refresh_period;/* The refresh period we have advised */ char protocol[64 ];/* frontend protocol */ };@@ -536,6 +537,41 @@ static void xenfb_on_fb_event(struct xenxc_evtchn_notify (xenfb->evt_xch, xenfb->fb.port); } +static int xenfb_queue_full (struct xenfb *xenfb) +{ +struct xenfb_page *page = xenfb->fb.page; +uint32_t cons, prod; + + prod = page->in_prod; + cons = page->in_cons; +return prod - cons ==XENFB_IN_RING_LEN ; +} + +static void xenfb_send_event (struct xenfb *xenfb,union xenfb_in_event *event) +{ +uint32_t prod; +struct xenfb_page *page = xenfb->fb.page; + + prod = page->in_prod; +/* caller ensures !xenfb_queue_full() */ +xen_mb ();/* ensure ring space available */ +XENFB_IN_RING_REF (page, prod) = *event; +xen_wmb ();/* ensure ring contents visible */ + page->in_prod = prod +1 ; + +xc_evtchn_notify (xenfb->evt_xch, xenfb->fb.port); +} + +static void xenfb_send_refresh_period (struct xenfb *xenfb,int period) +{ +union xenfb_in_event event; + +memset (&event,0 ,sizeof (event)); + event.type =XENFB_TYPE_REFRESH_PERIOD ; + event.refresh_period.period = period; +xenfb_send_event (xenfb, &event); +} +static void xenfb_on_kbd_event (struct xenfb *xenfb) {struct xenkbd_page *page = xenfb->kbd.page;@@ -707,6 +743,7 @@ static int xenfb_read_frontend_fb_config xenfb->protocol) < 0) xenfb->protocol[0 ] ='\0' ;xenfb_xs_printf (xenfb->xsh, xenfb->fb.nodename,"request-update" ,"1" ); + xenfb->refresh_period =-1 ;/* TODO check for permitted ranges */ fb_page = xenfb->fb.page;@@ -1185,10 +1222,28 @@ static void xenfb_guest_copy(struct xenfdpy_update (xenfb->ds, x, y, w, h); } -/* Periodic update of display, no need for any in our case */ +/* Periodic update of display, transmit the refresh interval to the frontend */ static void xenfb_update (void *opaque) {struct xenfb *xenfb = opaque; +int period; + +if (xenfb_queue_full (xenfb)) +return ;
tools/ioemu/hw/xenfb.c static void xenfb_guest_copy(struct xenf · line 1242
Quoted 10 lines
tools/ioemu/hw/xenfb.c +10
-0+ +if (xenfb->ds->idle) + period =0 ; +else { + period = xenfb->ds->gui_timer_interval; +if (!period) + period =GUI_REFRESH_INTERVAL ; + } + +/* Will have to be disabled for frontends without feature-update */
I think I asked you to put this comment here, but is it still correct for current XENFB_TYPE_REFRESH_PERIOD semantics?
tools/ioemu/hw/xenfb.c static void xenfb_guest_copy(struct xenf · line 1249
Quoted 7 lines
tools/ioemu/hw/xenfb.c +4
-0+if (xenfb->refresh_period != period) { +xenfb_send_refresh_period (xenfb, period); + xenfb->refresh_period = period; + } }/* QEMU display state changed, so refresh the framebuffer copy */
[CONFIG_STUBDOM stuff snipped, I'm too ignorant about that to comment...]
Quoted 1 line
diff -r
b0d7780794ebtools/ioemu/sdl.c
[more snippage due to ignorance...]
Quoted 1 line
diff -r
b0d7780794ebtools/ioemu/vl.c
[ditto...]
Quoted 1 line
diff -r
b0d7780794ebtools/ioemu/vl.h
[ditto...]
Quoted 1 line
diff -r
b0d7780794ebtools/ioemu/vnc.c
[ditto...]
Quoted 6 lines
diff -r
b0d7780794ebxen/include/public/io/fbif.hxen/include/public/io/fbif.h +0
-0@@ -79,15 +79,27 @@ union xenfb_out_event/* In events (backend -> frontend) */
xen/include/public/io/fbif.h union xenfb_out_event · line 88
Quoted 10 lines
xen/include/public/io/fbif.h +6
-2/* -* Frontends should ignore unknown in events. -* No in events currently defined. +* Framebuffer refresh period advice +* Backend sends it to advise the frontend the period of refresh it should use, +* i.e how often it should take care to update the FB with its internal state. +* +* If the frontend uses the advice, it should refresh and send an update event +* in response to this event. */
You delete the bit about ignoring unknown events. Oops.
What about this:
/* In events (backend -> frontend) */
/*
* Frontends should ignore unknown in events.
*/
/*
* Framebuffer refresh period advice
* Backend sends it to advise the frontend their preferred period of
* refresh. Frontends that keep the framebuffer constantly up-to-date
* just ignore it. Frontends that use the advice should immediately
* refresh the framebuffer (and send an update notification event if
* those have been requested), then use the update frequency to guide
* their periodical refreshs.
*/
#define XENFB_TYPE_REFRESH_PERIOD 1
Quoted 4 lines
xen/include/public/io/fbif.h +4
-0+#define XENFB_TYPE_REFRESH_PERIOD 1 + +struct xenfb_refresh_period +{
xen/include/public/io/fbif.h union xenfb_out_event · line 102
Quoted 10 lines
xen/include/public/io/fbif.h +4
-0+uint8_t type;/* XENFB_TYPE_UPDATE_PERIOD */ +uint32_t period;/* period of refresh, in ms, 0 if no refresh is needed */ +};#define XENFB_IN_EVENT_SIZE 40union xenfb_in_event {uint8_t type; +struct xenfb_refresh_period refresh_period;
Time unit? Needs a comment! Make sure to explain the special value for "no updates please".
I'd be tempted to use a frequency instead of a period, just because that doesn't require a special value for "no updates". Strictly a matter of taste.
Quoted 3 lines
xen/include/public/io/fbif.h +0
-0char pad[XENFB_IN_EVENT_SIZE ]; };
Quoted 4 lines · Markus Armbruster, le Fri 09 May 2008 10:43:15 +0200, a écrit :
Quoted 1 line
+ /* Will have to be disabled for frontends without feature-update */
I think I asked you to put this comment here, but is it still correct for current
XENFB_TYPE_REFRESH_PERIODsemantics?
Considering the clarification of the semantic, it can be dropped indeed.
Quoted 6 lines
Quoted 4 lines
+ *
+ * If the frontend uses the advice, it should refresh and send an update event
+ * in response to this event.
*/You delete the bit about ignoring unknown events. Oops.
Oops.
Quoted 1 line
What about this:
Ok.
Quoted 8 lines
Quoted 8 lines
xen/include/public/io/fbif.h +7
-0+#define XENFB_TYPE_REFRESH_PERIOD 1 + +struct xenfb_refresh_period +{ +uint8_t type;/* XENFB_TYPE_UPDATE_PERIOD */ +uint32_t period;/* period of refresh, in ms, 0 if no refresh is needed */ +};
Quoted 8 lines
Quoted 6 lines
#define
XENFB_IN_EVENT_SIZE40union
xenfb_in_event{ uint8_t type;+ struct
xenfb_refresh_periodrefresh_period;Time unit?
There is one in the structure above.
Quoted 3 lines
I'd be tempted to use a frequency instead of a period, just because that doesn't require a special value for "no updates". Strictly a matter of taste.
The "problem" of an integer frequency is that it does not permit a period of more than one second, which may become a limit in some odd situations (thousands of VMs waking every second?)
Samuel
Quoted 1 line · Samuel Thibault
Markus Armbruster, le Fri 09 May 2008 10:43:15 +0200, a écrit :
[...]
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
union
xenfb_in_event{ uint8_t type;+ struct
xenfb_refresh_periodrefresh_period;Time unit?
There is one in the structure above.
I was confused.
Quoted 9 lines
Quoted 3 lines
I'd be tempted to use a frequency instead of a period, just because that doesn't require a special value for "no updates". Strictly a matter of taste.
The "problem" of an integer frequency is that it does not permit a period of more than one second, which may become a limit in some odd situations (thousands of VMs waking every second?)
Samuel
Okay. Any convenient encoding for the values you're interested in should do, as long as it's documented clearly.
Updated patch, the only changes are the addition of a XENFB_NO_REFRESH macro and comment fixup (as well as a small fixup for the VNC case).
Samuel
pvfb/ioemu: transmit refresh interval advice from backend to frontend which permits the frontend to avoid useless polls.
extras/mini-os/fbfront.c +55 -0
@@ -255,11 +255,55 @@int offset;xenbus_event_queue events; + +#ifdef HAVE_LIBC +int fd; +#endif };void fbfront_handler (evtchn_port_t port,struct pt_regs *regs,void *data) { +#ifdef HAVE_LIBC +struct fbfront_dev *dev = data; +int fd = dev->fd; + + files[fd].read =1 ; +#endif wake_up (&fbfront_queue); +} + +int fbfront_receive (struct fbfront_dev *dev,union xenfb_in_event *buf,int n) +{ +struct xenfb_page *page = dev->page; +uint32_t prod, cons; +int i; + +#ifdef HAVE_LIBC + files[dev->fd].read =0 ; +mb ();/* Make sure to let the handler set read to 1 before we start looking at the ring */ +#endif + + prod = page->in_prod; + +if (prod == page->in_cons) +return 0 ; + +rmb ();/* ensure we see ring contents up to prod */ + +for (i =0 , cons = page->in_cons; i < n && cons != prod; i++, cons++) +memcpy (buf + i, &XENFB_IN_RING_REF (page, cons),sizeof (*buf)); + +mb ();/* ensure we got ring contents */ + page->in_cons = cons; +notify_remote_via_evtchn (dev->evtchn); + +#ifdef HAVE_LIBC +if (cons != prod) +/* still some events to read */ + files[dev->fd].read =1 ; +#endif + +return i; }struct fbfront_dev *init_fbfront (char *nodename,unsigned long *mfns,int width,int height,int depth,int stride,int n)
@@ -482,3 +526,14 @@free (dev->backend);free (dev); } + +#ifdef HAVE_LIBC +int fbfront_open (struct fbfront_dev *dev) +{ + dev->fd =alloc_fd (FTYPE_FB ); +printk ("fb_open(%s) -> %d\n" , dev->nodename, dev->fd); + files[dev->fd].fb.dev = dev; +return dev->fd; +} +#endif +
extras/mini-os/include/fbfront.h +3 -0
@@ -1,4 +1,5 @@#include <xen/io/kbdif.h> +#include <xen/io/fbif.h> #include <wait.h> /* from <linux/input.h> */
@@ -36,6 +37,8 @@int fbfront_open (struct fbfront_dev *dev);#endif +int fbfront_receive (struct fbfront_dev *dev,union xenfb_in_event *buf,int n); +extern struct wait_queue_head fbfront_queue;void fbfront_update (struct fbfront_dev *dev,int x,int y,int width,int height);void fbfront_resize (struct fbfront_dev *dev,int width,int height,int stride,int depth,int offset);
extras/mini-os/include/lib.h +4 -0
@@ -141,6 +141,7 @@FTYPE_TAP ,FTYPE_BLK ,FTYPE_KBD , + FTYPE_FB, };#define MAX_EVTCHN_PORTS 16
@@ -175,6 +176,9 @@struct {struct kbdfront_dev *dev; } kbd; +struct { +struct fbfront_dev *dev; + } fb;struct {/* To each xenbus FD is associated a queue of watch events for this * FD. */
extras/mini-os/kernel.c +43 -22
111 lines not on this page · raw message
extras/mini-os/lib/sys.c +20 -0
@@ -249,6 +249,16 @@ }return ret *sizeof (union xenkbd_in_event ); } +case FTYPE_FB : { +int ret, n; + n = nbytes /sizeof (union xenfb_in_event ); + ret =fbfront_receive (files[fd].fb.dev, buf, n); +if (ret <=0 ) { + errno =EAGAIN ; +return -1 ; + } +return ret *sizeof (union xenfb_in_event ); + }case FTYPE_NONE :case FTYPE_XENBUS :case FTYPE_EVTCHN :
@@ -290,6 +300,7 @@case FTYPE_EVTCHN :case FTYPE_BLK :case FTYPE_KBD : +case FTYPE_FB :break ; }printk ("write(%d): Bad descriptor\n" , fd);
@@ -348,6 +359,7 @@case FTYPE_TAP :case FTYPE_BLK :case FTYPE_KBD : +case FTYPE_FB :break ; }printk ("fsync(%d): Bad descriptor\n" , fd);
@@ -392,6 +404,10 @@return 0 ;case FTYPE_KBD :shutdown_kbdfront (files[fd].kbd.dev); + files[fd].type =FTYPE_NONE ; +return 0 ; +case FTYPE_FB : +shutdown_fbfront (files[fd].fb.dev); files[fd].type =FTYPE_NONE ;return 0 ;case FTYPE_NONE :
@@ -485,6 +501,7 @@case FTYPE_TAP :case FTYPE_BLK :case FTYPE_KBD : +case FTYPE_FB :break ; }
@@ -513,6 +530,7 @@case FTYPE_TAP :case FTYPE_BLK :case FTYPE_KBD : +case FTYPE_FB :break ; }
@@ -624,6 +642,7 @@ [FTYPE_TAP] = 'T', [FTYPE_BLK] = 'B', [FTYPE_KBD] = 'K', + [FTYPE_FB] = 'G', };#ifdef LIBC_DEBUG static void dump_set (int nfds,fd_set *readfds,fd_set *writefds,fd_set *exceptfds,struct timeval *timeout)
@@ -732,6 +751,7 @@case FTYPE_TAP :case FTYPE_BLK :case FTYPE_KBD : +case FTYPE_FB :if (FD_ISSET (i, readfds)) {if (files[i].read) n++;
tools/ioemu/hw/xenfb.c +136 -31
300 lines not on this page · raw message
tools/ioemu/sdl.c +2 -0
@@ -696,9 +696,11 @@if (ev->active.gain) {/* Back to default interval */ ds->gui_timer_interval =0 ; + ds->idle =0 ; }else {/* Sleeping interval */ ds->gui_timer_interval =500 ; + ds->idle =1 ; } }break ;
tools/ioemu/vl.c +2 -2
@@ -130,8 +130,6 @@#else #define DEFAULT_RAM_SIZE 128#endif -/* in ms */ -#define GUI_REFRESH_INTERVAL 30/* Max number of USB devices that can be specified on the commandline. */ #define MAX_USB_CMDLINE 8
@@ -4467,6 +4465,8 @@ ds->dpy_resize = dumb_resize; ds->dpy_colourdepth =NULL ; ds->dpy_refresh = dumb_refresh; + ds->gui_timer_interval =500 ; + ds->idle =1 ; }/***********************************************************/
tools/ioemu/vl.h +4 -0
@@ -929,6 +929,9 @@#define VGA_RAM_SIZE (8192 * 1024) +/* in ms */ +#define GUI_REFRESH_INTERVAL 30 +struct DisplayState {uint8_t *data;int linesize;
@@ -939,6 +942,7 @@void *opaque;uint32_t *palette;uint64_t gui_timer_interval; +int idle;int shared_buf;
tools/ioemu/vnc.c +27 -20
77 lines not on this page · raw message
xen/include/public/io/fbif.h +20 -1
@@ -80,14 +80,33 @@/* * Frontends should ignore unknown in events. -* No in events currently defined. */ + +/* +* Framebuffer refresh period advice +* Backend sends it to advise the frontend their preferred period of +* refresh. Frontends that keep the framebuffer constantly up-to-date +* just ignore it. Frontends that use the advice should immediately +* refresh the framebuffer (and send an update notification event if +* those have been requested), then use the update frequency to guide +* their periodical refreshs. +*/ +#define XENFB_TYPE_REFRESH_PERIOD 1 +#define XENFB_NO_REFRESH 0 + +struct xenfb_refresh_period +{ +uint8_t type;/* XENFB_TYPE_UPDATE_PERIOD */ +uint32_t period;/* period of refresh, in ms, +* XENFB_NO_REFRESH if no refresh is needed */ +};#define XENFB_IN_EVENT_SIZE 40union xenfb_in_event {uint8_t type; +struct xenfb_refresh_period refresh_period;char pad[XENFB_IN_EVENT_SIZE ]; };
Quoted 3 lines · Samuel Thibault
Hello,
Markus Armbruster, le Mon 03 Mar 2008 19:03:46 +0100, a écrit :
[...]
Quoted 9 lines
Quoted 2 lines
Are you sure the ability to control the rate is required? Why isn't it sufficient to be able to switch updates off?
Being able to choose the smoothness of the interface is really a good user experience. To my feeling, the current 30ms default rate of qemu (7% CPU) is not so smooth (people don't use 30Hz monitors, to they? ;). I usually prefer spending e.g. 14% CPU to get a 10ms rate, but of course I don't want that CPU time to be used when the viewer is off screen. Other people won't feel that need and can save CPU% by slowing it down.
If PVFB is not smooth enough, why not use some real remote graphics tech? Plain X11 (with NX for high latency connections) and VNC come to mind. PVFB is neat to run graphical installers and as an emergency console, but I wouldn't want to use it for a desktop.
[...]
Quoted 16 lines · Markus Armbruster, le Wed 05 Mar 2008 12:19:40 +0100, a écrit :
Quoted 3 lines · Samuel Thibault
Hello,
Markus Armbruster, le Mon 03 Mar 2008 19:03:46 +0100, a écrit :
[...]
Quoted 9 lines
Quoted 2 lines
Are you sure the ability to control the rate is required? Why isn't it sufficient to be able to switch updates off?
Being able to choose the smoothness of the interface is really a good user experience. To my feeling, the current 30ms default rate of qemu (7% CPU) is not so smooth (people don't use 30Hz monitors, to they? ;). I usually prefer spending e.g. 14% CPU to get a 10ms rate, but of course I don't want that CPU time to be used when the viewer is off screen. Other people won't feel that need and can save CPU% by slowing it down.
Quoted 4 lines
If PVFB is not smooth enough, why not use some real remote graphics tech? Plain X11 (with NX for high latency connections) and VNC come to mind. PVFB is neat to run graphical installers and as an emergency console, but I wouldn't want to use it for a desktop.
PVFB is by design just faster than X11 or VNC. The problem here is not in PVFB, but in the VGA engine, which needs information (minization) that X11 or VNC provide, but PVFB doesn't.
Samuel