xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Anthony PERARD <anthony.perard@citrix.com>
To: Paul Durrant <Paul.Durrant@citrix.com>
Cc: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
	Stefano Stabellini <sstabellini@kernel.org>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: Re: [Xen-devel] [PATCH 2/2] xen-bus: Avoid rewriting identical values to xenstore
Date: Thu, 22 Aug 2019 12:17:30 +0100	[thread overview]
Message-ID: <20190822111730.GK1289@perard.uk.xensource.com> (raw)
In-Reply-To: <b63f378211d8451d8267f83f0922138e@AMSPEX02CL03.citrite.net>

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

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2019-08-22 11:17 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20190821092020.17952-1-anthony.perard@citrix.com>
2019-08-21  9:20 ` [Xen-devel] [PATCH 1/2] xen-bus: Fix backend state transition on device reset Anthony PERARD
2019-08-21  9:36   ` Paul Durrant
2019-08-22  9:50     ` Anthony PERARD
2019-08-22  9:59       ` Paul Durrant
2019-08-22 15:01         ` Anthony PERARD
2019-08-21  9:20 ` [Xen-devel] [PATCH 2/2] xen-bus: Avoid rewriting identical values to xenstore Anthony PERARD
2019-08-21 15:40   ` Paul Durrant
2019-08-22 10:21     ` Anthony PERARD
2019-08-22 10:36       ` Paul Durrant
2019-08-22 11:17         ` Anthony PERARD [this message]
2019-08-22 11:25           ` Paul Durrant
2019-08-22 13:18             ` Anthony PERARD
2019-08-22 13:21               ` Paul Durrant

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190822111730.GK1289@perard.uk.xensource.com \
    --to=anthony.perard@citrix.com \
    --cc=Paul.Durrant@citrix.com \
    --cc=qemu-devel@nongnu.org \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).