From patchwork Wed Jul 7 09:55:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 95479 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2AA62A0C4A; Wed, 7 Jul 2021 11:56:05 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 19366406FF; Wed, 7 Jul 2021 11:56:05 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id A5452406B4 for ; Wed, 7 Jul 2021 11:56:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625651763; 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; bh=4ao1TUV+2Bg3HgstHXfY6LgT2vWevzMdgyz8esXvJFE=; b=D3TErk6uv3JJIsDXDiW1M6uc0qyxQzD4C1wZ8bniE3a9cxe6HlgsXQeIVule39GcqWSWLl Lp/UXxoe6ITmqc0XGaAA8J5TliINZB6oq+mI8jStMB4jvbntZ04ocvm4nfrA6hCfCx5eo+ TnkMRvb2rP66mAYS2S25xvcIgQziwwU= 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-460-ytY4zLF4Msmn-TG-uGrixw-1; Wed, 07 Jul 2021 05:56:01 -0400 X-MC-Unique: ytY4zLF4Msmn-TG-uGrixw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DDC343A42; Wed, 7 Jul 2021 09:56:00 +0000 (UTC) Received: from max-t490s.redhat.com (unknown [10.36.110.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3456E60C17; Wed, 7 Jul 2021 09:55:59 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, cheng1.jiang@intel.com, chenbo.xia@intel.com Cc: Maxime Coquelin , stable@dpdk.org Date: Wed, 7 Jul 2021 11:55:57 +0200 Message-Id: <20210707095557.315010-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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 Subject: [dpdk-dev] [PATCH] 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" 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 --- lib/vhost/virtio_net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c index b93482587c..43011b5a2a 100644 --- a/lib/vhost/virtio_net.c +++ b/lib/vhost/virtio_net.c @@ -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; }