qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 2/2] xen-bus: Avoid rewriting identical values t


From: Anthony PERARD
Subject: Re: [Qemu-devel] [PATCH 2/2] xen-bus: Avoid rewriting identical values to xenstore
Date: Thu, 22 Aug 2019 12:17:30 +0100
User-agent: Mutt/1.12.1 (2019-06-15)

On Thu, Aug 22, 2019 at 11:36:32AM +0100, Paul Durrant wrote:
> But, now I look at the code again without your patch applied I don't actually 
> see the problem it is trying to fix. The functions 
> xen_device_[back|front]end_set_state return early if the state being set 
> matches the existing state and hence never get to the line where the state is 
> written to xenstore.

Let's see:
    * step 1 (initial states in xenstore and QEMU)
        xenstore/frontend/state = 4
        xendev->frontend_state = 4
    * step 2 (frontend changes state in xenstore)
        xenstore/frontend/state = 5
    * step 3 (watch event received by QEMU)
        xen_device_frontend_changed()
            state = read(xenstore/frontend/state) (state=5)
            xen_device_frontend_set_state(state)
                xendev->frontend_state != state  (4!=5)
                    xendev->frontend_state = state
                    xenstore/frontend/state = state
    * step 4
        # watch event triggers xen_device_frontend_changed() again but
        # this time xendev->frontend_state == xenstore/frontend_state

This is how QEMU writes to xenstore an identical value.

That behavior might be an issue if the frontend changes the value after
QEMU have read it but before QEMU writes it again.

Also, it's nice to avoid extra work.

-- 
Anthony PERARD



reply via email to

[Prev in Thread] Current Thread [Next in Thread]