[PATCH v2 0/3] virtio-gpu: fix blob unmapping sequence

Manos Pitsidianakis posted 3 patches 7 months, 1 week ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20250410122643.1747913-1-manos.pitsidianakis@linaro.org
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>
include/exec/memory.h         |  1 +
hw/display/virtio-gpu-virgl.c | 60 ++++++++++++++++++++---------------
2 files changed, 35 insertions(+), 26 deletions(-)
[PATCH v2 0/3] virtio-gpu: fix blob unmapping sequence
Posted by Manos Pitsidianakis 7 months, 1 week ago
A hang was observed when running a small kernel that exercised VIRTIO 
GPU under TCG. This is an edge-case and won't happen under typical 
conditions.

When unmapping a blob object, its MemoryRegion's freeing is deferred to 
the RCU thread. The hang's cause was determined to be a busy main loop 
not allowing for the RCU thread to run because the kernel did not setup 
any timers or had any interrupts on the way. While fixing the RCU thread 
to run even if the guest CPU spins is a solution, it's easier to fix the 
reason why the MemoryRegion isn't freed from the main loop instead.

While at it, also restructure the 3 stage cleanup to immediately respond 
to the guest if the MR happened to have had no other reference.

PS: The hang can be reproduced by running this unikernel with TCG 

https://git.codelinaro.org/manos.pitsidianakis/virtio-tests/-/tree/8c0ebe9395827e24aa5711186d499bf5de87cf63/virtio-test-suite

v1 to v2:
  - Add patch by Alex to prevent double-free when FlatView is destroyed 
    from RCU thread.

Alex Bennée (1):
  hw/display: re-arrange memory region tracking

Manos Pitsidianakis (2):
  virtio-gpu: fix hang under TCG when unmapping blob
  virtio-gpu: refactor async blob unmapping

 include/exec/memory.h         |  1 +
 hw/display/virtio-gpu-virgl.c | 60 ++++++++++++++++++++---------------
 2 files changed, 35 insertions(+), 26 deletions(-)


base-commit: 56c6e249b6988c1b6edc2dd34ebb0f1e570a1365
-- 
γαῖα πυρί μιχθήτω


Re: [PATCH v2 0/3] virtio-gpu: fix blob unmapping sequence
Posted by Alex Bennée 7 months ago
Manos Pitsidianakis <manos.pitsidianakis@linaro.org> writes:

> A hang was observed when running a small kernel that exercised VIRTIO 
> GPU under TCG. This is an edge-case and won't happen under typical 
> conditions.

Queued to virtio-gpu/next, thanks.

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro
Re: [PATCH v2 0/3] virtio-gpu: fix blob unmapping sequence
Posted by Alex Bennée 7 months ago
Manos Pitsidianakis <manos.pitsidianakis@linaro.org> writes:

> A hang was observed when running a small kernel that exercised VIRTIO 
> GPU under TCG. This is an edge-case and won't happen under typical 
> conditions.

Should I (or MST?) pull these into a tree for 10.0 or should they be
grabbed for when the tree opens with a Cc qemu-stable?

>
> When unmapping a blob object, its MemoryRegion's freeing is deferred to 
> the RCU thread. The hang's cause was determined to be a busy main loop 
> not allowing for the RCU thread to run because the kernel did not setup 
> any timers or had any interrupts on the way. While fixing the RCU thread 
> to run even if the guest CPU spins is a solution, it's easier to fix the 
> reason why the MemoryRegion isn't freed from the main loop instead.
>
> While at it, also restructure the 3 stage cleanup to immediately respond 
> to the guest if the MR happened to have had no other reference.
>
> PS: The hang can be reproduced by running this unikernel with TCG 
>
> https://git.codelinaro.org/manos.pitsidianakis/virtio-tests/-/tree/8c0ebe9395827e24aa5711186d499bf5de87cf63/virtio-test-suite
>
> v1 to v2:
>   - Add patch by Alex to prevent double-free when FlatView is destroyed 
>     from RCU thread.
>
> Alex Bennée (1):
>   hw/display: re-arrange memory region tracking
>
> Manos Pitsidianakis (2):
>   virtio-gpu: fix hang under TCG when unmapping blob
>   virtio-gpu: refactor async blob unmapping
>
>  include/exec/memory.h         |  1 +
>  hw/display/virtio-gpu-virgl.c | 60 ++++++++++++++++++++---------------
>  2 files changed, 35 insertions(+), 26 deletions(-)
>
>
> base-commit: 56c6e249b6988c1b6edc2dd34ebb0f1e570a1365

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro
Re: [PATCH v2 0/3] virtio-gpu: fix blob unmapping sequence
Posted by Stefan Hajnoczi 7 months ago
On Tue, Apr 15, 2025 at 07:46:14PM +0100, Alex Bennée wrote:
> Manos Pitsidianakis <manos.pitsidianakis@linaro.org> writes:
> 
> > A hang was observed when running a small kernel that exercised VIRTIO 
> > GPU under TCG. This is an edge-case and won't happen under typical 
> > conditions.
> 
> Should I (or MST?) pull these into a tree for 10.0 or should they be
> grabbed for when the tree opens with a Cc qemu-stable?

QEMU 10.0.0-rc4 has already been tagged. No further patches will be
merged unless there is a show-stopper (build failure, security issue).

Please Cc qemu-stable so this can be merged for 10.0.1. Thanks!

> 
> >
> > When unmapping a blob object, its MemoryRegion's freeing is deferred to 
> > the RCU thread. The hang's cause was determined to be a busy main loop 
> > not allowing for the RCU thread to run because the kernel did not setup 
> > any timers or had any interrupts on the way. While fixing the RCU thread 
> > to run even if the guest CPU spins is a solution, it's easier to fix the 
> > reason why the MemoryRegion isn't freed from the main loop instead.
> >
> > While at it, also restructure the 3 stage cleanup to immediately respond 
> > to the guest if the MR happened to have had no other reference.
> >
> > PS: The hang can be reproduced by running this unikernel with TCG 
> >
> > https://git.codelinaro.org/manos.pitsidianakis/virtio-tests/-/tree/8c0ebe9395827e24aa5711186d499bf5de87cf63/virtio-test-suite
> >
> > v1 to v2:
> >   - Add patch by Alex to prevent double-free when FlatView is destroyed 
> >     from RCU thread.
> >
> > Alex Bennée (1):
> >   hw/display: re-arrange memory region tracking
> >
> > Manos Pitsidianakis (2):
> >   virtio-gpu: fix hang under TCG when unmapping blob
> >   virtio-gpu: refactor async blob unmapping
> >
> >  include/exec/memory.h         |  1 +
> >  hw/display/virtio-gpu-virgl.c | 60 ++++++++++++++++++++---------------
> >  2 files changed, 35 insertions(+), 26 deletions(-)
> >
> >
> > base-commit: 56c6e249b6988c1b6edc2dd34ebb0f1e570a1365
> 
> -- 
> Alex Bennée
> Virtualisation Tech Lead @ Linaro
> 
Re: [PATCH v2 0/3] virtio-gpu: fix blob unmapping sequence
Posted by Michael S. Tsirkin 7 months ago
On Tue, Apr 15, 2025 at 07:46:14PM +0100, Alex Bennée wrote:
> Manos Pitsidianakis <manos.pitsidianakis@linaro.org> writes:
> 
> > A hang was observed when running a small kernel that exercised VIRTIO 
> > GPU under TCG. This is an edge-case and won't happen under typical 
> > conditions.
> 
> Should I (or MST?) pull these into a tree for 10.0 or should they be
> grabbed for when the tree opens with a Cc qemu-stable?


Let's just agree who takes them, then it's up to that maintainer.
You wanna merge them?

> >
> > When unmapping a blob object, its MemoryRegion's freeing is deferred to 
> > the RCU thread. The hang's cause was determined to be a busy main loop 
> > not allowing for the RCU thread to run because the kernel did not setup 
> > any timers or had any interrupts on the way. While fixing the RCU thread 
> > to run even if the guest CPU spins is a solution, it's easier to fix the 
> > reason why the MemoryRegion isn't freed from the main loop instead.
> >
> > While at it, also restructure the 3 stage cleanup to immediately respond 
> > to the guest if the MR happened to have had no other reference.
> >
> > PS: The hang can be reproduced by running this unikernel with TCG 
> >
> > https://git.codelinaro.org/manos.pitsidianakis/virtio-tests/-/tree/8c0ebe9395827e24aa5711186d499bf5de87cf63/virtio-test-suite
> >
> > v1 to v2:
> >   - Add patch by Alex to prevent double-free when FlatView is destroyed 
> >     from RCU thread.
> >
> > Alex Bennée (1):
> >   hw/display: re-arrange memory region tracking
> >
> > Manos Pitsidianakis (2):
> >   virtio-gpu: fix hang under TCG when unmapping blob
> >   virtio-gpu: refactor async blob unmapping
> >
> >  include/exec/memory.h         |  1 +
> >  hw/display/virtio-gpu-virgl.c | 60 ++++++++++++++++++++---------------
> >  2 files changed, 35 insertions(+), 26 deletions(-)
> >
> >
> > base-commit: 56c6e249b6988c1b6edc2dd34ebb0f1e570a1365
> 
> -- 
> Alex Bennée
> Virtualisation Tech Lead @ Linaro
Re: [PATCH v2 0/3] virtio-gpu: fix blob unmapping sequence
Posted by Alex Bennée 7 months ago
"Michael S. Tsirkin" <mst@redhat.com> writes:

> On Tue, Apr 15, 2025 at 07:46:14PM +0100, Alex Bennée wrote:
>> Manos Pitsidianakis <manos.pitsidianakis@linaro.org> writes:
>> 
>> > A hang was observed when running a small kernel that exercised VIRTIO 
>> > GPU under TCG. This is an edge-case and won't happen under typical 
>> > conditions.
>> 
>> Should I (or MST?) pull these into a tree for 10.0 or should they be
>> grabbed for when the tree opens with a Cc qemu-stable?
>
>
> Let's just agree who takes them, then it's up to that maintainer.
> You wanna merge them?

I'm happy to take them, I'll cc stable when the tree opens up again.

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro
Re: [PATCH v2 0/3] virtio-gpu: fix blob unmapping sequence
Posted by Michael S. Tsirkin 7 months ago
On Thu, Apr 17, 2025 at 09:00:40AM +0100, Alex Bennée wrote:
> "Michael S. Tsirkin" <mst@redhat.com> writes:
> 
> > On Tue, Apr 15, 2025 at 07:46:14PM +0100, Alex Bennée wrote:
> >> Manos Pitsidianakis <manos.pitsidianakis@linaro.org> writes:
> >> 
> >> > A hang was observed when running a small kernel that exercised VIRTIO 
> >> > GPU under TCG. This is an edge-case and won't happen under typical 
> >> > conditions.
> >> 
> >> Should I (or MST?) pull these into a tree for 10.0 or should they be
> >> grabbed for when the tree opens with a Cc qemu-stable?
> >
> >
> > Let's just agree who takes them, then it's up to that maintainer.
> > You wanna merge them?
> 
> I'm happy to take them, I'll cc stable when the tree opens up again.


Acked-by: Michael S. Tsirkin <mst@redhat.com>


> -- 
> Alex Bennée
> Virtualisation Tech Lead @ Linaro