Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp581721imm; Wed, 23 May 2018 02:00:18 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqOw+Y7UZP1uxjYZl87UT+F9zYW9bb7Pwg/5QKDfmkU4xT65kHr0+zBmq30spbBP2/kUOF6 X-Received: by 2002:a17:902:4303:: with SMTP id i3-v6mr2151375pld.394.1527066018290; Wed, 23 May 2018 02:00:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527066018; cv=none; d=google.com; s=arc-20160816; b=c+LOFYYOIAWaIQq3CVgdY6EWZycuwcu15YNHBRYXZZpyUS07bDJmGSX+8jUnaBgKAQ wscHMUs/Q89UF6n+wXbVsTBPICO9pxIojdXuwa8s4sUMRKVCs+BjRJpO46wmuOeUmqRF 3S4t4gu/uQlG0FNZTVuVAEzxObJw8iuddExCsavl86xvlYHYoO6BTQDVVze2h3Dkrsl9 pWf6mykHWcJ6/AFMUMg6Erlvmm8oiAbwRjDXBuX08vFQUfbS4COy+2a8ctchPFPVpl1Z OO3eF5XJK7w07IZVaah+1M2fkN1A2HCovhb05F29xJHYPE84dds+/32ApBZiDY4XMDGj 9MDg== 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=ewbr/DJw/GoOlHS8s6qnfFxnAzJfqGFUnhkV4AuxOEQ=; b=g8UnEJ9kyUAdYaAWytUhGZBSkvr6MkcE4QBYSzLK9t9dt2b2M3pu+gB+5uFyCVPPb3 JKbyE2J+l6I6VkRR7sK3eH7L9EkGK/3brjKpspsCaStSShvPxL3ZJO98Kl1i6pZd9C/L dypVpfd9n95OSlQqivuXQDUu4gwHKPBAkFnSoATH7egIQMl8qGJ9hiq2HiAfKGWy7FFV EyVKmAmYhZjSXF9bK6yudydmDQHv2vmak8xdylzrNNmkjU0M1CDPvN5qG3H9I9pMT1nc FOBQO5jk9DnTYUMnw1uty3b+Ey7y9tGBf3i/L8qM3b27+ujhUUWuUtZ7DIOdoHJVvavC A1/Q== 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 w189-v6si514119pgb.431.2018.05.23.02.00.03; Wed, 23 May 2018 02:00:18 -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 S932118AbeEWI55 (ORCPT + 99 others); Wed, 23 May 2018 04:57:57 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:59140 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754334AbeEWI5y (ORCPT ); Wed, 23 May 2018 04:57:54 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 44365CB9E4; Wed, 23 May 2018 08:57:54 +0000 (UTC) Received: from [10.72.12.62] (ovpn-12-62.pek2.redhat.com [10.72.12.62]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9A4E720244F5; Wed, 23 May 2018 08:57:49 +0000 (UTC) Subject: Re: [RFC V4 PATCH 7/8] vhost: packed ring support To: Wei Xu Cc: mst@redhat.com, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, jfreimann@redhat.com, tiwei.bie@intel.com References: <1526473941-16199-1-git-send-email-jasowang@redhat.com> <1526473941-16199-8-git-send-email-jasowang@redhat.com> <20180522165448.GA13523@wei-ubt> <20180523071727.GA13373@wei-ubt> From: Jason Wang Message-ID: Date: Wed, 23 May 2018 16:57:46 +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: <20180523071727.GA13373@wei-ubt> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Wed, 23 May 2018 08:57:54 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Wed, 23 May 2018 08:57:54 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.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年05月23日 15:17, Wei Xu wrote: > On Wed, May 23, 2018 at 09:39:28AM +0800, Jason Wang wrote: >> >> On 2018年05月23日 00:54, Wei Xu wrote: >>> On Wed, May 16, 2018 at 08:32:20PM +0800, Jason Wang wrote: >>>> Signed-off-by: Jason Wang >>>> --- >>>> drivers/vhost/net.c | 3 +- >>>> drivers/vhost/vhost.c | 539 ++++++++++++++++++++++++++++++++++++++++++++++---- >>>> drivers/vhost/vhost.h | 8 +- >>>> 3 files changed, 513 insertions(+), 37 deletions(-) >>>> >>>> diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c >>>> index 8304c30..f2a0f5b 100644 >>>> --- a/drivers/vhost/vhost.c >>>> +++ b/drivers/vhost/vhost.c >>>> @@ -1358,6 +1382,8 @@ long vhost_vring_ioctl(struct vhost_dev *d, unsigned int ioctl, void __user *arg >>>> break; >>>> } >>>> vq->last_avail_idx = s.num; >>>> + if (vhost_has_feature(vq, VIRTIO_F_RING_PACKED)) >>>> + vq->avail_wrap_counter = s.num >> 31; >>>> /* Forget the cached index value. */ >>>> vq->avail_idx = vq->last_avail_idx; >>>> break; >>>> @@ -1366,6 +1392,8 @@ long vhost_vring_ioctl(struct vhost_dev *d, unsigned int ioctl, void __user *arg >>>> s.num = vq->last_avail_idx; >>>> if (copy_to_user(argp, &s, sizeof s)) >>>> r = -EFAULT; >>>> + if (vhost_has_feature(vq, VIRTIO_F_RING_PACKED)) >>>> + s.num |= vq->avail_wrap_counter << 31; >>>> break; >>>> case VHOST_SET_VRING_ADDR: >>>> if (copy_from_user(&a, argp, sizeof a)) { >>> 'last_used_idx' also needs to be saved/restored here. >>> >>> I have figured out the root cause of broken device after reloading >>> 'virtio-net' module, all indices have been reset for a reloading but >>> 'last_used_idx' is not properly reset in this case. This confuses >>> handle_rx()/tx(). >>> >>> Wei >>> >> Good catch, so we probably need a new ioctl to sync between qemu and vhost. >> >> Something like VHOST_SET/GET_USED_BASE. > Sure, or can we expand 'vhost_vring_state' to keep them done in a bunch? It's port of uapi, so we can't. Thanks > >> Thanks >>