Skip to contentSkip to conversation

video: hyperv: hyperv_fb: Support deferred IO for Hyper-V frame buffer driver

PATCH Superseded Wei Hu 4 participants 6 messages Sep 13, 2019 – Oct 2, 2019

Subsystems (3)

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Wei Hu

author maintainer
#0 lore raw

PATCH v5 1/1 video: hyperv: hyperv_fb: Support deferred IO for Hyper-V frame buffer driver

Without deferred IO support, hyperv_fb driver informs the host to refresh the entire guest frame buffer at fixed rate, e.g. at 20Hz, no matter there is screen update or not. This patch supports deferred IO for screens in graphics mode and also enables the frame buffer on-demand refresh. The highest refresh rate is still set at 20Hz.

Currently Hyper-V only takes a physical address from guest as the starting address of frame buffer. This implies the guest must allocate contiguous physical memory for frame buffer. In addition, Hyper-V Gen 2 VMs only accept address from MMIO region as frame buffer address. Due to these limitations on Hyper-V host, we keep a shadow copy of frame buffer in the guest. This means one more copy of the dirty rectangle inside guest when doing the on-demand refresh. This can be optimized in the future with help from host. For now the host performance gain from deferred IO outweighs the shadow copy impact in the guest.

---
v2: Incorporated review comments from Michael Kelley
- Increased dirty rectangle by one row in deferred IO case when sending to Hyper-V.
- Corrected the dirty rectangle size in the text mode.
- Added more comments.
- Other minor code cleanups.

v3: Incorporated more review comments
- Removed a few unnecessary variable tests

v4: Incorporated test and review feedback from Dexuan Cui
- Not disable interrupt while acquiring docopy_lock in hvfb_update_work(). This avoids significant bootup delay in large vCPU count VMs.

v5: Completely remove the unnecessary docopy_lock after discussing with Dexuan Cui.

 drivers/video/fbdev/Kconfig     |   1 +
 drivers/video/fbdev/hyperv_fb.c | 208 +++++++++++++++++++++++++++++---
 2 files changed, 189 insertions(+), 20 deletions(-)
drivers/video/fbdev/Kconfig +1 -0
index 1b2f5f31fb6f..e781f89a1824 100644
@@ -2241,6 +2241,7 @@ config FB_HYPERV
 	select FB_CFB_FILLRECT
 	select FB_CFB_COPYAREA
 	select FB_CFB_IMAGEBLIT
+	select FB_DEFERRED_IO
 	help
 	  This framebuffer driver supports Microsoft Hyper-V Synthetic Video.
 
drivers/video/fbdev/hyperv_fb.c +188 -20

356 lines not on this page · raw message

Signature · 1 line
2.20.1
maintainer Reviewed-by on v5 1/1
#1 lore raw
Quoted 31 lines

From: Wei Hu <[email protected]>
Sent: Thursday, September 12, 2019 11:03 PM

Without deferred IO support, hyperv_fb driver informs the host to refresh the entire guest frame buffer at fixed rate, e.g. at 20Hz, no matter there is screen update or not. This patch supports deferred IO for screens in graphics mode and also enables the frame buffer on-demand refresh. The highest refresh rate is still set at 20Hz.

Currently Hyper-V only takes a physical address from guest as the starting address of frame buffer. This implies the guest must allocate contiguous physical memory for frame buffer. In addition, Hyper-V Gen 2 VMs only accept address from MMIO region as frame buffer address. Due to these limitations on Hyper-V host, we keep a shadow copy of frame buffer in the guest. This means one more copy of the dirty rectangle inside guest when doing the on-demand refresh. This can be optimized in the future with help from host. For now the host performance gain from deferred IO outweighs the shadow copy impact in the guest.

---
v2: Incorporated review comments from Michael Kelley
- Increased dirty rectangle by one row in deferred IO case when sending to Hyper-V.
- Corrected the dirty rectangle size in the text mode.
- Added more comments.
- Other minor code cleanups.

v3: Incorporated more review comments
- Removed a few unnecessary variable tests

Quoted 7 lines

v4: Incorporated test and review feedback from Dexuan Cui
- Not disable interrupt while acquiring docopy_lock in hvfb_update_work(). This avoids significant bootup delay in large vCPU count VMs.

v5: Completely remove the unnecessary docopy_lock after discussing with Dexuan Cui.

Thanks! Looks good to me.

Reviewed-by on v5 1/1
#3 lore raw
In reply to Wei Hu

From: Wei Hu <[email protected]> Sent: Thursday, September 12, 2019 11:03 PM

Quoted 29 lines

Without deferred IO support, hyperv_fb driver informs the host to refresh the entire guest frame buffer at fixed rate, e.g. at 20Hz, no matter there is screen update or not. This patch supports deferred IO for screens in graphics mode and also enables the frame buffer on-demand refresh. The highest refresh rate is still set at 20Hz.

Currently Hyper-V only takes a physical address from guest as the starting address of frame buffer. This implies the guest must allocate contiguous physical memory for frame buffer. In addition, Hyper-V Gen 2 VMs only accept address from MMIO region as frame buffer address. Due to these limitations on Hyper-V host, we keep a shadow copy of frame buffer in the guest. This means one more copy of the dirty rectangle inside guest when doing the on-demand refresh. This can be optimized in the future with help from host. For now the host performance gain from deferred IO outweighs the shadow copy impact in the guest.

---
v2: Incorporated review comments from Michael Kelley
- Increased dirty rectangle by one row in deferred IO case when sending to Hyper-V.
- Corrected the dirty rectangle size in the text mode.
- Added more comments.
- Other minor code cleanups.

v3: Incorporated more review comments
- Removed a few unnecessary variable tests

Quoted 8 lines

v4: Incorporated test and review feedback from Dexuan Cui
- Not disable interrupt while acquiring docopy_lock in hvfb_update_work(). This avoids significant bootup delay in large vCPU count VMs.

v5: Completely remove the unnecessary docopy_lock after discussing with Dexuan Cui.

maintainer
#2 lore raw
In reply to Dexuan Cui

Thanks,
-- Dexuan

Quoted 51 lines

-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Dexuan Cui
Sent: Thursday, September 12, 2019 11:38 PM
To: Wei Hu <[email protected]>; Michael Kelley <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Stephen Hemminger <[email protected]>; Haiyang Zhang <[email protected]>; KY Srinivasan <[email protected]>
Subject: RE: [PATCH v5] video: hyperv: hyperv_fb: Support deferred IO for Hyper-V frame buffer driver

Quoted 36 lines

From: Wei Hu <[email protected]>
Sent: Thursday, September 12, 2019 11:03 PM

Without deferred IO support, hyperv_fb driver informs the host to refresh the entire guest frame buffer at fixed rate, e.g. at 20Hz, no matter there is screen update or not. This patch supports deferred IO for screens in graphics mode and also enables the frame buffer on-demand refresh. The highest refresh rate is still set at 20Hz.

Currently Hyper-V only takes a physical address from guest as the starting address of frame buffer. This implies the guest must allocate contiguous physical memory for frame buffer. In addition, Hyper-V Gen 2 VMs only accept address from MMIO region as frame buffer address. Due to these limitations on Hyper-V host, we keep a shadow copy of frame buffer in the guest. This means one more copy of the dirty rectangle inside guest when doing the on-demand refresh. This can be optimized in the future with help from host. For now the host performance gain from deferred IO outweighs the shadow copy impact in the guest.

---
v2: Incorporated review comments from Michael Kelley
- Increased dirty rectangle by one row in deferred IO case when sending to Hyper-V.
- Corrected the dirty rectangle size in the text mode.
- Added more comments.
- Other minor code cleanups.

v3: Incorporated more review comments
- Removed a few unnecessary variable tests

v4: Incorporated test and review feedback from Dexuan Cui
- Not disable interrupt while acquiring docopy_lock in hvfb_update_work(). This avoids significant bootup delay in large vCPU count VMs.

Quoted 6 lines
Quoted 2 lines

v5: Completely remove the unnecessary docopy_lock after discussing with Dexuan Cui.

Thanks! Looks good to me.

Hi Wei,
It turns out we need to make a further fix. :-)

The patch forgets to take par->update into consideration.

When the VM Connection window is closed (or minimized?), the host sends a message to the guest, and the guest sets par->update to false in synthvid_recv_sub().

If par->update is false, the guest doesn't need to call synthvid_update().

Thanks,
-- Dexuan

#4 lore raw
In reply to Wei Hu
Quoted 16 lines · Wei Hu

Without deferred IO support, hyperv_fb driver informs the host to refresh the entire guest frame buffer at fixed rate, e.g. at 20Hz, no matter there is screen update or not. This patch supports deferred IO for screens in graphics mode and also enables the frame buffer on-demand refresh. The highest refresh rate is still set at 20Hz.

Currently Hyper-V only takes a physical address from guest as the starting address of frame buffer. This implies the guest must allocate contiguous physical memory for frame buffer. In addition, Hyper-V Gen 2 VMs only accept address from MMIO region as frame buffer address. Due to these limitations on Hyper-V host, we keep a shadow copy of frame buffer in the guest. This means one more copy of the dirty rectangle inside guest when doing the on-demand refresh. This can be optimized in the future with help from host. For now the host performance gain from deferred IO outweighs the shadow copy impact in the guest.

Quoted 1 line

What tree is this based on? I can't get it to apply.

--
Thanks,
Sasha

maintainer
#5 lore raw
Quoted 21 lines

From: Sasha Levin <[email protected]>
Sent: Tuesday, October 1, 2019 11:45 AM
To: Wei Hu <[email protected]>

Quoted 16 lines · Wei Hu

Without deferred IO support, hyperv_fb driver informs the host to refresh the entire guest frame buffer at fixed rate, e.g. at 20Hz, no matter there is screen update or not. This patch supports deferred IO for screens in graphics mode and also enables the frame buffer on-demand refresh. The highest refresh rate is still set at 20Hz.

Currently Hyper-V only takes a physical address from guest as the starting address of frame buffer. This implies the guest must allocate contiguous physical memory for frame buffer. In addition, Hyper-V Gen 2 VMs only accept address from MMIO region as frame buffer address. Due to these limitations on Hyper-V host, we keep a shadow copy of frame buffer in the guest. This means one more copy of the dirty rectangle inside guest when doing the on-demand refresh. This can be optimized in the future with help from host. For now the host performance gain from deferred IO outweighs the shadow copy impact in the guest.

Quoted 6 lines
Quoted 1 line

What tree is this based on? I can't get it to apply.

Thanks,
Sasha

Please use Wei's v6 patch, which can apply on today's hyperv/linux.git/s hyperv-next branch.

Thanks,
-- Dexuan