From: Anthony PERARD <anthony.perard@citrix.com> To: <qemu-devel@nongnu.org> Cc: Anthony PERARD <anthony.perard@citrix.com>, xen-devel@lists.xenproject.org, Stefano Stabellini <sstabellini@kernel.org>, Paul Durrant <paul.durrant@citrix.com> Subject: [Qemu-devel] [PATCH v2 2/2] xen-bus: Avoid rewriting identical values to xenstore Date: Fri, 23 Aug 2019 11:15:34 +0100 [thread overview] Message-ID: <20190823101534.465-3-anthony.perard@citrix.com> (raw) In-Reply-To: <20190823101534.465-1-anthony.perard@citrix.com> When QEMU receives a xenstore watch event suggesting that the "state" of the frontend changed, it records this in its own state but it also re-write the value back into xenstore even so there were no change. This triggers an unnecessary xenstore watch event which QEMU will process again (and maybe the frontend as well). Also QEMU could potentially write an already old value. Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> --- Notes: v2: - fix coding style - only change frontend_set_state() and use 'publish' instead of 'export'. hw/xen/xen-bus.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/hw/xen/xen-bus.c b/hw/xen/xen-bus.c index 62c127b926..a04478ad4f 100644 --- a/hw/xen/xen-bus.c +++ b/hw/xen/xen-bus.c @@ -698,7 +698,8 @@ int xen_device_frontend_scanf(XenDevice *xendev, const char *key, } static void xen_device_frontend_set_state(XenDevice *xendev, - enum xenbus_state state) + enum xenbus_state state, + bool publish) { const char *type = object_get_typename(OBJECT(xendev)); @@ -710,7 +711,9 @@ static void xen_device_frontend_set_state(XenDevice *xendev, xs_strstate(state)); xendev->frontend_state = state; - xen_device_frontend_printf(xendev, "state", "%u", state); + if (publish) { + xen_device_frontend_printf(xendev, "state", "%u", state); + } } static void xen_device_frontend_changed(void *opaque) @@ -726,7 +729,7 @@ static void xen_device_frontend_changed(void *opaque) state = XenbusStateUnknown; } - xen_device_frontend_set_state(xendev, state); + xen_device_frontend_set_state(xendev, state, false); if (state == XenbusStateInitialising && xendev->backend_state == XenbusStateClosed && @@ -1169,7 +1172,7 @@ static void xen_device_realize(DeviceState *dev, Error **errp) xen_device_frontend_printf(xendev, "backend-id", "%u", xenbus->backend_id); - xen_device_frontend_set_state(xendev, XenbusStateInitialising); + xen_device_frontend_set_state(xendev, XenbusStateInitialising, true); xendev->exit.notify = xen_device_exit; qemu_add_exit_notifier(&xendev->exit); -- Anthony PERARD
WARNING: multiple messages have this Message-ID (diff)
From: Anthony PERARD <anthony.perard@citrix.com> To: <qemu-devel@nongnu.org> Cc: Anthony PERARD <anthony.perard@citrix.com>, xen-devel@lists.xenproject.org, Stefano Stabellini <sstabellini@kernel.org>, Paul Durrant <paul.durrant@citrix.com> Subject: [Xen-devel] [PATCH v2 2/2] xen-bus: Avoid rewriting identical values to xenstore Date: Fri, 23 Aug 2019 11:15:34 +0100 [thread overview] Message-ID: <20190823101534.465-3-anthony.perard@citrix.com> (raw) In-Reply-To: <20190823101534.465-1-anthony.perard@citrix.com> When QEMU receives a xenstore watch event suggesting that the "state" of the frontend changed, it records this in its own state but it also re-write the value back into xenstore even so there were no change. This triggers an unnecessary xenstore watch event which QEMU will process again (and maybe the frontend as well). Also QEMU could potentially write an already old value. Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> --- Notes: v2: - fix coding style - only change frontend_set_state() and use 'publish' instead of 'export'. hw/xen/xen-bus.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/hw/xen/xen-bus.c b/hw/xen/xen-bus.c index 62c127b926..a04478ad4f 100644 --- a/hw/xen/xen-bus.c +++ b/hw/xen/xen-bus.c @@ -698,7 +698,8 @@ int xen_device_frontend_scanf(XenDevice *xendev, const char *key, } static void xen_device_frontend_set_state(XenDevice *xendev, - enum xenbus_state state) + enum xenbus_state state, + bool publish) { const char *type = object_get_typename(OBJECT(xendev)); @@ -710,7 +711,9 @@ static void xen_device_frontend_set_state(XenDevice *xendev, xs_strstate(state)); xendev->frontend_state = state; - xen_device_frontend_printf(xendev, "state", "%u", state); + if (publish) { + xen_device_frontend_printf(xendev, "state", "%u", state); + } } static void xen_device_frontend_changed(void *opaque) @@ -726,7 +729,7 @@ static void xen_device_frontend_changed(void *opaque) state = XenbusStateUnknown; } - xen_device_frontend_set_state(xendev, state); + xen_device_frontend_set_state(xendev, state, false); if (state == XenbusStateInitialising && xendev->backend_state == XenbusStateClosed && @@ -1169,7 +1172,7 @@ static void xen_device_realize(DeviceState *dev, Error **errp) xen_device_frontend_printf(xendev, "backend-id", "%u", xenbus->backend_id); - xen_device_frontend_set_state(xendev, XenbusStateInitialising); + xen_device_frontend_set_state(xendev, XenbusStateInitialising, true); xendev->exit.notify = xen_device_exit; qemu_add_exit_notifier(&xendev->exit); -- Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2019-08-23 10:18 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-08-23 10:15 [Qemu-devel] [PATCH v2 0/2] Fix for the xen-bus driver Anthony PERARD 2019-08-23 10:15 ` [Qemu-devel] [PATCH v2 1/2] xen-bus: Fix backend state transition on device reset Anthony PERARD 2019-08-23 10:15 ` [Xen-devel] " Anthony PERARD 2019-08-27 9:44 ` [Qemu-devel] " Paul Durrant 2019-08-27 9:44 ` [Xen-devel] " Paul Durrant 2019-08-23 10:15 ` Anthony PERARD [this message] 2019-08-23 10:15 ` [Xen-devel] [PATCH v2 2/2] xen-bus: Avoid rewriting identical values to xenstore Anthony PERARD 2019-08-27 9:46 ` [Qemu-devel] " Paul Durrant 2019-08-27 9:46 ` [Xen-devel] " 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=20190823101534.465-3-anthony.perard@citrix.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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.