Hi Andy,

> -----Original Message-----
> From: Pei, Andy <[email protected]>
> Sent: Monday, July 11, 2022 5:03 PM
> To: Xia, Chenbo <[email protected]>; Maxime Coquelin
> <[email protected]>; Ma, WenwuX <[email protected]>;
> [email protected]
> Cc: Hu, Jiayu <[email protected]>; Wang, Yinan <[email protected]>; He,
> Xingguang <[email protected]>; [email protected]
> Subject: RE: [PATCH v3] vhost: fix deadlock when message handling failed
> 
> HI Chenbo,
> 
> See below example
> 
> 1.
>       ret = read_vhost_message(dev, fd, &ctx);
>       if (ret <= 0) {
>               if (ret < 0)
>                       VHOST_LOG_CONFIG(dev->ifname, ERR, "vhost read message
> failed\n");
>               else
>                       VHOST_LOG_CONFIG(dev->ifname, INFO, "vhost peer
> closed\n");
> 
>               return -1;
>       }
> 
> 2.
>       ret = vhost_user_check_and_alloc_queue_pair(dev, &ctx);
>       if (ret < 0) {
>               VHOST_LOG_CONFIG(dev->ifname, ERR, "failed to alloc queue\n");
>               return -1;
>       }
> 
> 
> 3. ret = -1
>       } else if (ret == RTE_VHOST_MSG_RESULT_ERR) {
>               VHOST_LOG_CONFIG(dev->ifname, ERR, "vhost message handling
> failed.\n");
>               ret = -1;
>               goto unlock;
>       }
> 
> I mean ret is used to check the function is returned successfully or not
> while it is also used to store vhost msg return code like
> "RTE_VHOST_MSG_RESULT_XXX".

It makes sense to make it two, one int for return value, one enum
rte_vhost_msg_result only for message handling. IMHO, this could improve 
readability.

Thanks,
Chenbo

> 
> 
> 
> 
> > -----Original Message-----
> > From: Xia, Chenbo <[email protected]>
> > Sent: Monday, July 11, 2022 4:54 PM
> > To: Pei, Andy <[email protected]>; Maxime Coquelin
> > <[email protected]>; Ma, WenwuX <[email protected]>;
> > [email protected]
> > Cc: Hu, Jiayu <[email protected]>; Wang, Yinan <[email protected]>;
> He,
> > Xingguang <[email protected]>; [email protected]
> > Subject: RE: [PATCH v3] vhost: fix deadlock when message handling failed
> >
> > > -----Original Message-----
> > > From: Pei, Andy <[email protected]>
> > > Sent: Monday, July 11, 2022 4:42 PM
> > > To: Maxime Coquelin <[email protected]>; Ma, WenwuX
> > > <[email protected]>; Xia, Chenbo <[email protected]>;
> > > [email protected]
> > > Cc: Hu, Jiayu <[email protected]>; Wang, Yinan
> > > <[email protected]>; He, Xingguang <[email protected]>;
> > > [email protected]
> > > Subject: RE: [PATCH v3] vhost: fix deadlock when message handling
> > > failed
> > >
> > > HI ALL,
> > >
> > > I see that in function vhost_user_msg_handler.
> > > We use "ret" to store both vhost msg return code like
> > > "RTE_VHOST_MSG_RESULT_XXX" and function return value.
> > > I wonder if it is better to use two different variable to make it easy
> > > to read.
> >
> > By saying 'function return value', you mean which function? Can you
> elaborate
> > more?
> >
> > Thanks,
> > Chenbo
> >
> > >
> > > > -----Original Message-----
> > > > From: Maxime Coquelin <[email protected]>
> > > > Sent: Tuesday, May 17, 2022 9:24 PM
> > > > To: Ma, WenwuX <[email protected]>; Xia, Chenbo
> > > > <[email protected]>; [email protected]
> > > > Cc: Hu, Jiayu <[email protected]>; Wang, Yinan
> > > > <[email protected]>;
> > > He,
> > > > Xingguang <[email protected]>; [email protected]
> > > > Subject: Re: [PATCH v3] vhost: fix deadlock when message handling
> > > > failed
> > > >
> > > >
> > > >
> > > > On 5/7/22 15:27, Wenwu Ma wrote:
> > > > > In vhost_user_msg_handler(), if vhost message handling failed, we
> > > > > should check whether the queue is locked and release the lock
> > > > > before returning. Or, it will cause a deadlock later.
> > > > >
> > > > > Fixes: 7f31d4ea05ca ("vhost: fix lock on device readiness
> > > > > notification")
> > > > > Cc: [email protected]
> > > > >
> > > > > Signed-off-by: Wenwu Ma <[email protected]>
> > > > > ---
> > > > >   lib/vhost/vhost_user.c | 10 ++++++----
> > > > >   1 file changed, 6 insertions(+), 4 deletions(-)
> > > > >
> > > >
> > > > Applied to dpdk-next-virtio/main.
> > > >
> > > > Thanks,
> > > > Maxime

Reply via email to