From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-000f0801.pphosted.com (mx0a-000f0801.pphosted.com [67.231.144.122]) by dpdk.org (Postfix) with ESMTP id 207302C08 for ; Mon, 22 Feb 2016 17:23:21 +0100 (CET) Received: from pps.filterd (m0000542.ppops.net [127.0.0.1]) by mx0a-000f0801.pphosted.com (8.15.0.59/8.15.0.59) with SMTP id u1MGDqsf013182; Mon, 22 Feb 2016 08:23:21 -0800 Received: from brmwp-exmb11.corp.brocade.com ([208.47.132.227]) by mx0a-000f0801.pphosted.com with ESMTP id 216re5vm0v-1 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 22 Feb 2016 08:23:21 -0800 Received: from EMEAWP-EXMB12.corp.brocade.com (172.29.11.86) by BRMWP-EXMB11.corp.brocade.com (172.16.59.77) with Microsoft SMTP Server (TLS) id 15.0.1104.5; Mon, 22 Feb 2016 09:23:17 -0700 Received: from [172.29.197.46] (172.29.197.46) by EMEAWP-EXMB12.corp.brocade.com (172.29.11.86) with Microsoft SMTP Server (TLS) id 15.0.1104.5; Mon, 22 Feb 2016 17:23:13 +0100 To: Kyle Larose , "Xie, Huawei" References: <1447407013-6986-1-git-send-email-tkiely@brocade.com> <567299E9.60000@brocade.com> From: Tom Kiely Message-ID: <56CB35E9.50309@brocade.com> Date: Mon, 22 Feb 2016 16:23:05 +0000 User-Agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [172.29.197.46] X-ClientProxiedBy: hq1wp-excas14.corp.brocade.com (10.70.38.103) To EMEAWP-EXMB12.corp.brocade.com (172.29.11.86) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-02-22_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=2 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1601100000 definitions=main-1602220183 Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] [PATCH] virtio: fix rx ring descriptor starvation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Feb 2016 16:23:22 -0000 Hi, Sorry I missed the last few messages until now. I'm happy with just removing the "if". Kyle, when you say you fixed it, do you mean that you will push the patch or have already done so ? Thanks, Tom On 02/18/2016 02:03 PM, Kyle Larose wrote: > On Tue, Jan 5, 2016 at 2:13 AM, Xie, Huawei wrote: >> On 12/17/2015 7:18 PM, Tom Kiely wrote: >>> >>> On 11/25/2015 05:32 PM, Xie, Huawei wrote: >>>> On 11/13/2015 5:33 PM, Tom Kiely wrote: >>>>> If all rx descriptors are processed while transient >>>>> mbuf exhaustion is present, the rx ring ends up with >>>>> no available descriptors. Thus no packets are received >>>>> on that ring. Since descriptor refill is performed post >>>>> rx descriptor processing, in this case no refill is >>>>> ever subsequently performed resulting in permanent rx >>>>> traffic drop. >>>>> >>>>> Signed-off-by: Tom Kiely >>>>> --- >>>>> drivers/net/virtio/virtio_rxtx.c | 6 ++++-- >>>>> 1 file changed, 4 insertions(+), 2 deletions(-) >>>>> >>>>> diff --git a/drivers/net/virtio/virtio_rxtx.c >>>>> b/drivers/net/virtio/virtio_rxtx.c >>>>> index 5770fa2..a95e234 100644 >>>>> --- a/drivers/net/virtio/virtio_rxtx.c >>>>> +++ b/drivers/net/virtio/virtio_rxtx.c >>>>> @@ -586,7 +586,8 @@ virtio_recv_pkts(void *rx_queue, struct rte_mbuf >>>>> **rx_pkts, uint16_t nb_pkts) >>>>> if (likely(num > DESC_PER_CACHELINE)) >>>>> num = num - ((rxvq->vq_used_cons_idx + num) % >>>>> DESC_PER_CACHELINE); >>>>> - if (num == 0) >>>>> + /* Refill free descriptors even if no pkts recvd */ >>>>> + if (num == 0 && virtqueue_full(rxvq)) >>>> Should the return condition be that no used buffers and we have avail >>>> descs in avail ring, i.e, >>>> num == 0 && rxvq->vq_free_cnt != rxvq->vq_nentries >>>> >>>> rather than >>>> num == 0 && rxvq->vq_free_cnt == 0 >>> Yes we could do that but I don't see a good reason to wait until the >>> vq_free_cnt == vq_nentries >>> before attempting the refill. The existing code will attempt refill >>> even if only 1 packet was received >>> and the free count is small. To me it seems safer to extend that to >>> try refill even if no packet was received >>> but the free count is non-zero. >> The existing code attempt to refill only if 1 packet was received. >> >> If we want to refill even no packet was received, then the strict >> condition should be >> num == 0 && rxvq->vq_free_cnt != rxvq->vq_nentries >> >> The safer condition, what you want to use, should be >> num == 0 && !virtqueue_full(...) >> rather than >> num == 0 && virtqueue_full(...) >> >> We could simplify things a bit, just remove this check, if the following >> receiving code already takes care of the "num == 0" condition. >> > FWIW, I fixed this issue myself by just removing the if(num == 0) > checks entirely. I didn't see any benefit in short-circuiting a loop > which pretty much does nothing anyway when num == 0. Further, we only > hit this case when there's no packets to receive, which means there's > probably a few cycles to spare. This is even simpler. > >> I find virtqueue_full is confusing, maybe we could change it to some >> other meaningful name. >> >>> Tom >>> >>>>> return 0; >>>>> num = virtqueue_dequeue_burst_rx(rxvq, rcv_pkts, len, num); >>>>> @@ -683,7 +684,8 @@ virtio_recv_mergeable_pkts(void *rx_queue, >>>>> virtio_rmb(); >>>>> - if (nb_used == 0) >>>>> + /* Refill free descriptors even if no pkts recvd */ >>>>> + if (nb_used == 0 && virtqueue_full(rxvq)) >>>>> return 0; >>>>> PMD_RX_LOG(DEBUG, "used:%d\n", nb_used); >>>