Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1431344ybb; Sun, 29 Mar 2020 04:36:35 -0700 (PDT) X-Google-Smtp-Source: ADFU+vt/JLukhRKQ5dg6GERtVYfRbjLNJXHnYoRcBLZ3e5RSu0lbDNjUtMDa+yoGPavrYcTpHIbI X-Received: by 2002:a05:6830:1296:: with SMTP id z22mr5518141otp.108.1585481795519; Sun, 29 Mar 2020 04:36:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585481795; cv=none; d=google.com; s=arc-20160816; b=d1UVDuRWTHT9Zi6E7AVzxpW2fk2da7pqGnvbvD6amxfZrejt/yodZZIxwPf1mO7ZTc rNAOOxG5OI3URyCE05WJ5uIGzuQ29genwv39FYJy3PAUZZv+hH0a7diZMzMMNs2vIbPd PXHYN272hxZN9yVa7xj3WMvQtY8W6+MCw2co6dQqZ2y11Gxr6iFmmvibthDd/GmK2wIR ZyfWK2mpZ+QSsAThmdDd45WA7uH0uCGBwGFevVMWiw6wEBHQcWr5fpHNjFJzFhS9FFUv EATSWgwyINnAiRWIQ8nPump+2/hoCI67uompsvez99iALud6+fUol0yNXa7+sFiaClq0 H6SA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=f2xSZ1+lt7RamvhPTl6pP+suvDZVoUYTv4LGPAjxmSU=; b=IENYuhJg7QOSyE4L/IhRonOD158vB6mECRdaZGbZWGbPFms/Dct8yLndTcxab2LsGo nTynCV0Lbs2p3YisKp27QFoQaPtuOf559idWnaST7vBsAdWLwU7C47fXWD166Me8Kv5W bLRd0juFPu91DXn8LaeolMc8yJRgTPkcq8ydrKN/5KSX5dpJRuYZ7yr7oE8zFQ7CU6cR dK3dYOcD2u0TfoGGhCi09wTXDGgP6e+5CTZzUiass3AtiVW5D3oXuYFKUuLP+LlLZmyF I7BF/rzaL1I+VHpYV6bTea4U6zZK30Y9quy6WbjPwPMytRfc4Ax8MK3oSxMGVlt+w/7e 79qQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cxz3atby; 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=pass (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 z9si4496633oih.157.2020.03.29.04.36.23; Sun, 29 Mar 2020 04:36:35 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cxz3atby; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728182AbgC2Lep (ORCPT + 99 others); Sun, 29 Mar 2020 07:34:45 -0400 Received: from us-smtp-delivery-74.mimecast.com ([216.205.24.74]:47597 "EHLO us-smtp-delivery-74.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728171AbgC2Lel (ORCPT ); Sun, 29 Mar 2020 07:34:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585481680; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=f2xSZ1+lt7RamvhPTl6pP+suvDZVoUYTv4LGPAjxmSU=; b=cxz3atbyxfNqjfTB06r+yVOq+jXG7E+EtIZie/yL9O02JlzJ14mRIjBi5REudO7iBen5U4 MoUlZquULIiIwCsRhhUyuma38caJOgJBeGh8nA8uOturQLqvadUfac1cyqj1dSAVgNO6gq O6xiKhO+FcNYpDOn4goVTcwsQPGIG10= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-177-C2Xmv3AHM3y3R7uQan8dSg-1; Sun, 29 Mar 2020 07:34:39 -0400 X-MC-Unique: C2Xmv3AHM3y3R7uQan8dSg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C372A18B5F69; Sun, 29 Mar 2020 11:34:37 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-112-95.ams2.redhat.com [10.36.112.95]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4B3635C1B5; Sun, 29 Mar 2020 11:34:33 +0000 (UTC) From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: "Michael S. Tsirkin" Cc: "virtualization@lists.linux-foundation.org" , Halil Pasic , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Stephen Rothwell , Linux Next Mailing List , kvm list , Cornelia Huck , Christian Borntraeger , "linux-kernel@vger.kernel.org" Subject: [PATCH 5/6] vhost: Delete virtqueue batch_descs member Date: Sun, 29 Mar 2020 13:33:58 +0200 Message-Id: <20200329113359.30960-6-eperezma@redhat.com> In-Reply-To: <20200329113359.30960-1-eperezma@redhat.com> References: <20200329113359.30960-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It can be deduced from "max_descs". Signed-off-by: Eugenio P=C3=A9rez --- drivers/vhost/vhost.c | 11 +++++++++-- drivers/vhost/vhost.h | 1 - 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index b5a51b1f2e79..5f84f29b6c47 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -372,6 +372,11 @@ static int vhost_worker(void *data) return 0; } =20 +static int vhost_vq_num_batch_descs(struct vhost_virtqueue *vq) +{ + return vq->max_descs - UIO_MAXIOV; +} + static void vhost_vq_free_iovecs(struct vhost_virtqueue *vq) { kfree(vq->descs); @@ -394,7 +399,9 @@ static long vhost_dev_alloc_iovecs(struct vhost_dev *= dev) for (i =3D 0; i < dev->nvqs; ++i) { vq =3D dev->vqs[i]; vq->max_descs =3D dev->iov_limit; - vq->batch_descs =3D dev->iov_limit - UIO_MAXIOV; + if (vhost_vq_num_batch_descs(vq) < 0) { + return -EINVAL; + } vq->descs =3D kmalloc_array(vq->max_descs, sizeof(*vq->descs), GFP_KERNEL); @@ -2333,7 +2340,7 @@ static int fetch_descs(struct vhost_virtqueue *vq) if (vq->ndescs) return 0; =20 - while (!ret && vq->ndescs <=3D vq->batch_descs) + while (!ret && vq->ndescs <=3D vhost_vq_num_batch_descs(vq)) ret =3D fetch_buf(vq); =20 return vq->ndescs ? 0 : ret; diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h index 661088ae6dc7..e648b9b997d4 100644 --- a/drivers/vhost/vhost.h +++ b/drivers/vhost/vhost.h @@ -102,7 +102,6 @@ struct vhost_virtqueue { int ndescs; int first_desc; int max_descs; - int batch_descs; =20 const struct vhost_umem_node *meta_iotlb[VHOST_NUM_ADDRS]; struct file *kick; --=20 2.18.1