qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2] vhost-user: pass message as a pointer to process_message_reply()
@ 2017-05-24  9:05 Maxime Coquelin
  2017-05-24  9:09 ` Marc-André Lureau
  2017-05-24 21:58 ` Michael S. Tsirkin
  0 siblings, 2 replies; 5+ messages in thread
From: Maxime Coquelin @ 2017-05-24  9:05 UTC (permalink / raw)
  To: zhiyong.yang, mst, qemu-devel, jfreiman, marcandre.lureau; +Cc: Maxime Coquelin

process_message_reply() was recently updated to get full message
content instead of only its request field.

There is no need to copy all the struct content into the stack,
so just pass its pointer as const.

Cc: Zhiyong Yang <zhiyong.yang@intel.com>
Fixes: 60cd11024f41 ("hw/virtio: fix vhost user fails to startup when MQ")
Reviewed-by: Jens Freimann <jfreiman@redhat.com>
Reviewed-by: Zhiyong Yang <zhiyong.yang@intel.com>
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
V2:
 - Make msg pointer const (Marc-Andre)
 - Apply R-b's

 hw/virtio/vhost-user.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index b87a176..dde094a 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -162,11 +162,11 @@ fail:
 }
 
 static int process_message_reply(struct vhost_dev *dev,
-                                 VhostUserMsg msg)
+                                 const VhostUserMsg *msg)
 {
     VhostUserMsg msg_reply;
 
-    if ((msg.flags & VHOST_USER_NEED_REPLY_MASK) == 0) {
+    if ((msg->flags & VHOST_USER_NEED_REPLY_MASK) == 0) {
         return 0;
     }
 
@@ -174,10 +174,10 @@ static int process_message_reply(struct vhost_dev *dev,
         return -1;
     }
 
-    if (msg_reply.request != msg.request) {
+    if (msg_reply.request != msg->request) {
         error_report("Received unexpected msg type."
                      "Expected %d received %d",
-                     msg.request, msg_reply.request);
+                     msg->request, msg_reply.request);
         return -1;
     }
 
@@ -324,7 +324,7 @@ static int vhost_user_set_mem_table(struct vhost_dev *dev,
     }
 
     if (reply_supported) {
-        return process_message_reply(dev, msg);
+        return process_message_reply(dev, &msg);
     }
 
     return 0;
@@ -716,7 +716,7 @@ static int vhost_user_net_set_mtu(struct vhost_dev *dev, uint16_t mtu)
 
     /* If reply_ack supported, slave has to ack specified MTU is valid */
     if (reply_supported) {
-        return process_message_reply(dev, msg);
+        return process_message_reply(dev, &msg);
     }
 
     return 0;
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH v2] vhost-user: pass message as a pointer to process_message_reply()
  2017-05-24  9:05 [Qemu-devel] [PATCH v2] vhost-user: pass message as a pointer to process_message_reply() Maxime Coquelin
@ 2017-05-24  9:09 ` Marc-André Lureau
  2017-05-24 21:58 ` Michael S. Tsirkin
  1 sibling, 0 replies; 5+ messages in thread
From: Marc-André Lureau @ 2017-05-24  9:09 UTC (permalink / raw)
  To: Maxime Coquelin, zhiyong.yang, mst, qemu-devel, jfreiman

Hi

On Wed, May 24, 2017 at 1:06 PM Maxime Coquelin <maxime.coquelin@redhat.com>
wrote:

> process_message_reply() was recently updated to get full message
> content instead of only its request field.
>
> There is no need to copy all the struct content into the stack,
> so just pass its pointer as const.
>
> Cc: Zhiyong Yang <zhiyong.yang@intel.com>
> Fixes: 60cd11024f41 ("hw/virtio: fix vhost user fails to startup when MQ")
> Reviewed-by: Jens Freimann <jfreiman@redhat.com>
> Reviewed-by: Zhiyong Yang <zhiyong.yang@intel.com>
> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


> ---
> V2:
>  - Make msg pointer const (Marc-Andre)
>  - Apply R-b's
>
>  hw/virtio/vhost-user.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
> index b87a176..dde094a 100644
> --- a/hw/virtio/vhost-user.c
> +++ b/hw/virtio/vhost-user.c
> @@ -162,11 +162,11 @@ fail:
>  }
>
>  static int process_message_reply(struct vhost_dev *dev,
> -                                 VhostUserMsg msg)
> +                                 const VhostUserMsg *msg)
>  {
>      VhostUserMsg msg_reply;
>
> -    if ((msg.flags & VHOST_USER_NEED_REPLY_MASK) == 0) {
> +    if ((msg->flags & VHOST_USER_NEED_REPLY_MASK) == 0) {
>          return 0;
>      }
>
> @@ -174,10 +174,10 @@ static int process_message_reply(struct vhost_dev
> *dev,
>          return -1;
>      }
>
> -    if (msg_reply.request != msg.request) {
> +    if (msg_reply.request != msg->request) {
>          error_report("Received unexpected msg type."
>                       "Expected %d received %d",
> -                     msg.request, msg_reply.request);
> +                     msg->request, msg_reply.request);
>          return -1;
>      }
>
> @@ -324,7 +324,7 @@ static int vhost_user_set_mem_table(struct vhost_dev
> *dev,
>      }
>
>      if (reply_supported) {
> -        return process_message_reply(dev, msg);
> +        return process_message_reply(dev, &msg);
>      }
>
>      return 0;
> @@ -716,7 +716,7 @@ static int vhost_user_net_set_mtu(struct vhost_dev
> *dev, uint16_t mtu)
>
>      /* If reply_ack supported, slave has to ack specified MTU is valid */
>      if (reply_supported) {
> -        return process_message_reply(dev, msg);
> +        return process_message_reply(dev, &msg);
>      }
>
>      return 0;
> --
> 2.9.4
>
>
> --
Marc-André Lureau

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH v2] vhost-user: pass message as a pointer to process_message_reply()
  2017-05-24  9:05 [Qemu-devel] [PATCH v2] vhost-user: pass message as a pointer to process_message_reply() Maxime Coquelin
  2017-05-24  9:09 ` Marc-André Lureau
@ 2017-05-24 21:58 ` Michael S. Tsirkin
  2017-05-25 15:57   ` Maxime Coquelin
  1 sibling, 1 reply; 5+ messages in thread
From: Michael S. Tsirkin @ 2017-05-24 21:58 UTC (permalink / raw)
  To: Maxime Coquelin; +Cc: zhiyong.yang, qemu-devel, jfreiman, marcandre.lureau

On Wed, May 24, 2017 at 11:05:20AM +0200, Maxime Coquelin wrote:
> process_message_reply() was recently updated to get full message
> content instead of only its request field.
> 
> There is no need to copy all the struct content into the stack,
> so just pass its pointer as const.
> 
> Cc: Zhiyong Yang <zhiyong.yang@intel.com>
> Fixes: 60cd11024f41 ("hw/virtio: fix vhost user fails to startup when MQ")
> Reviewed-by: Jens Freimann <jfreiman@redhat.com>
> Reviewed-by: Zhiyong Yang <zhiyong.yang@intel.com>
> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Why "Fixes"? It's not a bugfix, is it? Passing a pointer is
slightly cleaner but it's not a big deal IMHO. I'll apply
but would like to get clarification on this tag.

> ---
> V2:
>  - Make msg pointer const (Marc-Andre)
>  - Apply R-b's
> 
>  hw/virtio/vhost-user.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
> index b87a176..dde094a 100644
> --- a/hw/virtio/vhost-user.c
> +++ b/hw/virtio/vhost-user.c
> @@ -162,11 +162,11 @@ fail:
>  }
>  
>  static int process_message_reply(struct vhost_dev *dev,
> -                                 VhostUserMsg msg)
> +                                 const VhostUserMsg *msg)
>  {
>      VhostUserMsg msg_reply;
>  
> -    if ((msg.flags & VHOST_USER_NEED_REPLY_MASK) == 0) {
> +    if ((msg->flags & VHOST_USER_NEED_REPLY_MASK) == 0) {
>          return 0;
>      }
>  
> @@ -174,10 +174,10 @@ static int process_message_reply(struct vhost_dev *dev,
>          return -1;
>      }
>  
> -    if (msg_reply.request != msg.request) {
> +    if (msg_reply.request != msg->request) {
>          error_report("Received unexpected msg type."
>                       "Expected %d received %d",
> -                     msg.request, msg_reply.request);
> +                     msg->request, msg_reply.request);
>          return -1;
>      }
>  
> @@ -324,7 +324,7 @@ static int vhost_user_set_mem_table(struct vhost_dev *dev,
>      }
>  
>      if (reply_supported) {
> -        return process_message_reply(dev, msg);
> +        return process_message_reply(dev, &msg);
>      }
>  
>      return 0;
> @@ -716,7 +716,7 @@ static int vhost_user_net_set_mtu(struct vhost_dev *dev, uint16_t mtu)
>  
>      /* If reply_ack supported, slave has to ack specified MTU is valid */
>      if (reply_supported) {
> -        return process_message_reply(dev, msg);
> +        return process_message_reply(dev, &msg);
>      }
>  
>      return 0;
> -- 
> 2.9.4

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH v2] vhost-user: pass message as a pointer to process_message_reply()
  2017-05-24 21:58 ` Michael S. Tsirkin
@ 2017-05-25 15:57   ` Maxime Coquelin
  2017-05-25 17:21     ` Michael S. Tsirkin
  0 siblings, 1 reply; 5+ messages in thread
From: Maxime Coquelin @ 2017-05-25 15:57 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: zhiyong.yang, qemu-devel, jfreiman, marcandre.lureau



On 05/24/2017 11:58 PM, Michael S. Tsirkin wrote:
> On Wed, May 24, 2017 at 11:05:20AM +0200, Maxime Coquelin wrote:
>> process_message_reply() was recently updated to get full message
>> content instead of only its request field.
>>
>> There is no need to copy all the struct content into the stack,
>> so just pass its pointer as const.
>>
>> Cc: Zhiyong Yang <zhiyong.yang@intel.com>
>> Fixes: 60cd11024f41 ("hw/virtio: fix vhost user fails to startup when MQ")
>> Reviewed-by: Jens Freimann <jfreiman@redhat.com>
>> Reviewed-by: Zhiyong Yang <zhiyong.yang@intel.com>
>> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> 
> Why "Fixes"? It's not a bugfix, is it? Passing a pointer is
> slightly cleaner but it's not a big deal IMHO. I'll apply
> but would like to get clarification on this tag.

Right, this is not a bug fix.
I noticed this while rebasing my Vhost-user IOMMU series,
which will call this function much more often than currently.
That said, I haven't done any measurements, and I don't believe it
will have a noticeable impact.

Feel free to remove the "Fixes:" line when applying, or I can resend
if you prefer.

Maxime

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH v2] vhost-user: pass message as a pointer to process_message_reply()
  2017-05-25 15:57   ` Maxime Coquelin
@ 2017-05-25 17:21     ` Michael S. Tsirkin
  0 siblings, 0 replies; 5+ messages in thread
From: Michael S. Tsirkin @ 2017-05-25 17:21 UTC (permalink / raw)
  To: Maxime Coquelin; +Cc: zhiyong.yang, qemu-devel, jfreiman, marcandre.lureau

On Thu, May 25, 2017 at 05:57:43PM +0200, Maxime Coquelin wrote:
> 
> 
> On 05/24/2017 11:58 PM, Michael S. Tsirkin wrote:
> > On Wed, May 24, 2017 at 11:05:20AM +0200, Maxime Coquelin wrote:
> > > process_message_reply() was recently updated to get full message
> > > content instead of only its request field.
> > > 
> > > There is no need to copy all the struct content into the stack,
> > > so just pass its pointer as const.
> > > 
> > > Cc: Zhiyong Yang <zhiyong.yang@intel.com>
> > > Fixes: 60cd11024f41 ("hw/virtio: fix vhost user fails to startup when MQ")
> > > Reviewed-by: Jens Freimann <jfreiman@redhat.com>
> > > Reviewed-by: Zhiyong Yang <zhiyong.yang@intel.com>
> > > Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> > 
> > Why "Fixes"? It's not a bugfix, is it? Passing a pointer is
> > slightly cleaner but it's not a big deal IMHO. I'll apply
> > but would like to get clarification on this tag.
> 
> Right, this is not a bug fix.
> I noticed this while rebasing my Vhost-user IOMMU series,
> which will call this function much more often than currently.
> That said, I haven't done any measurements, and I don't believe it
> will have a noticeable impact.
> 
> Feel free to remove the "Fixes:" line when applying, or I can resend
> if you prefer.
> 
> Maxime

Applied no need to resend.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-05-25 17:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-24  9:05 [Qemu-devel] [PATCH v2] vhost-user: pass message as a pointer to process_message_reply() Maxime Coquelin
2017-05-24  9:09 ` Marc-André Lureau
2017-05-24 21:58 ` Michael S. Tsirkin
2017-05-25 15:57   ` Maxime Coquelin
2017-05-25 17:21     ` Michael S. Tsirkin

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).