Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757842AbcLADPH (ORCPT ); Wed, 30 Nov 2016 22:15:07 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37396 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753741AbcLADPG (ORCPT ); Wed, 30 Nov 2016 22:15:06 -0500 Subject: Re: [PATCH net] vhost_net: don't continue to call the recvmsg when meet errors To: "Michael S. Tsirkin" , Yunjian Wang References: <1480507857-22976-1-git-send-email-wangyunjian@huawei.com> <20161130152004-mutt-send-email-mst@kernel.org> Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, caihe@huawei.com From: Jason Wang Message-ID: Date: Thu, 1 Dec 2016 11:15:00 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20161130152004-mutt-send-email-mst@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 01 Dec 2016 03:15:05 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1172 Lines: 38 On 2016年11月30日 21:40, Michael S. Tsirkin wrote: > On Wed, Nov 30, 2016 at 08:10:57PM +0800, Yunjian Wang wrote: >> When we meet an error(err=-EBADFD) recvmsg, > How do you get EBADFD? Won't vhost_net_rx_peek_head_len > return 0 in this case, breaking the loop? > >> the error handling in vhost >> handle_rx() will continue. This will cause a soft CPU lockup in vhost thread. >> >> Signed-off-by: Yunjian Wang >> --- >> drivers/vhost/net.c | 3 +++ >> 1 file changed, 3 insertions(+) >> >> diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c >> index 5dc128a..edc470b 100644 >> --- a/drivers/vhost/net.c >> +++ b/drivers/vhost/net.c >> @@ -717,6 +717,9 @@ static void handle_rx(struct vhost_net *net) >> pr_debug("Discarded rx packet: " >> " len %d, expected %zd\n", err, sock_len); >> vhost_discard_vq_desc(vq, headcount); >> + /* Don't continue to do, when meet errors. */ >> + if (err < 0) >> + goto out; > You might get e.g. EAGAIN and I think you need to retry > in this case. Yes. >> continue; >> } >> /* Supply virtio_net_hdr if VHOST_NET_F_VIRTIO_NET_HDR */ >> -- >> 1.9.5.msysgit.1 >>