From patchwork Sun Mar 29 11:33:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eugenio Perez Martin X-Patchwork-Id: 11463995 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 32AEB913 for ; Sun, 29 Mar 2020 11:34:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1224620774 for ; Sun, 29 Mar 2020 11:34:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="N4GxHr1Q" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728180AbgC2Leo (ORCPT ); Sun, 29 Mar 2020 07:34:44 -0400 Received: from us-smtp-delivery-74.mimecast.com ([216.205.24.74]:54140 "EHLO us-smtp-delivery-74.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728177AbgC2Leo (ORCPT ); Sun, 29 Mar 2020 07:34:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585481682; 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=N4GxHr1QRWzJsKoxy1hbJ6KcVvtQWOwattPrgqAfApDIdEU8QBeifsg//5K5jQA3ud1idj F9Zev4y3dR4LSBi6v9IsFwWctrooyXdpZGF8BzAbsEpsHSK9jaYbDS9LkmMmOK0YCHeEYW EMF2PLaITtzbQ19hQ3AwuXOJsX6kYeE= 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_P=C3=A9rez?= To: "Michael S. Tsirkin" Cc: "virtualization@lists.linux-foundation.org" , Halil Pasic , =?utf-8?q?Eugenio_P=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 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org It can be deduced from "max_descs". Signed-off-by: Eugenio PĂ©rez --- 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; } +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 = 0; i < dev->nvqs; ++i) { vq = dev->vqs[i]; vq->max_descs = dev->iov_limit; - vq->batch_descs = dev->iov_limit - UIO_MAXIOV; + if (vhost_vq_num_batch_descs(vq) < 0) { + return -EINVAL; + } vq->descs = 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; - while (!ret && vq->ndescs <= vq->batch_descs) + while (!ret && vq->ndescs <= vhost_vq_num_batch_descs(vq)) ret = fetch_buf(vq); 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; const struct vhost_umem_node *meta_iotlb[VHOST_NUM_ADDRS]; struct file *kick;