From: Stefano Stabellini <sstabellini@kernel.org> To: stefanha@gmail.com Cc: stefanha@redhat.com, peter.maydell@linaro.org, sstabellini@kernel.org, anthony.perard@citrix.com, xen-devel@lists.xenproject.org, qemu-devel@nongnu.org, Jan Beulich <JBeulich@suse.com>, Jan Beulich <jbeulich@suse.com> Subject: [Qemu-devel] [PULL 3/4] xen: slightly simplify bufioreq handling Date: Mon, 28 Nov 2016 11:42:25 -0800 [thread overview] Message-ID: <1480362146-14873-3-git-send-email-sstabellini@kernel.org> (raw) In-Reply-To: <1480362146-14873-1-git-send-email-sstabellini@kernel.org> From: Jan Beulich <JBeulich@suse.com> There's no point setting fields always receiving the same value on each iteration, as handle_ioreq() doesn't alter them anyway. Set state and count once ahead of the loop, drop the redundant clearing of data_is_ptr, and avoid the meaningless (because count is 1) setting of df altogether. Also avoid doing an unsigned long calculation of size when the field to be initialized is only 32 bits wide (and the shift value in the range 0...3). Signed-off-by: Jan Beulich <jbeulich@suse.com> Reviewed-by: Paul Durrant <paul.durrant@citrix.com> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org> Signed-off-by: Stefano Stabellini <sstabellini@kernel.org> --- xen-hvm.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/xen-hvm.c b/xen-hvm.c index d74e233..124ae10 100644 --- a/xen-hvm.c +++ b/xen-hvm.c @@ -995,6 +995,8 @@ static int handle_buffered_iopage(XenIOState *state) } memset(&req, 0x00, sizeof(req)); + req.state = STATE_IOREQ_READY; + req.count = 1; for (;;) { uint32_t rdptr = buf_page->read_pointer, wrptr; @@ -1009,15 +1011,11 @@ static int handle_buffered_iopage(XenIOState *state) break; } buf_req = &buf_page->buf_ioreq[rdptr % IOREQ_BUFFER_SLOT_NUM]; - req.size = 1UL << buf_req->size; - req.count = 1; + req.size = 1U << buf_req->size; req.addr = buf_req->addr; req.data = buf_req->data; - req.state = STATE_IOREQ_READY; req.dir = buf_req->dir; - req.df = 1; req.type = buf_req->type; - req.data_is_ptr = 0; xen_rmb(); qw = (req.size == 8); if (qw) { @@ -1032,6 +1030,13 @@ static int handle_buffered_iopage(XenIOState *state) handle_ioreq(state, &req); + /* Only req.data may get updated by handle_ioreq(), albeit even that + * should not happen as such data would never make it to the guest. + */ + assert(req.state == STATE_IOREQ_READY); + assert(req.count == 1); + assert(!req.data_is_ptr); + atomic_add(&buf_page->read_pointer, qw + 1); } -- 1.9.1
WARNING: multiple messages have this Message-ID (diff)
From: Stefano Stabellini <sstabellini@kernel.org> To: stefanha@gmail.com Cc: peter.maydell@linaro.org, sstabellini@kernel.org, Jan Beulich <jbeulich@suse.com>, qemu-devel@nongnu.org, stefanha@redhat.com, anthony.perard@citrix.com, xen-devel@lists.xenproject.org Subject: [PULL 3/4] xen: slightly simplify bufioreq handling Date: Mon, 28 Nov 2016 11:42:25 -0800 [thread overview] Message-ID: <1480362146-14873-3-git-send-email-sstabellini@kernel.org> (raw) In-Reply-To: <1480362146-14873-1-git-send-email-sstabellini@kernel.org> From: Jan Beulich <JBeulich@suse.com> There's no point setting fields always receiving the same value on each iteration, as handle_ioreq() doesn't alter them anyway. Set state and count once ahead of the loop, drop the redundant clearing of data_is_ptr, and avoid the meaningless (because count is 1) setting of df altogether. Also avoid doing an unsigned long calculation of size when the field to be initialized is only 32 bits wide (and the shift value in the range 0...3). Signed-off-by: Jan Beulich <jbeulich@suse.com> Reviewed-by: Paul Durrant <paul.durrant@citrix.com> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org> Signed-off-by: Stefano Stabellini <sstabellini@kernel.org> --- xen-hvm.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/xen-hvm.c b/xen-hvm.c index d74e233..124ae10 100644 --- a/xen-hvm.c +++ b/xen-hvm.c @@ -995,6 +995,8 @@ static int handle_buffered_iopage(XenIOState *state) } memset(&req, 0x00, sizeof(req)); + req.state = STATE_IOREQ_READY; + req.count = 1; for (;;) { uint32_t rdptr = buf_page->read_pointer, wrptr; @@ -1009,15 +1011,11 @@ static int handle_buffered_iopage(XenIOState *state) break; } buf_req = &buf_page->buf_ioreq[rdptr % IOREQ_BUFFER_SLOT_NUM]; - req.size = 1UL << buf_req->size; - req.count = 1; + req.size = 1U << buf_req->size; req.addr = buf_req->addr; req.data = buf_req->data; - req.state = STATE_IOREQ_READY; req.dir = buf_req->dir; - req.df = 1; req.type = buf_req->type; - req.data_is_ptr = 0; xen_rmb(); qw = (req.size == 8); if (qw) { @@ -1032,6 +1030,13 @@ static int handle_buffered_iopage(XenIOState *state) handle_ioreq(state, &req); + /* Only req.data may get updated by handle_ioreq(), albeit even that + * should not happen as such data would never make it to the guest. + */ + assert(req.state == STATE_IOREQ_READY); + assert(req.count == 1); + assert(!req.data_is_ptr); + atomic_add(&buf_page->read_pointer, qw + 1); } -- 1.9.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-11-28 19:42 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2016-11-28 19:42 [Qemu-devel] [PULL for-2.8 0/4] tags/xen-20161128-tag Stefano Stabellini 2016-11-28 19:42 ` [Qemu-devel] [PULL 1/4] xen_disk: split discard input to match internal representation Stefano Stabellini 2016-11-28 19:42 ` Stefano Stabellini 2016-11-28 19:42 ` [Qemu-devel] [PULL 2/4] xen: fix quad word bufioreq handling Stefano Stabellini 2016-11-28 19:42 ` Stefano Stabellini 2016-11-28 19:42 ` Stefano Stabellini [this message] 2016-11-28 19:42 ` [PULL 3/4] xen: slightly simplify " Stefano Stabellini 2016-11-28 19:42 ` [Qemu-devel] [PULL 4/4] xen: ignore direction in " Stefano Stabellini 2016-11-28 19:42 ` Stefano Stabellini 2016-11-29 9:28 ` [PULL for-2.8 0/4] tags/xen-20161128-tag Stefan Hajnoczi 2016-11-29 9:28 ` [Qemu-devel] " Stefan Hajnoczi
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=1480362146-14873-3-git-send-email-sstabellini@kernel.org \ --to=sstabellini@kernel.org \ --cc=JBeulich@suse.com \ --cc=anthony.perard@citrix.com \ --cc=peter.maydell@linaro.org \ --cc=qemu-devel@nongnu.org \ --cc=stefanha@gmail.com \ --cc=stefanha@redhat.com \ --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.