Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1825040imm; Tue, 22 May 2018 09:55:28 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq1L0QgtEvPLl/a1i36D//WL/fG93IYS/20dazoeKr36MVbXXsR+zM7L9ZV/nqBBg7B8jXX X-Received: by 2002:a17:902:265:: with SMTP id 92-v6mr24891631plc.368.1527008128493; Tue, 22 May 2018 09:55:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527008128; cv=none; d=google.com; s=arc-20160816; b=X4eCrUe6piZg2CaCsp+exg9eGuZt/TZns2TPcq0zXigpwJUIBOvjnQ7hUx0J173Y8K vtC5nJqeQd4aY03F4YirWGbyMA/nnKadj+yjhtahY4v2AZMyOxbZn5YNIG7/nJjkEmJ0 QifBRk+1AjvxI7YF9AIyfBLCCwFYBZS8AezqR7hbW8mpijUsB4WKJVoEtX2OZqU3wGT0 EdTPSgJeL6Rir6dImkIRkKoXuR7JZOmffQOJ2YjddUxWCtkcyzR6sZqJwK3ob6RRiXtX wSgr7gnxqKgkiddlVwUYonC2JPlfTt63KxxZrPNovqWC/EQlHmoyieq2xdvB7Mi2WEph T8mw== 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-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=bh9/OmgqyhZu7pksgX48WkTyaqbYiGzCt/u+Vq7idX8=; b=MD6fL2eKhrAaK8KvWKrXh4tXLxBZSO5joztXTRgLmZZ9dsqyOsoO6X2+rDxqRgFNsL uP9GB001l0fajBN2OcPhj+qzcALtSaag4OuQD6lo4N6Rr2cUkW8Ga6v4JC2ZtX9nPt0S PbEyFxjHyzGarUwd67kFvxlA2+DfkZZRVp68F5Pd4+6ZWJ6krMy11BL1ckjOf1TBWPx4 8JnT33pADopjxAVetk4n7E2A+TJZD29F61GhgNtedlO37jEHleoLNpSfFmvPKSiWuhdl bp1nDUZA7crP3vM/jjnptMJz/guk5Q7zgcigRj7ihi3jGr/4rEsA4mjQi/9tCyA4RYeG Jrig== 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 x28-v6si17149786pfa.37.2018.05.22.09.55.12; Tue, 22 May 2018 09:55:28 -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 S1751439AbeEVQy5 (ORCPT + 99 others); Tue, 22 May 2018 12:54:57 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:37446 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751229AbeEVQyz (ORCPT ); Tue, 22 May 2018 12:54:55 -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 DBD728A9EC; Tue, 22 May 2018 16:54:54 +0000 (UTC) Received: from wei-ubt (dhcp-14-122.nay.redhat.com [10.66.14.122]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EA446200BCB4; Tue, 22 May 2018 16:54:51 +0000 (UTC) Date: Wed, 23 May 2018 00:54:48 +0800 From: Wei Xu To: Jason Wang 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 Subject: Re: [RFC V4 PATCH 7/8] vhost: packed ring support Message-ID: <20180522165448.GA13523@wei-ubt> References: <1526473941-16199-1-git-send-email-jasowang@redhat.com> <1526473941-16199-8-git-send-email-jasowang@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1526473941-16199-8-git-send-email-jasowang@redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) 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.2]); Tue, 22 May 2018 16:54:54 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 22 May 2018 16:54:54 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'wexu@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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