Received: by 10.192.165.148 with SMTP id m20csp815451imm; Thu, 10 May 2018 00:43:18 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqdqiznCIipghWYIMCVqRMwryUpYmH+rVqW0mY5PrPrPQTF1TiSDG44QUH16Qzg8/67veRs X-Received: by 2002:a62:5fc5:: with SMTP id t188-v6mr348380pfb.214.1525938198045; Thu, 10 May 2018 00:43:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525938197; cv=none; d=google.com; s=arc-20160816; b=NfvP8SWrT6DYgCoEpR1YuVFnV4Qso5h4q+J90s+6xOa1W6Kz4ShIZahYBlqsi1Jlcb QFNOKRMCqAXCnQE+CVfI0rDloNIbEujOn0ohlgERtFvEXevMZbCwMRVVoN+IE+xYbv/2 B8+IrzO3qNcg4qGbaNv056IwmJNzBzbBZVUx/KhmDVLd/3uuNAfOZNpqM8/KtxxOfvdT yq+RYSx+XV6Md8ctc0jMer+bDDbfZ/WOwzKLsujaSvudFiTxBvCWiVK76MoVaDWivYEo 9mpvdX1dxGw+3Y3D9BMcAd3Su+nd1vfbDnMalIE+JehZ1Dmukc/5GKykWI7A4XFjz3/W BkdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=k0SGYSJHiEE7qjmxi96xD/PZX+Ugzyx8sd3YC4wWO8g=; b=ayvmfXCd5y3CG3ZmN/0ffN01gn11NV4iE8Krdj7rBfYGCAwzR3/7vPuBWA/CHwA+re hsAo3UngJOxHlLi7rBtHppYcNnXTEG0aNlicbjlZxgs7fPaKNTi79xfIGmEUtki8Jbr3 m3zlL7R28/82KKCwFGjGehcjhL/q3a6wpvIJDrKMaOqQGf7GsqEiqzMc3B04I8Q5tTwg 8CM0DhF0W7VOucLyYwYTa0e+X77GoIXHtgqBWKLjuaxQMnngZ3/9GGcQDS/RwhlzSdD4 Hxx078MQuNdrK4U8qvNu28gTEZzYPsKDfgzSG/m3LJODbcgAP4a9aEys2AqtmGSXCSOn 1K+A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y15-v6si177858pli.354.2018.05.10.00.41.50; Thu, 10 May 2018 00:43:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934608AbeEJHcg (ORCPT + 99 others); Thu, 10 May 2018 03:32:36 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:41918 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934174AbeEJHcf (ORCPT ); Thu, 10 May 2018 03:32:35 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B334E407B3B8; Thu, 10 May 2018 07:32:34 +0000 (UTC) Received: from [10.72.12.162] (ovpn-12-162.pek2.redhat.com [10.72.12.162]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 710AF1DB47; Thu, 10 May 2018 07:32:27 +0000 (UTC) Subject: Re: [RFC v3 3/5] virtio_ring: add packed ring support To: Tiwei Bie , mst@redhat.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: wexu@redhat.com, jfreimann@redhat.com References: <20180425051550.24342-1-tiwei.bie@intel.com> <20180425051550.24342-4-tiwei.bie@intel.com> From: Jason Wang Message-ID: <927f4478-5a81-31d4-ac69-f9ec26248591@redhat.com> Date: Thu, 10 May 2018 15:32:19 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180425051550.24342-4-tiwei.bie@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 10 May 2018 07:32:34 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 10 May 2018 07:32:34 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jasowang@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018年04月25日 13:15, Tiwei Bie wrote: > + /* We're using some buffers from the free list. */ > + vq->vq.num_free -= descs_used; > + > + /* Update free pointer */ > + if (indirect) { > + n = head + 1; > + if (n >= vq->vring_packed.num) { > + n = 0; > + vq->wrap_counter ^= 1; > + } > + vq->next_avail_idx = n; > + } else > + vq->next_avail_idx = i; During testing zerocopy (out of order completion), I found driver may submit two identical buffer id to vhost. So the above code may not work well. Consider the case that driver adds 3 buffer and virtqueue size is 8. a) id = 0,count = 2,next_avail = 2 b) id = 2,count = 4,next_avail = 2 c) id = 4,count = 2,next_avail = 0 if packet b is done before packet a, driver may think buffer id 0 is available and try to use it if even if the real buffer 0 was not done. Thanks