drm/virtgpu: Make vblank event dependent on the external sync
Subsystems (4)
Thomas Zimmermann
maintainerPATCH v4 1/1 drm/virtgpu: Make vblank event dependent on the external sync
For each plane, store the buffer object's sync status in the state of the plane's respective CRTC. During the CRTC's atomic flush, ignore the vblank timer if any of the CRTC's plane's buffer object is synchronized to an external source. Instead send the vblank event immediately. Avoids corner cases where a vblank event happens too late for the next frame to be page flipped in time.
Exporters of GEM objects sometimes interfere with the vblank timer; resulting in framerate drops. Hence detect this case and handle it as outlined above.
The vblank timer is still active and fires in regular intervals according to the guest display refresh. This rate limits clients that only wait for the next vblank to occur, such as fbcon. These clients would otherwise produce a very high number of frames per second.
v4:
- only handle imported GEM buffer objects (Dmitri, Vivek)
- fix test for plane visibility (Vivek)
- always enable vblank timer to make waiting clients happy v3:
- disable vblank unconditionally
- compute status on each commit
v2:
- enable/disable vblank timer according to buffer setup
---
This patch was previously called "drm/virtgpu: Make vblank event dependent on the host resource". Earlier versions where meant for testing, rather than being merged. See [1] for a discussion of when the fixed problem happens.
[1] https://lore.kernel.org/dri-devel/[email protected]/
--- drivers/gpu/drm/virtio/virtgpu_display.c | 67 ++++++++++++++++++++++-- drivers/gpu/drm/virtio/virtgpu_drv.h | 15 ++++++ drivers/gpu/drm/virtio/virtgpu_plane.c | 28 +++++++++- 3 files changed, 104 insertions(+), 6 deletions(-)
drivers/gpu/drm/virtio/virtgpu_display.c +63 -4
@@ -49,14 +49,71 @@#define drm_connector_to_virtio_gpu_output (x) \ container_of(x, struct virtio_gpu_output, conn) +static void virtio_gpu_crtc_state_destroy (struct virtio_gpu_crtc_state *vgcrtc_state) +{ +__drm_atomic_helper_crtc_destroy_state (&vgcrtc_state->base); + +kfree (vgcrtc_state); +} + +static bool virtio_gpu_crtc_state_send_event_on_flush (struct virtio_gpu_crtc_state *vgcrtc_state) +{ +struct drm_crtc_state *crtc_state = &vgcrtc_state->base; + +/* +* The CRTC's output is sync'ed if at least one plane's output +* is sync'ed to an external source. Send out vlbank event in +* atomic_flush instead of vblank timeout. +*/ +return vgcrtc_state->plane_synced_to_ext & crtc_state->plane_mask; +} + +static void virtio_gpu_crtc_reset (struct drm_crtc *crtc) +{ +struct virtio_gpu_crtc_state *vgcrtc_state; + +if (crtc->state) +virtio_gpu_crtc_state_destroy (to_virtio_gpu_crtc_state (crtc->state)); + + vgcrtc_state =kzalloc (sizeof (*vgcrtc_state),GFP_KERNEL ); +if (vgcrtc_state) +__drm_atomic_helper_crtc_reset (crtc, &vgcrtc_state->base); +else +__drm_atomic_helper_crtc_reset (crtc,NULL ); +} + +static struct drm_crtc_state *virtio_gpu_crtc_atomic_duplicate_state (struct drm_crtc *crtc) +{ +struct drm_device *dev = crtc->dev; +struct drm_crtc_state *crtc_state = crtc->state; +struct virtio_gpu_crtc_state *new_vgcrtc_state; + +if (drm_WARN_ON (dev, !crtc_state)) +return NULL ; + + new_vgcrtc_state =kzalloc (sizeof (*new_vgcrtc_state),GFP_KERNEL ); +if (!new_vgcrtc_state) +return NULL ; + +__drm_atomic_helper_crtc_duplicate_state (crtc, &new_vgcrtc_state->base); + +return &new_vgcrtc_state->base; +} + +static void virtio_gpu_crtc_atomic_destroy_state (struct drm_crtc *crtc, +struct drm_crtc_state *crtc_state) +{ +virtio_gpu_crtc_state_destroy (to_virtio_gpu_crtc_state (crtc_state)); +} +static const struct drm_crtc_funcs virtio_gpu_crtc_funcs = { .set_config = drm_atomic_helper_set_config, .destroy = drm_crtc_cleanup, .page_flip = drm_atomic_helper_page_flip, - .reset = drm_atomic_helper_crtc_reset, - .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state, - .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state, + .reset = virtio_gpu_crtc_reset, + .atomic_duplicate_state = virtio_gpu_crtc_atomic_duplicate_state, + .atomic_destroy_state = virtio_gpu_crtc_atomic_destroy_state,DRM_CRTC_VBLANK_TIMER_FUNCS , };
@@ -129,7 +186,9 @@ static void virtio_gpu_crtc_atomic_flush(struct drm_crtc *crtc, {struct drm_device *dev = crtc->dev;struct drm_crtc_state *crtc_state =drm_atomic_get_new_crtc_state (state, crtc); +struct virtio_gpu_crtc_state *vgcrtc_state =to_virtio_gpu_crtc_state (crtc_state);struct virtio_gpu_output *output =drm_crtc_to_virtio_gpu_output (crtc); +bool send_event_on_flush =virtio_gpu_crtc_state_send_event_on_flush (vgcrtc_state);struct drm_pending_vblank_event *event;/*
@@ -147,7 +206,7 @@ static void virtio_gpu_crtc_atomic_flush(struct drm_crtc *crtc, crtc_state->event =NULL ;if (event) { -if (drm_crtc_vblank_get (crtc) ==0 ) +if (!send_event_on_flush &&drm_crtc_vblank_get (crtc) ==0 )drm_crtc_arm_vblank_event (crtc, event);else drm_crtc_send_vblank_event (crtc, event);
drivers/gpu/drm/virtio/virtgpu_drv.h +15 -0
@@ -195,6 +195,21 @@ struct virtio_gpu_framebuffer {#define to_virtio_gpu_framebuffer (x) \ container_of(x, struct virtio_gpu_framebuffer, base) +struct virtio_gpu_crtc_state { +struct drm_crtc_state base; + +/* +* Set from each plane's atomic check and depends on the plane's GEM +* buffer objects. The bit shows is the corresponding plane is already +* synchronized to an external source. Used by the CRTC for vblank +* handling. Only valid during mode setting. +*/ +u32 plane_synced_to_ext; +}; + +#define to_virtio_gpu_crtc_state (x) \ + container_of(x, struct virtio_gpu_crtc_state, base) +struct virtio_gpu_plane_state {struct drm_plane_state base;struct virtio_gpu_fence *fence;
drivers/gpu/drm/virtio/virtgpu_plane.c +26 -2
@@ -27,6 +27,7 @@#include <drm/drm_damage_helper.h> #include <drm/drm_fourcc.h> #include <drm/drm_gem_atomic_helper.h> +#include <drm/drm_gem_framebuffer_helper.h> #include <linux/virtio_dma_buf.h> #include <drm/drm_managed.h> #include <drm/drm_panic.h>
@@ -104,7 +105,8 @@ static int virtio_gpu_plane_atomic_check(struct drm_plane *plane, plane);bool is_cursor = plane->type ==DRM_PLANE_TYPE_CURSOR ;struct drm_crtc_state *crtc_state; -int ret; +struct virtio_gpu_crtc_state *vgcrtc_state; +int ret, i;if (!new_plane_state->fb ||WARN_ON (!new_plane_state->crtc))return 0 ;
@@ -126,7 +128,29 @@ static int virtio_gpu_plane_atomic_check(struct drm_plane *plane,DRM_PLANE_NO_SCALING ,DRM_PLANE_NO_SCALING , is_cursor, true); -return ret; +if (ret) +return ret; +else if (!new_plane_state->visible) +return 0 ; + + vgcrtc_state =to_virtio_gpu_crtc_state (crtc_state); + vgcrtc_state->plane_synced_to_ext &= ~drm_plane_mask (plane); + +for (i =0 ; i < new_plane_state->fb->format->num_planes; ++i) { +struct drm_gem_object *obj =drm_gem_fb_get_obj (new_plane_state->fb, i); + +/* +* Exporters of GEM buffer objects sometimes interfere with the +* vblank timer. Mark the plane as externally synchronized if we +* find an imported GEM buffer object. +*/ +if (drm_gem_is_imported (obj)) { + vgcrtc_state->plane_synced_to_ext |=drm_plane_mask (plane); +break ;/* only need to find one */ + } + } + +return 0 ; }/* For drm panic */
Signature · 1 line
2.51.1
Quoted 34 lines · Thomas Zimmermann
For each plane, store the buffer object's sync status in the state of the plane's respective CRTC. During the CRTC's atomic flush, ignore the vblank timer if any of the CRTC's plane's buffer object is synchronized to an external source. Instead send the vblank event immediately. Avoids corner cases where a vblank event happens too late for the next frame to be page flipped in time.
Exporters of GEM objects sometimes interfere with the vblank timer; resulting in framerate drops. Hence detect this case and handle it as outlined above.
The vblank timer is still active and fires in regular intervals according to the guest display refresh. This rate limits clients that only wait for the next vblank to occur, such as fbcon. These clients would otherwise produce a very high number of frames per second.
v4:
- only handle imported GEM buffer objects (Dmitri, Vivek)
- fix test for plane visibility (Vivek)
- always enable vblank timer to make waiting clients happy v3:
- disable vblank unconditionally
- compute status on each commit
v2:
- enable/disable vblank timer according to buffer setupSigned-off-by Thomas Zimmermann <[email protected]>---
This patch was previously called "drm/virtgpu: Make vblank event dependent on the host resource". Earlier versions where meant for testing, rather than being merged. See [1] for a discussion of when the fixed problem happens.
Quoted 7 lines
[1] https://lore.kernel.org/dri-devel/20251016145230.79270-1-
[email protected]/--- drivers/gpu/drm/virtio/virtgpu_display.c | 67 ++++++++++++++++++++++-- drivers/gpu/drm/virtio/virtgpu_drv.h | 15 ++++++ drivers/gpu/drm/virtio/virtgpu_plane.c | 28 +++++++++- 3 files changed, 104 insertions(+), 6 deletions(-)
No problems spotted. I'd only extended comment in the code explicitly stating that drm_gem_is_imported() is the workaround, might edit it on applying. Will wait for Vivek's feedback. Thanks.
Signature · 2 lines
Best regards, Dmitry
Hi Thomas, Dmitry,
Quoted 46 lines
Subject: Re: [PATCH v4] drm/virtgpu: Make vblank event dependent on the external sync
Quoted 34 lines · Thomas Zimmermann
For each plane, store the buffer object's sync status in the state of the plane's respective CRTC. During the CRTC's atomic flush, ignore the vblank timer if any of the CRTC's plane's buffer object is synchronized to an external source. Instead send the vblank event immediately. Avoids corner cases where a vblank event happens too late for the next frame to be page flipped in time.
Exporters of GEM objects sometimes interfere with the vblank timer; resulting in framerate drops. Hence detect this case and handle it as outlined above.
The vblank timer is still active and fires in regular intervals according to the guest display refresh. This rate limits clients that only wait for the next vblank to occur, such as fbcon. These clients would otherwise produce a very high number of frames per second.
v4:
- only handle imported GEM buffer objects (Dmitri, Vivek)
- fix test for plane visibility (Vivek)
- always enable vblank timer to make waiting clients happy v3:
- disable vblank unconditionally
- compute status on each commit
v2:
- enable/disable vblank timer according to buffer setupSigned-off-by Thomas Zimmermann <[email protected]>---
This patch was previously called "drm/virtgpu: Make vblank event dependent on the host resource". Earlier versions where meant for testing, rather than being merged. See [1] for a discussion of when the fixed problem happens.Quoted 7 lines
[1] https://lore.kernel.org/dri-devel/20251016145230.79270-1-
[email protected]/--- drivers/gpu/drm/virtio/virtgpu_display.c | 67 ++++++++++++++++++++++-- drivers/gpu/drm/virtio/virtgpu_drv.h | 15 ++++++ drivers/gpu/drm/virtio/virtgpu_plane.c | 28 +++++++++- 3 files changed, 104 insertions(+), 6 deletions(-)
Quoted 3 lines
No problems spotted. I'd only extended comment in the code explicitly stating that
drm_gem_is_imported()is the workaround, might edit it on applying. Will wait for Vivek's feedback. Thanks.
I applied this patch and tested 3 different scenarios:
1) blob=true + imported buffers
root@localhost:weston_upstream/weston# ./build/clients/weston-simple-egl -o & Using config: r8g8b8a0 has EGL_EXT_buffer_age and EGL_EXT_swap_buffers_with_damage has EGL_EXT_surface_compression 245 frames in 5 seconds: 49.000000 fps 236 frames in 5 seconds: 47.200001 fps 279 frames in 5 seconds: 55.799999 fps 240 frames in 5 seconds: 48.000000 fps 244 frames in 5 seconds: 48.799999 fps 283 frames in 5 seconds: 56.599998 fps 274 frames in 5 seconds: 54.799999 fps
2) blob=true
root@localhost:/weston_upstream/weston# ./build/clients/weston-simple-egl -o & Using config: r8g8b8a0 has EGL_EXT_buffer_age and EGL_EXT_swap_buffers_with_damage has EGL_EXT_surface_compression 167 frames in 5 seconds: 33.400002 fps 208 frames in 5 seconds: 41.599998 fps 203 frames in 5 seconds: 40.599998 fps 252 frames in 5 seconds: 50.400002 fps 180 frames in 5 seconds: 36.000000 fps 219 frames in 5 seconds: 43.799999 fps 176 frames in 5 seconds: 35.200001 fps 220 frames in 5 seconds: 44.000000 fps
3) blob=false
root@localhost:/weston_upstream/weston# ./build/clients/weston-simple-egl -o & [1] 1137 Using config: r8g8b8a0 has EGL_EXT_buffer_age and EGL_EXT_swap_buffers_with_damage has EGL_EXT_surface_compression 285 frames in 5 seconds: 57.000000 fps 291 frames in 5 seconds: 58.200001 fps 290 frames in 5 seconds: 58.000000 fps 297 frames in 5 seconds: 59.400002 fps 291 frames in 5 seconds: 58.200001 fps 292 frames in 5 seconds: 58.400002 fps
The problem in the first 2 cases above is that as long as blob=true, the vblank timer is not helpful as we would be over-synchronizing. Note that even in the second case, if blob=true, then even dumb BOs would satisfy bo->guest_blob condition.
So, I added the following changes to Thomas' patch and can now achieve FPS >= 58 in all 3 cases above:
drivers/gpu/drm/virtio/virtgpu_display.c +4 -1
@@ -159,7 +159,10 @@ static void virtio_gpu_crtc_mode_set_nofb(struct drm_crtc *crtc)static void virtio_gpu_crtc_atomic_enable (struct drm_crtc *crtc,struct drm_atomic_state *state) { -drm_crtc_vblank_on (crtc); +struct virtio_gpu_crtc_state *vgcrtc_state =to_virtio_gpu_crtc_state (crtc->state); + +if (!virtio_gpu_crtc_state_send_event_on_flush (vgcrtc_state)) +drm_crtc_vblank_on (crtc); } static void virtio_gpu_crtc_atomic_disable(struct drm_crtc *crtc,
drivers/gpu/drm/virtio/virtgpu_plane.c +4 -1
@@ -99,6 +99,8 @@ static const struct drm_plane_funcs virtio_gpu_plane_funcs = {static int virtio_gpu_plane_atomic_check (struct drm_plane *plane,struct drm_atomic_state *state) { +struct drm_device *dev = plane->dev; +struct virtio_gpu_device *vgdev = dev->dev_private;struct drm_plane_state *new_plane_state =drm_atomic_get_new_plane_state (state, plane); struct drm_plane_state *old_plane_state = drm_atomic_get_old_plane_state(state,
@@ -138,13 +140,14 @@ static int virtio_gpu_plane_atomic_check(struct drm_plane *plane,for (i =0 ; i < new_plane_state->fb->format->num_planes; ++i) {struct drm_gem_object *obj =drm_gem_fb_get_obj (new_plane_state->fb, i); +struct virtio_gpu_object *bo =gem_to_virtio_gpu_obj (obj);/* * Exporters of GEM buffer objects sometimes interfere with the * vblank timer. Mark the plane as externally synchronized if we * find an imported GEM buffer object. */ -if (drm_gem_is_imported (obj)) { +if (bo->guest_blob && !vgdev->has_virgl_3d) { vgcrtc_state->plane_synced_to_ext |=drm_plane_mask (plane);break ;/* only need to find one */
For testing the 3 cases, I ran Gnome Wayland like this:
XDG_SESSION_TYPE=wayland dbus-run-session -- ./bin/gnome-shell --wayland --no-x11 &
and here are the relevant options for Qemu cmd line I tested with:
./qemu-system-x86_64 -m 4096m
-device virtio-gpu,max_outputs=1,xres=1920,yres=1080,blob=true
-display gtk,gl=on
-object memory-backend-memfd,id=mem1,size=4096M
-machine q35,accel=kvm,memory-backend=mem1 -usb -device usb-tablet -serial stdio
Thanks,
Vivek
Quoted 7 lines
Reviewed-by Dmitry Osipenko <[email protected]>Tested-by Dmitry Osipenko <[email protected]>--
Best regards,
Dmitry
Thomas Zimmermann
maintainerHi Vivek
Am 29.10.25 um 06:47 schrieb Kasireddy, Vivek:
Quoted 91 lines
Hi Thomas, Dmitry,
Quoted 45 lines
Subject: Re: [PATCH v4] drm/virtgpu: Make vblank event dependent on the external sync
Quoted 34 lines · Thomas Zimmermann
For each plane, store the buffer object's sync status in the state of the plane's respective CRTC. During the CRTC's atomic flush, ignore the vblank timer if any of the CRTC's plane's buffer object is synchronized to an external source. Instead send the vblank event immediately. Avoids corner cases where a vblank event happens too late for the next frame to be page flipped in time.
Exporters of GEM objects sometimes interfere with the vblank timer; resulting in framerate drops. Hence detect this case and handle it as outlined above.
The vblank timer is still active and fires in regular intervals according to the guest display refresh. This rate limits clients that only wait for the next vblank to occur, such as fbcon. These clients would otherwise produce a very high number of frames per second.
v4:
- only handle imported GEM buffer objects (Dmitri, Vivek)
- fix test for plane visibility (Vivek)
- always enable vblank timer to make waiting clients happy v3:
- disable vblank unconditionally
- compute status on each commit
v2:
- enable/disable vblank timer according to buffer setupSigned-off-by Thomas Zimmermann <[email protected]>---
This patch was previously called "drm/virtgpu: Make vblank event dependent on the host resource". Earlier versions where meant for testing, rather than being merged. See [1] for a discussion of when the fixed problem happens.Quoted 7 lines
[1] https://lore.kernel.org/dri-devel/20251016145230.79270-1-
[email protected]/--- drivers/gpu/drm/virtio/virtgpu_display.c | 67 ++++++++++++++++++++++-- drivers/gpu/drm/virtio/virtgpu_drv.h | 15 ++++++ drivers/gpu/drm/virtio/virtgpu_plane.c | 28 +++++++++- 3 files changed, 104 insertions(+), 6 deletions(-)Quoted 3 lines
No problems spotted. I'd only extended comment in the code explicitly stating that
drm_gem_is_imported()is the workaround, might edit it on applying. Will wait for Vivek's feedback. Thanks.I applied this patch and tested 3 different scenarios:
1) blob=true + imported buffersroot@localhost:weston_upstream/weston# ./build/clients/weston-simple-egl -o & Using config: r8g8b8a0 has EGL_EXT_buffer_age and EGL_EXT_swap_buffers_with_damage has EGL_EXT_surface_compression 245 frames in 5 seconds: 49.000000 fps 236 frames in 5 seconds: 47.200001 fps 279 frames in 5 seconds: 55.799999 fps 240 frames in 5 seconds: 48.000000 fps 244 frames in 5 seconds: 48.799999 fps 283 frames in 5 seconds: 56.599998 fps 274 frames in 5 seconds: 54.799999 fps2) blob=true
root@localhost:/weston_upstream/weston# ./build/clients/weston-simple-egl -o & Using config: r8g8b8a0 has EGL_EXT_buffer_age and EGL_EXT_swap_buffers_with_damage has EGL_EXT_surface_compression 167 frames in 5 seconds: 33.400002 fps 208 frames in 5 seconds: 41.599998 fps 203 frames in 5 seconds: 40.599998 fps 252 frames in 5 seconds: 50.400002 fps 180 frames in 5 seconds: 36.000000 fps 219 frames in 5 seconds: 43.799999 fps 176 frames in 5 seconds: 35.200001 fps 220 frames in 5 seconds: 44.000000 fps3) blob=false
root@localhost:/weston_upstream/weston# ./build/clients/weston-simple-egl -o & [1] 1137 Using config: r8g8b8a0 has EGL_EXT_buffer_age and EGL_EXT_swap_buffers_with_damage has EGL_EXT_surface_compression 285 frames in 5 seconds: 57.000000 fps 291 frames in 5 seconds: 58.200001 fps 290 frames in 5 seconds: 58.000000 fps 297 frames in 5 seconds: 59.400002 fps 291 frames in 5 seconds: 58.200001 fps 292 frames in 5 seconds: 58.400002 fps
Quoted 6 lines
The problem in the first 2 cases above is that as long as blob=true, the vblank timer is not helpful as we would be over-synchronizing. Note that even in the second case, if blob=true, then even dumb BOs would satisfy
bo->guest_blobcondition.So, I added the following changes to Thomas' patch and can now achieve FPS >= 58 in all 3 cases above:
Thanks for testing. These changes mostly revert the patch back to an older rev. Let's merge this then to make progress with this bug. I'll send you an update soon.
Best regards
Thomas
Quoted 64 lines
drivers/gpu/drm/virtio/virtgpu_display.c +4
-1@@ -159,7 +159,10 @@ static void virtio_gpu_crtc_mode_set_nofb(struct drm_crtc *crtc)static void virtio_gpu_crtc_atomic_enable (struct drm_crtc *crtc,struct drm_atomic_state *state) { -drm_crtc_vblank_on (crtc); +struct virtio_gpu_crtc_state *vgcrtc_state =to_virtio_gpu_crtc_state (crtc->state); + +if (!virtio_gpu_crtc_state_send_event_on_flush (vgcrtc_state)) +drm_crtc_vblank_on (crtc); } static void virtio_gpu_crtc_atomic_disable(struct drm_crtc *crtc,drivers/gpu/drm/virtio/virtgpu_plane.c +4
-1@@ -99,6 +99,8 @@ static const struct drm_plane_funcs virtio_gpu_plane_funcs = {static int virtio_gpu_plane_atomic_check (struct drm_plane *plane,struct drm_atomic_state *state) { +struct drm_device *dev = plane->dev; +struct virtio_gpu_device *vgdev = dev->dev_private;struct drm_plane_state *new_plane_state =drm_atomic_get_new_plane_state (state, plane); struct drm_plane_state *old_plane_state = drm_atomic_get_old_plane_state(state,@@ -138,13 +140,14 @@ static int virtio_gpu_plane_atomic_check(struct drm_plane *plane,for (i =0 ; i < new_plane_state->fb->format->num_planes; ++i) {struct drm_gem_object *obj =drm_gem_fb_get_obj (new_plane_state->fb, i); +struct virtio_gpu_object *bo =gem_to_virtio_gpu_obj (obj);/* * Exporters of GEM buffer objects sometimes interfere with the * vblank timer. Mark the plane as externally synchronized if we * find an imported GEM buffer object. */ -if (drm_gem_is_imported (obj)) { +if (bo->guest_blob && !vgdev->has_virgl_3d) { vgcrtc_state->plane_synced_to_ext |=drm_plane_mask (plane);break ;/* only need to find one */ For testing the 3 cases, I ran Gnome Wayland like this:
XDG_SESSION_TYPE=wayland dbus-run-session -- ./bin/gnome-shell --wayland --no-x11 &and here are the relevant options for Qemu cmd line I tested with:
./qemu-system-x86_64 -m 4096m
-device virtio-gpu,max_outputs=1,xres=1920,yres=1080,blob=truedrivers/gpu/drm/virtio/virtgpu_plane.c +0
-3-display gtk,gl=on -object memory-backend-memfd,id=mem1,size=4096M -machine q35,accel=kvm,memory-backend=mem1 -usb -device usb-tablet -serial stdioThanks,
VivekQuoted 6 lines
Reviewed-by Dmitry Osipenko <[email protected]>Tested-by Dmitry Osipenko <[email protected]>--
Best regards,
Dmitry
Signature · 7 lines
-- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nuernberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman HRB 36809 (AG Nuernberg)
Dmitry Osipenko
maintainerQuoted 15 lines · Vivek
I applied this patch and tested 3 different scenarios:
1) blob=true + imported buffersroot@localhost:weston_upstream/weston# ./build/clients/weston-simple-egl -o & Using config: r8g8b8a0 has EGL_EXT_buffer_age and EGL_EXT_swap_buffers_with_damage has EGL_EXT_surface_compression 245 frames in 5 seconds: 49.000000 fps 236 frames in 5 seconds: 47.200001 fps 279 frames in 5 seconds: 55.799999 fps 240 frames in 5 seconds: 48.000000 fps 244 frames in 5 seconds: 48.799999 fps 283 frames in 5 seconds: 56.599998 fps 274 frames in 5 seconds: 54.799999 fps2) blob=true
Quoted 12 lines
root@localhost:/weston_upstream/weston# ./build/clients/weston-simple-egl -o & Using config: r8g8b8a0 has EGL_EXT_buffer_age and EGL_EXT_swap_buffers_with_damage has EGL_EXT_surface_compression 167 frames in 5 seconds: 33.400002 fps 208 frames in 5 seconds: 41.599998 fps 203 frames in 5 seconds: 40.599998 fps 252 frames in 5 seconds: 50.400002 fps 180 frames in 5 seconds: 36.000000 fps 219 frames in 5 seconds: 43.799999 fps 176 frames in 5 seconds: 35.200001 fps 220 frames in 5 seconds: 44.000000 fps
Thanks for the testing.
For the second scenario I'm getting better result, it's 55-60fps for me. Given that this is a SW rendering, curious whether that's because you're testing on a lower end machine(?)
Signature · 2 lines
Best regards, Dmitry
Hi Dmitry,
Quoted 34 lines
Subject: Re: [PATCH v4] drm/virtgpu: Make vblank event dependent on the external sync
Quoted 3 lines · Vivek
I applied this patch and tested 3 different scenarios:
1) blob=true + imported buffersroot@localhost:weston_upstream/weston# ./build/clients/weston-simple-egl -o &
Quoted 11 lines
Using config: r8g8b8a0
hasEGL_EXT_buffer_ageandEGL_EXT_swap_buffers_with_damagehasEGL_EXT_surface_compression
245 frames in 5 seconds: 49.000000 fps
236 frames in 5 seconds: 47.200001 fps
279 frames in 5 seconds: 55.799999 fps
240 frames in 5 seconds: 48.000000 fps
244 frames in 5 seconds: 48.799999 fps
283 frames in 5 seconds: 56.599998 fps
274 frames in 5 seconds: 54.799999 fpsQuoted 2 lines
2) blob=true
root@localhost:/weston_upstream/weston# ./build/clients/weston-simple-egl -o &
Quoted 11 lines
Using config: r8g8b8a0
hasEGL_EXT_buffer_ageandEGL_EXT_swap_buffers_with_damagehasEGL_EXT_surface_compression
167 frames in 5 seconds: 33.400002 fps
208 frames in 5 seconds: 41.599998 fps
203 frames in 5 seconds: 40.599998 fps
252 frames in 5 seconds: 50.400002 fps
180 frames in 5 seconds: 36.000000 fps
219 frames in 5 seconds: 43.799999 fps
176 frames in 5 seconds: 35.200001 fps
220 frames in 5 seconds: 44.000000 fps
Quoted 5 lines
Thanks for the testing.
For the second scenario I'm getting better result, it's 55-60fps for me. Given that this is a SW rendering, curious whether that's because you're testing on a lower end machine(?)
I am testing with a dGPU (B60) on the Host where I am running Gnome Xorg but I am running Gnome Wayland in the Guest. What compositors are you running on the Host and Guest? Kwin? Also, could you please share your Qemu launch parameters as well so that we can try to figure out the reason for the performance discrepancy?
Thanks,
Vivek
Quoted 4 lines
--
Best regards,
Dmitry
Dmitry Osipenko
maintainerQuoted 38 lines · Vivek
Hi Dmitry,
Quoted 36 lines
Subject: Re: [PATCH v4] drm/virtgpu: Make vblank event dependent on the external sync
Quoted 3 lines · Vivek
I applied this patch and tested 3 different scenarios:
1) blob=true + imported buffersroot@localhost:weston_upstream/weston# ./build/clients/weston-simple-egl -o &
Quoted 11 lines
Using config: r8g8b8a0
hasEGL_EXT_buffer_ageandEGL_EXT_swap_buffers_with_damagehasEGL_EXT_surface_compression
245 frames in 5 seconds: 49.000000 fps
236 frames in 5 seconds: 47.200001 fps
279 frames in 5 seconds: 55.799999 fps
240 frames in 5 seconds: 48.000000 fps
244 frames in 5 seconds: 48.799999 fps
283 frames in 5 seconds: 56.599998 fps
274 frames in 5 seconds: 54.799999 fpsQuoted 2 lines
2) blob=true
root@localhost:/weston_upstream/weston# ./build/clients/weston-simple-egl -o &
Quoted 11 lines
Using config: r8g8b8a0
hasEGL_EXT_buffer_ageandEGL_EXT_swap_buffers_with_damagehasEGL_EXT_surface_compression
167 frames in 5 seconds: 33.400002 fps
208 frames in 5 seconds: 41.599998 fps
203 frames in 5 seconds: 40.599998 fps
252 frames in 5 seconds: 50.400002 fps
180 frames in 5 seconds: 36.000000 fps
219 frames in 5 seconds: 43.799999 fps
176 frames in 5 seconds: 35.200001 fps
220 frames in 5 seconds: 44.000000 fpsThanks for the testing.
Quoted 8 lines
Quoted 3 lines
For the second scenario I'm getting better result, it's 55-60fps for me. Given that this is a SW rendering, curious whether that's because you're testing on a lower end machine(?)
I am testing with a dGPU (B60) on the Host where I am running Gnome Xorg but I am running Gnome Wayland in the Guest. What compositors are you running on the Host and Guest? Kwin? Also, could you please share your Qemu launch parameters as well so that we can try to figure out the reason for the performance discrepancy?
Did further testing on older IvyBridge machine and getting comparable result to yours on it.
I'm using exactly same QEMU setup as you do with nothing special in the cmdline. Tested with both KDE and Gnome on host.
On IvyBridge getting:
- 46-55fps jittery with GTK display + blob + vblank_timer
- 46-55fps jittery with GTK display + blob + vblank_timer + vblank_mode=1 to disable vsync on host
- constant 60fps with GTK display without blob + vblank_timer
- constant 60fps with GTK display + blob without vblank_timer
- constant 60fps with SDL display + blob + vblank_timer
So, discrepancy of the results is directly tied to CPU performance + GTK oddity when SW+blob rendering is used on guest.
Why SDL performs much better than GTK I don't know.
Signature · 2 lines
Best regards, Dmitry
Dmitry Osipenko
maintainerQuoted 63 lines · Dmitry Osipenko
Quoted 38 lines · Vivek
Hi Dmitry,
Quoted 36 lines
Subject: Re: [PATCH v4] drm/virtgpu: Make vblank event dependent on the external sync
Quoted 3 lines · Vivek
I applied this patch and tested 3 different scenarios:
1) blob=true + imported buffersroot@localhost:weston_upstream/weston# ./build/clients/weston-simple-egl -o &
Quoted 11 lines
Using config: r8g8b8a0
hasEGL_EXT_buffer_ageandEGL_EXT_swap_buffers_with_damagehasEGL_EXT_surface_compression
245 frames in 5 seconds: 49.000000 fps
236 frames in 5 seconds: 47.200001 fps
279 frames in 5 seconds: 55.799999 fps
240 frames in 5 seconds: 48.000000 fps
244 frames in 5 seconds: 48.799999 fps
283 frames in 5 seconds: 56.599998 fps
274 frames in 5 seconds: 54.799999 fpsQuoted 2 lines
2) blob=true
root@localhost:/weston_upstream/weston# ./build/clients/weston-simple-egl -o &
Quoted 11 lines
Using config: r8g8b8a0
hasEGL_EXT_buffer_ageandEGL_EXT_swap_buffers_with_damagehasEGL_EXT_surface_compression
167 frames in 5 seconds: 33.400002 fps
208 frames in 5 seconds: 41.599998 fps
203 frames in 5 seconds: 40.599998 fps
252 frames in 5 seconds: 50.400002 fps
180 frames in 5 seconds: 36.000000 fps
219 frames in 5 seconds: 43.799999 fps
176 frames in 5 seconds: 35.200001 fps
220 frames in 5 seconds: 44.000000 fpsThanks for the testing.
Quoted 8 lines
Quoted 3 lines
For the second scenario I'm getting better result, it's 55-60fps for me. Given that this is a SW rendering, curious whether that's because you're testing on a lower end machine(?)
I am testing with a dGPU (B60) on the Host where I am running Gnome Xorg but I am running Gnome Wayland in the Guest. What compositors are you running on the Host and Guest? Kwin? Also, could you please share your Qemu launch parameters as well so that we can try to figure out the reason for the performance discrepancy?
Did further testing on older IvyBridge machine and getting comparable result to yours on it.
I'm using exactly same QEMU setup as you do with nothing special in the cmdline. Tested with both KDE and Gnome on host.
On IvyBridge getting:
- 46-55fps jittery with GTK display + blob +
vblank_timer
- 46-55fps jittery with GTK display + blob +vblank_timer+ vblank_mode=1 to disable vsync on host
- constant 60fps with GTK display without blob +vblank_timer
- constant 60fps with GTK display + blob withoutvblank_timer
- constant 60fps with SDL display + blob +vblank_timer
Quoted 5 lines
So, discrepancy of the results is directly tied to CPU performance + GTK oddity when SW+blob rendering is used on guest.
Why SDL performs much better than GTK I don't know.
Forgot to mention that I'm testing using my [1] QEMU branch.
[1] https://gitlab.freedesktop.org/digetx/qemu/-/commits/native-context-v14
Signature · 2 lines
Best regards, Dmitry
Hi Dmitry,
Quoted 50 lines
Subject: Re: [PATCH v4] drm/virtgpu: Make vblank event dependent on the external sync
Quoted 3 lines · Vivek
Hi Dmitry,
Quoted 1 line
Subject: Re: [PATCH v4] drm/virtgpu: Make vblank event dependent on
the
Quoted 6 lines
Quoted 6 lines
external sync
Quoted 3 lines · Vivek
I applied this patch and tested 3 different scenarios:
1) blob=true + imported buffersroot@localhost:weston_upstream/weston# ./build/clients/weston-simple-
Quoted 12 lines
Quoted 12 lines
egl -o &
Quoted 11 lines
Using config: r8g8b8a0
hasEGL_EXT_buffer_ageandEGL_EXT_swap_buffers_with_damagehasEGL_EXT_surface_compression
245 frames in 5 seconds: 49.000000 fps
236 frames in 5 seconds: 47.200001 fps
279 frames in 5 seconds: 55.799999 fps
240 frames in 5 seconds: 48.000000 fps
244 frames in 5 seconds: 48.799999 fps
283 frames in 5 seconds: 56.599998 fps
274 frames in 5 seconds: 54.799999 fpsQuoted 2 lines
Quoted 2 lines
Quoted 2 lines
2) blob=true
root@localhost:/weston_upstream/weston# ./build/clients/weston-simple-
Quoted 13 lines
Quoted 13 lines
egl -o &
Quoted 11 lines
Using config: r8g8b8a0
hasEGL_EXT_buffer_ageandEGL_EXT_swap_buffers_with_damagehasEGL_EXT_surface_compression
167 frames in 5 seconds: 33.400002 fps
208 frames in 5 seconds: 41.599998 fps
203 frames in 5 seconds: 40.599998 fps
252 frames in 5 seconds: 50.400002 fps
180 frames in 5 seconds: 36.000000 fps
219 frames in 5 seconds: 43.799999 fps
176 frames in 5 seconds: 35.200001 fps
220 frames in 5 seconds: 44.000000 fpsQuoted 6 lines
Quoted 5 lines
Thanks for the testing.
For the second scenario I'm getting better result, it's 55-60fps for me. Given that this is a SW rendering, curious whether that's because you're testing on a lower end machine(?)
I am testing with a dGPU (B60) on the Host where I am running Gnome
Xorg
Quoted 8 lines
Quoted 3 lines
but I am running Gnome Wayland in the Guest. What compositors are you running on the Host and Guest? Kwin? Also, could you please share your Qemu launch parameters as well so that we can try to figure out the
reason
Quoted 1 line
for the performance discrepancy?
Did further testing on older IvyBridge machine and getting comparable result to yours on it.
Thank you for running these tests.
Quoted 4 lines
I'm using exactly same QEMU setup as you do with nothing special in the cmdline. Tested with both KDE and Gnome on host.
Quoted 8 lines
On IvyBridge getting:
- 46-55fps jittery with GTK display + blob +
vblank_timer
- 46-55fps jittery with GTK display + blob +vblank_timer+ vblank_mode=1 to disable vsync on host
- constant 60fps with GTK display without blob +vblank_timer
- constant 60fps with GTK display + blob withoutvblank_timer
- constant 60fps with SDL display + blob +vblank_timer
What happens in the case of:
- SDL display + blob without vblank_timer
- SDL display + vblank_timer without blob
Quoted 5 lines
So, discrepancy of the results is directly tied to CPU performance + GTK oddity when SW+blob rendering is used on guest.
Why SDL performs much better than GTK I don't know.
AFAICS, there are some key differences between SDL and GTK UIs that might be playing a role:
- SDL UI does not implement dmabuf ops such as dpy_gl_scanout_dmabuf() but it does implement dpy_gl_scanout_texture() which I see is only called from virtio-gpu-virgl.c. I am wondering how does the display get updated in non-virgl usecases, especially when blob=true and given that this option is specifically meant for UI's dmabuf ops?
- GTK asynchronously waits (using an EGL fence) until the GPU Blit is completed (before releasing Guest FB) which other UIs do not do when blob=true. So, this might incur some extra delay which is not the case with SDL.
- SDL's display updates (sent to the Host compositor) seem to be UI timer driven while GTK's updates are repaint callback driven.
Thanks,
Vivek
Quoted 4 lines
--
Best regards,
Dmitry
Dmitry Osipenko
maintainerQuoted 91 lines · Vivek
Hi Dmitry,
Quoted 50 lines
Subject: Re: [PATCH v4] drm/virtgpu: Make vblank event dependent on the external sync
Quoted 3 lines · Vivek
Hi Dmitry,
Quoted 1 line
Subject: Re: [PATCH v4] drm/virtgpu: Make vblank event dependent on
the
Quoted 6 lines
Quoted 6 lines
external sync
Quoted 3 lines · Vivek
I applied this patch and tested 3 different scenarios:
1) blob=true + imported buffersroot@localhost:weston_upstream/weston# ./build/clients/weston-simple-
Quoted 12 lines
Quoted 12 lines
egl -o &
Quoted 11 lines
Using config: r8g8b8a0
hasEGL_EXT_buffer_ageandEGL_EXT_swap_buffers_with_damagehasEGL_EXT_surface_compression
245 frames in 5 seconds: 49.000000 fps
236 frames in 5 seconds: 47.200001 fps
279 frames in 5 seconds: 55.799999 fps
240 frames in 5 seconds: 48.000000 fps
244 frames in 5 seconds: 48.799999 fps
283 frames in 5 seconds: 56.599998 fps
274 frames in 5 seconds: 54.799999 fpsQuoted 2 lines
Quoted 2 lines
Quoted 2 lines
2) blob=true
root@localhost:/weston_upstream/weston# ./build/clients/weston-simple-
Quoted 13 lines
Quoted 13 lines
egl -o &
Quoted 11 lines
Using config: r8g8b8a0
hasEGL_EXT_buffer_ageandEGL_EXT_swap_buffers_with_damagehasEGL_EXT_surface_compression
167 frames in 5 seconds: 33.400002 fps
208 frames in 5 seconds: 41.599998 fps
203 frames in 5 seconds: 40.599998 fps
252 frames in 5 seconds: 50.400002 fps
180 frames in 5 seconds: 36.000000 fps
219 frames in 5 seconds: 43.799999 fps
176 frames in 5 seconds: 35.200001 fps
220 frames in 5 seconds: 44.000000 fpsQuoted 6 lines
Quoted 5 lines
Thanks for the testing.
For the second scenario I'm getting better result, it's 55-60fps for me. Given that this is a SW rendering, curious whether that's because you're testing on a lower end machine(?)
I am testing with a dGPU (B60) on the Host where I am running Gnome
Xorg
Quoted 8 lines
Quoted 3 lines
but I am running Gnome Wayland in the Guest. What compositors are you running on the Host and Guest? Kwin? Also, could you please share your Qemu launch parameters as well so that we can try to figure out the
reason
Quoted 1 line
for the performance discrepancy?
Did further testing on older IvyBridge machine and getting comparable result to yours on it.
Thank you for running these tests.
Quoted 4 lines
I'm using exactly same QEMU setup as you do with nothing special in the cmdline. Tested with both KDE and Gnome on host.
Quoted 8 lines
On IvyBridge getting:
- 46-55fps jittery with GTK display + blob +
vblank_timer
- 46-55fps jittery with GTK display + blob +vblank_timer+ vblank_mode=1 to disable vsync on host
- constant 60fps with GTK display without blob +vblank_timer
- constant 60fps with GTK display + blob withoutvblank_timer
- constant 60fps with SDL display + blob +vblank_timerWhat happens in the case of:
- SDL display + blob withoutvblank_timer
- SDL display +vblank_timerwithout blobQuoted 5 lines
So, discrepancy of the results is directly tied to CPU performance + GTK oddity when SW+blob rendering is used on guest.
Why SDL performs much better than GTK I don't know.
AFAICS, there are some key differences between SDL and GTK UIs that might be playing a role:
- SDL UI does not implement dmabuf ops such asdpy_gl_scanout_dmabuf()but it does implementdpy_gl_scanout_texture()which I see is only called fromvirtio-gpu-virgl.c. I am wondering how does the display get updated in non-virgl usecases, especially when blob=true and given that this option is specifically meant for UI's dmabuf ops?
Quoted 7 lines
- GTK asynchronously waits (using an EGL fence) until the GPU Blit is completed (before releasing Guest FB) which other UIs do not do when blob=true. So, this might incur some extra delay which is not the case with SDL.
- SDL's display updates (sent to the Host compositor) seem to be UI timer driven while GTK's updates are repaint callback driven.
My QEMU branch contains patch adding dpy_gl_scanout_dmabuf() support to SDL display. Haven't checked without it, will check next week.
Assume this is a QEMU-specific issue with how QEMU display logic works. It's unclear to me how much severe this problem is in practice. Meanwhile should be okay to add a workaround for guest blobs with a comment explaining why it's needed if this is a significant-enough regression for your use-cases. Feel free to send v5.
Signature · 2 lines
Best regards, Dmitry