From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43439) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c9UE0-00080Z-Hn for qemu-devel@nongnu.org; Wed, 23 Nov 2016 04:52:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c9UDx-00045D-9r for qemu-devel@nongnu.org; Wed, 23 Nov 2016 04:52:20 -0500 Received: from smtp.ctxuk.citrix.com ([185.25.65.24]:50519 helo=SMTP.EU.CITRIX.COM) by eggs.gnu.org with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.71) (envelope-from ) id 1c9UDw-00043s-W3 for qemu-devel@nongnu.org; Wed, 23 Nov 2016 04:52:17 -0500 From: Paul Durrant Date: Wed, 23 Nov 2016 09:51:53 +0000 Message-ID: References: <58356D610200007800121289@prv-mh.provo.novell.com> <58356E680200007800121299@prv-mh.provo.novell.com> In-Reply-To: <58356E680200007800121299@prv-mh.provo.novell.com> Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 2/3] xen: slightly simplify bufioreq handling List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jan Beulich , "qemu-devel@nongnu.org" Cc: Anthony Perard , Stefano Stabellini , xen-devel > -----Original Message----- > From: Jan Beulich [mailto:JBeulich@suse.com] > Sent: 23 November 2016 09:25 > To: qemu-devel@nongnu.org > Cc: Anthony Perard ; Paul Durrant > ; Stefano Stabellini ; x= en- > devel > Subject: [PATCH 2/3] xen: slightly simplify bufioreq handling >=20 > 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 setting of df altogether. >=20 > 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). >=20 > Signed-off-by: Jan Beulich Reviewed-by: Paul Durrant >=20 > --- a/xen-hvm.c > +++ b/xen-hvm.c > @@ -995,6 +995,8 @@ static int handle_buffered_iopage(XenIOS > } >=20 > memset(&req, 0x00, sizeof(req)); > + req.state =3D STATE_IOREQ_READY; > + req.count =3D 1; >=20 > for (;;) { > uint32_t rdptr =3D buf_page->read_pointer, wrptr; > @@ -1009,15 +1011,11 @@ static int handle_buffered_iopage(XenIOS > break; > } > buf_req =3D &buf_page->buf_ioreq[rdptr % IOREQ_BUFFER_SLOT_NUM]; > - req.size =3D 1UL << buf_req->size; > - req.count =3D 1; > + req.size =3D 1U << buf_req->size; > req.addr =3D buf_req->addr; > req.data =3D buf_req->data; > - req.state =3D STATE_IOREQ_READY; > req.dir =3D buf_req->dir; > - req.df =3D 1; > req.type =3D buf_req->type; > - req.data_is_ptr =3D 0; > xen_rmb(); > qw =3D (req.size =3D=3D 8); > if (qw) { > @@ -1032,6 +1030,13 @@ static int handle_buffered_iopage(XenIOS >=20 > handle_ioreq(state, &req); >=20 > + /* Only req.data may get updated by handle_ioreq(), albeit even = that > + * should not happen as such data would never make it to the gue= st. > + */ > + assert(req.state =3D=3D STATE_IOREQ_READY); > + assert(req.count =3D=3D 1); > + assert(!req.data_is_ptr); > + > atomic_add(&buf_page->read_pointer, qw + 1); > } >=20 >=20 >=20