Received: by 10.192.165.148 with SMTP id m20csp873756imm; Thu, 10 May 2018 01:57:14 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo2GhQw4Jv5OF6qIOpZHMDwjH5ROq2QKKTf3gSNaFwuUeOuUYIcK+e65O26XrfB3Mgy+eah X-Received: by 2002:a62:2043:: with SMTP id g64-v6mr575074pfg.12.1525942634611; Thu, 10 May 2018 01:57:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525942634; cv=none; d=google.com; s=arc-20160816; b=t6ZfHAEbWquo+M9JhmM9ueCD4wvzjuJglT6xpiOzyyd/XsLAV2QzOXLlKDMscBKHGP yiQpOG4/ZAVJerYvxGnD0OYiBbtyBm5Pto83u/3kM8bzxllCd/HSa5pOXhU4hkDIarsU uvjbzw4qBDzNkJNTajEBzQOkCsVmKDYYMkTCgcp5czxUnU+EVwZ0CgIxtQgD5/6YltsV cFoyjUiyQJgLnmhHETm821elNFq5ldiFep1AhjV9dASwxfas8UURUwfb9JAGptU+AEw0 ZzQSHbYe6F9Zuasdwb/HR3j+Nolye8UjVoPUd80EW4Q264dPtPl3djBd/+Yv+TY74Bg3 sp5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=ixGAWZv68CxiWIoD08b0Kc4h28/gv939oaLK5l6q9v0=; b=FFYkVJVQwu8/LBfqwdPH1Dvv5ur6aEkzAWVvdOTtvMTm/dw941hnhtlqZ6z8Z2Lb+e phD0favV2DxXujc5jOBNsONFyVMOQfMZtE2g7ulo9lR5QEuhBAbMNQUXv3Q7/wh/+B7f +oP6d95uJJvCLjwjzb42B3BvpcnrvxgB6ddVKncq4huUJIo9EENvDlr4e0aWn0CdAOZ4 zK84iyQt5pcE50sGnb0Rm1Abz5Tx9n5megHpWEzHrSBZKBXFRKeVOPSJTIwEPVFNXFW3 OhGqj5u7OWlvQHXz9oM+b/DETfNWCqhxVK8W/lD+auvR0QmUt1roBPNnhjBrWV4DnArK IcPg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l4-v6si323540plt.258.2018.05.10.01.57.00; Thu, 10 May 2018 01:57:14 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756966AbeEJIzc (ORCPT + 99 others); Thu, 10 May 2018 04:55:32 -0400 Received: from mga18.intel.com ([134.134.136.126]:4916 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756676AbeEJIza (ORCPT ); Thu, 10 May 2018 04:55:30 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 May 2018 01:55:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,384,1520924400"; d="scan'208";a="57461983" Received: from debian.sh.intel.com (HELO debian) ([10.67.104.164]) by orsmga002.jf.intel.com with ESMTP; 10 May 2018 01:55:28 -0700 Date: Thu, 10 May 2018 16:56:01 +0800 From: Tiwei Bie To: Jason Wang Cc: mst@redhat.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, wexu@redhat.com Subject: Re: [RFC v3 3/5] virtio_ring: add packed ring support Message-ID: <20180510085601.6mpxf3yvwxnqnk5q@debian> References: <20180425051550.24342-1-tiwei.bie@intel.com> <20180425051550.24342-4-tiwei.bie@intel.com> <927f4478-5a81-31d4-ac69-f9ec26248591@redhat.com> <5885acac-e9e3-3abf-b6a2-7347f4d55be2@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <5885acac-e9e3-3abf-b6a2-7347f4d55be2@redhat.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 10, 2018 at 03:34:50PM +0800, Jason Wang wrote: > On 2018年05月10日 15:32, Jason Wang wrote: > > 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 > > next_avail should be 6 here. > > > > > c) id = 4,count = 2,next_avail = 0 > > > > id should be 6 here. > > Thanks > > > 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 Nice catch! Thanks a lot! I'll implement an ID allocator. Best regards, Tiwei Bie