Received: by 10.223.185.116 with SMTP id b49csp4718413wrg; Tue, 27 Feb 2018 01:08:33 -0800 (PST) X-Google-Smtp-Source: AH8x225eLVZ6J5dlvCmbgkLU7ByPgU703AiqRby07KStdjvI0NeatYDS7xCweM/t8yp9xyZZnla5 X-Received: by 10.98.15.137 with SMTP id 9mr13428415pfp.216.1519722513524; Tue, 27 Feb 2018 01:08:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519722513; cv=none; d=google.com; s=arc-20160816; b=0TVS+nYxU2+QDIe8p79lW7WL5x8YDEDCrIc2t1D+CPV6I77WfCFxpAG2uyPYQpvuru A4mnEz9fc86qdP5Aj6SpoMxUKA2FSD8IbEyzsRw8l2IXf0FYec9uBaRAS3GKxs+6g5z9 MDUpk8pdfEUmyAK7kJyFUl5Dln8TcH/kPedhC7Jlhb3ecCr1e/WRFit7jekV4NHguOpZ e5DCc7dPLL3OAFknK/ysSSp86Q8tSe6m6lM7CTH7ADPrBHL8xYoNZ6G8RoDPxhzyvZEq MkbzeBqvXz9hLfXXNJF/vbZsqRugx12ID28aayV3o3UEK3DYCkgmVWjhMmu95vm3+h6J nhUw== 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=dk7lGcxwsvqeUHvyn5h8JzsxJqbQ2rYamjdSX3mkp1c=; b=mg+1k8SiZNg1TgXuZj055T5z/wIsYZIgmlHCV89+YB0MkMkMBxeBWaJAD5Bi+WBA0c Fc8ZLQbV/moiBE/9DSVvClU8vCFKn7hDWssmEJvIDN2YlVqAhNOYFV8kohAGWu8fgQdN WoNb16Za0hC+04PzlRXJo3rLnNjh7TdLf5aF4dd1+f6Thv1kFSw2INZD9SPV8iZAAqeX jnM/9ZQyGbEhYz8xCvl5BQ0QN4cyiTYNnt7YUBYZd0qF+VGWBRfCevUzz6p6wXCvmb+U N+QMaNZlq/6RUp0CCQV4FoosO/AZ0IZ1JAkL+xNNYTs32WqJbFVG0XjnxbOfgu7yNqd2 Y1lQ== 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 m189si8156791pfc.410.2018.02.27.01.08.19; Tue, 27 Feb 2018 01:08:33 -0800 (PST) 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 S1752500AbeB0JE5 (ORCPT + 99 others); Tue, 27 Feb 2018 04:04:57 -0500 Received: from mga09.intel.com ([134.134.136.24]:16376 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752336AbeB0JEz (ORCPT ); Tue, 27 Feb 2018 04:04:55 -0500 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Feb 2018 01:04:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,400,1515484800"; d="scan'208";a="207373257" Received: from debian.sh.intel.com (HELO debian) ([10.67.104.164]) by fmsmga006.fm.intel.com with ESMTP; 27 Feb 2018 01:04:52 -0800 Date: Tue, 27 Feb 2018 17:03:20 +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, jfreimann@redhat.com Subject: Re: [PATCH RFC 2/2] vhost: packed ring support Message-ID: <20180227090319.h7hxmxp5rpozrb5s@debian> References: <1518575829-1431-1-git-send-email-jasowang@redhat.com> <1518575829-1431-3-git-send-email-jasowang@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1518575829-1431-3-git-send-email-jasowang@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 Wed, Feb 14, 2018 at 10:37:09AM +0800, Jason Wang wrote: [...] > +static void set_desc_used(struct vhost_virtqueue *vq, > + struct vring_desc_packed *desc, bool wrap_counter) > +{ > + __virtio16 flags = desc->flags; > + > + if (wrap_counter) { > + desc->flags |= cpu_to_vhost16(vq, DESC_AVAIL); > + desc->flags |= cpu_to_vhost16(vq, DESC_USED); > + } else { > + desc->flags &= ~cpu_to_vhost16(vq, DESC_AVAIL); > + desc->flags &= ~cpu_to_vhost16(vq, DESC_USED); > + } > + > + desc->flags = flags; The `desc->flags` is restored after the change. > +} > + > +static int vhost_get_vq_desc_packed(struct vhost_virtqueue *vq, > + struct iovec iov[], unsigned int iov_size, > + unsigned int *out_num, unsigned int *in_num, > + struct vhost_log *log, > + unsigned int *log_num) > +{ > + struct vring_desc_packed desc; > + int ret, access, i; > + u16 avail_idx = vq->last_avail_idx; > + > + /* When we start there are none of either input nor output. */ > + *out_num = *in_num = 0; > + if (unlikely(log)) > + *log_num = 0; > + > + do { > + unsigned int iov_count = *in_num + *out_num; > + > + i = vq->last_avail_idx & (vq->num - 1); The queue size may not be a power of 2 in packed ring. Best regards, Tiwei Bie