From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0C5A8A0C50; Mon, 12 Jul 2021 11:17:06 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CA5C64069D; Mon, 12 Jul 2021 11:17:05 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mails.dpdk.org (Postfix) with ESMTP id 3F1F540685 for ; Mon, 12 Jul 2021 11:17:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626081423; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LMVi+H/7tSu9E5TwUgIeWQVcBY3BYyDiW3wYTh4SgSw=; b=Nt8WWcxH5aHwfSKLWDfVxqWgJBIO9QZL9AgvicVlDXuv2LrpZ8jWyvoVH3jIN2YIttJ/U4 MKUUnbrhM41J1pS6+KzX4DrV0Dy6kXmyexJfDfr9ao+YeIM3UxeWK8tQRRF/yoVy3TEyu5 HfqxePkYErmpPdp1ZPwArWN2OdjDShI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-537-10mVA7TiNgWmJA8VAk4a2A-1; Mon, 12 Jul 2021 05:17:02 -0400 X-MC-Unique: 10mVA7TiNgWmJA8VAk4a2A-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 59F4D100C609; Mon, 12 Jul 2021 09:17:00 +0000 (UTC) Received: from [10.36.110.39] (unknown [10.36.110.39]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 75C585D9CA; Mon, 12 Jul 2021 09:16:59 +0000 (UTC) To: "Jiang, Cheng1" , "dev@dpdk.org" , "Xia, Chenbo" Cc: "stable@dpdk.org" References: <20210707103004.317886-1-maxime.coquelin@redhat.com> From: Maxime Coquelin Message-ID: <624d37fe-ec60-97d8-e00b-e71661b548e1@redhat.com> Date: Mon, 12 Jul 2021 11:16:57 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=maxime.coquelin@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v2] vhost: fix assuming packed ring size is a power of 2 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi Cheng, Thanks for catching the issue. It was an accident, that I thought I had resolved already :) This is fixed now. Maxime On 7/12/21 8:53 AM, Jiang, Cheng1 wrote: > Hi Maxime, > > I have noticed you changed the state this patch to Superseded. > So are you going to submit a new version of this patch? > > Thanks, > Cheng > >> -----Original Message----- >> From: Jiang, Cheng1 >> Sent: Wednesday, July 7, 2021 7:11 PM >> To: Maxime Coquelin ; dev@dpdk.org; Xia, >> Chenbo >> Cc: stable@dpdk.org >> Subject: RE: [PATCH v2] vhost: fix assuming packed ring size is a power of 2 >> >> Hi Maxime, >> >> I have also noticed the wrong calculation here, thanks for the timely help. >> >> Thanks, >> Cheng >> >>> -----Original Message----- >>> From: Maxime Coquelin >>> Sent: Wednesday, July 7, 2021 6:30 PM >>> To: dev@dpdk.org; Jiang, Cheng1 ; Xia, Chenbo >>> >>> Cc: Maxime Coquelin ; stable@dpdk.org >>> Subject: [PATCH v2] vhost: fix assuming packed ring size is a power of >>> 2 >>> >>> Unlike split ring, packed ring does not mandate the ring size to be a >>> power of 2. So we have to use a modulo operation when wrapping ring >> index. >>> >>> Fixes: 873e8dad6f49 ("vhost: support packed ring in async datapath") >>> Cc: stable@dpdk.org >>> >>> Signed-off-by: Maxime Coquelin >>> --- >>> >>> V2: Also fix wrapping in virtio_dev_rx_async_get_info_idx which is >>> used in the packed ring data path. >>> >>> lib/vhost/virtio_net.c | 4 ++-- >>> 1 file changed, 2 insertions(+), 2 deletions(-) >>> >>> diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c index >>> b93482587c..0de5231db7 100644 >>> --- a/lib/vhost/virtio_net.c >>> +++ b/lib/vhost/virtio_net.c >>> @@ -1470,7 +1470,7 @@ virtio_dev_rx_async_get_info_idx(uint16_t >>> pkts_idx, >>> uint16_t vq_size, uint16_t n_inflight) { >>> return pkts_idx > n_inflight ? (pkts_idx - n_inflight) : >>> - (vq_size - n_inflight + pkts_idx) & (vq_size - 1); >>> + (vq_size - n_inflight + pkts_idx) % vq_size; >>> } >>> >>> static __rte_always_inline void >>> @@ -2131,7 +2131,7 @@ uint16_t rte_vhost_poll_enqueue_completed(int >>> vid, uint16_t queue_id, >>> >>> if (vq_is_packed(dev)) { >>> for (i = 0; i < n_pkts_put; i++) { >>> - from = (start_idx + i) & (vq_size - 1); >>> + from = (start_idx + i) % vq_size; >>> n_buffers += pkts_info[from].nr_buffers; >>> pkts[i] = pkts_info[from].mbuf; >>> } >>> -- >>> 2.31.1 >> >> >> Acked-by: Cheng Jiang >