Received: by 10.192.165.156 with SMTP id m28csp1349939imm; Mon, 16 Apr 2018 19:56:17 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/jvHP8URYsmbril0sKQx2RalOyLf7bxyHxgbxvmw89nVLnJnSltjAa9xp/n+yIQNc5Hvgi X-Received: by 10.101.101.207 with SMTP id y15mr305779pgv.84.1523933777250; Mon, 16 Apr 2018 19:56:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523933777; cv=none; d=google.com; s=arc-20160816; b=WtAOgcFN9oFsfHhWtCF7RECNAiO6jv4RKDP8L0PCqQ/eoPjrVT/ADlpdeV4uhDdcsT GxkmKAQPwpfbYnxWMMnRB8evcs44KnH+WGzlsoIRU/ba0unDGetZdZ6396Jn+rzerk+h SRqyiLfZGGRovX9KvvnFO/6ceRC2LJvLD7jR8XFx3XmqJSW119ubkY6VJxpqEr37EtaK 0wOzAS93FYX9D91Sh9jp7eCptDYuhciMrntf7SN7jc15DcT7kUFirbEVT7sS/oAOKOFJ AT5BV9B0PF2JGXK6lHoX1cBR/rls/HRZgCR49zYVx6uef1+YMVdzjIFM4WkTq5Vtb1nB 1uFw== 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=xy1tVZD9SSF1jbE/WLmWUGeWSlfDdoUB0rfuJ8Re5yU=; b=izilCyB4GPsbeCysYobPuKKnY2INSVgD2c/XhbOXw67p0dcIWgwhi8eUBotsCm9Bbc xFd6G0u+CAb3L1ULudEdH3oOEQOd6TckNfiwLIR7hqD0NuApqZaguNllEtZDkM+FfnvT d7n8BIQK0TkBy7aj7Ev5/L2vX32lPbUekpWZcp9oiepgI9Vs1xQ6v2pDqzOqeRYAiqus 2MtCG1Oq76K0OW8/SmVdQxrhmdD3Uwb0yzEG6r+yCb1a1xc2X+ZB1m7HBWe/Dhs5mkyO c9sWirfY5w6r7NFQq2j9DbTSUdFI43jvZuWE4dF4W/9zVHoLOByqR3T7xjKIqgBA1JCC TYRQ== 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 j4si10541603pgq.54.2018.04.16.19.55.51; Mon, 16 Apr 2018 19:56: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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751980AbeDQCyG (ORCPT + 99 others); Mon, 16 Apr 2018 22:54:06 -0400 Received: from mga11.intel.com ([192.55.52.93]:63374 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751086AbeDQCyF (ORCPT ); Mon, 16 Apr 2018 22:54:05 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Apr 2018 19:53:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,461,1517904000"; d="scan'208";a="217122779" Received: from debian.sh.intel.com (HELO debian) ([10.67.104.164]) by orsmga005.jf.intel.com with ESMTP; 16 Apr 2018 19:53:36 -0700 Date: Tue, 17 Apr 2018 10:51:33 +0800 From: Tiwei Bie To: Jason Wang Cc: mst@redhat.com, wexu@redhat.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, jfreimann@redhat.com Subject: Re: [RFC v2] virtio: support packed ring Message-ID: <20180417025133.7t7exmizgolr565z@debian> References: <20180401141216.8969-1-tiwei.bie@intel.com> <20180413071529.f4esh654dakodf4f@debian> <8dee7d62-ac0b-54ba-6bec-4bc4a6fb34e9@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <8dee7d62-ac0b-54ba-6bec-4bc4a6fb34e9@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 Tue, Apr 17, 2018 at 10:11:58AM +0800, Jason Wang wrote: > On 2018年04月13日 15:15, Tiwei Bie wrote: > > On Fri, Apr 13, 2018 at 12:30:24PM +0800, Jason Wang wrote: > > > On 2018年04月01日 22:12, Tiwei Bie wrote: [...] > > > > +static int detach_buf_packed(struct vring_virtqueue *vq, unsigned int head, > > > > + void **ctx) > > > > +{ > > > > + struct vring_packed_desc *desc; > > > > + unsigned int i, j; > > > > + > > > > + /* Clear data ptr. */ > > > > + vq->desc_state[head].data = NULL; > > > > + > > > > + i = head; > > > > + > > > > + for (j = 0; j < vq->desc_state[head].num; j++) { > > > > + desc = &vq->vring_packed.desc[i]; > > > > + vring_unmap_one_packed(vq, desc); > > > > + desc->flags = 0x0; > > > Looks like this is unnecessary. > > It's safer to zero it. If we don't zero it, after we > > call virtqueue_detach_unused_buf_packed() which calls > > this function, the desc is still available to the > > device. > > Well detach_unused_buf_packed() should be called after device is stopped, > otherwise even if you try to clear, there will still be a window that device > may use it. This is not about whether the device has been stopped or not. We don't have other places to re-initialize the ring descriptors and wrap_counter. So they need to be set to the correct values when doing detach_unused_buf. Best regards, Tiwei Bie