Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1040687pxb; Thu, 28 Jan 2021 06:47:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJxWRzVysQyo2h4s5tzOENCQSgtuSH6k+nZkalZO0XdF4LiBUJMAEOsM5Uvrkz0qUB3fUn3w X-Received: by 2002:aa7:de8f:: with SMTP id j15mr14859590edv.268.1611845230755; Thu, 28 Jan 2021 06:47:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611845230; cv=none; d=google.com; s=arc-20160816; b=vQ4lffgpO6LyyQLJa1+i3W1uisE8rG5JkVLJhfSGg9Piy51RdF3B2dbEywAoCWOvil dU8N28Ftwkjd/ss3WQrYYO+7kuHJTYgbOpqp+vC8ScQ4NtBwP7/SKTcun9CZt+FlxmEP QoPvuoCPFN0Wxhvao4mAAw59FImySgp2UN+FkG9DXlkBeDcXgvV3F9E9OUKwPl370XlI v59jpDBKqTPxH2wXhxB8Q86+gactzFMyizvjQgj9no/4unNU31wdFoWguNzWj7cDGIq7 ExH49lj1KXguzbN3XhPwmwV3wIh5DnNVrmFnLekdaCpDXEqneSXAmeQoj+x0c6beHEyp vpog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=g3g1OmTgyQKpO44PG/KohyJWQoMIoCRfwQDA6iGRUjI=; b=EqbgBWGyBDQj1tcntNF+YkTfK5R32X65w+f6GXmq9ixQqGse+6WFPyrdkQY8sAzF9j 8q8yqWEKLa6QG6IByXg1DTtPR/BC0udL9yHiUcw8PMf0Wce57AzGWA/DeGf1jOZFHWb/ T2F3VBiTNazn8O46grdILeRzLYd0zX/BjSKXU1xVXNGRBsdCL7YAlLI79TqMI5yB42gS sKlD0Xhxm/NJY77gIkj6YCUO42gDYHWZkRaWx8rXugsviib6cgikK/eM7sMX0Vm5R/BY DTB34D4C/5+4Hwxsn+wavjQ4zwYeYG26cyz51Qexge5xj8eaT7nwZALItWRcJyr4B8GU 3vIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dwFxDncG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id jg15si2883562ejc.481.2021.01.28.06.46.46; Thu, 28 Jan 2021 06:47:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dwFxDncG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S232034AbhA1Oo5 (ORCPT + 99 others); Thu, 28 Jan 2021 09:44:57 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:50792 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231856AbhA1OoG (ORCPT ); Thu, 28 Jan 2021 09:44:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611844960; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g3g1OmTgyQKpO44PG/KohyJWQoMIoCRfwQDA6iGRUjI=; b=dwFxDncG+2WxwVxUIW3aPR8K9JHmhsj7UBQf2S+ob29lA/D6Uiwf3nbQZG6XQE8QzxbUbr Kt+PKGYV5g0sKbn7L0CokX7eRxqNALiNU+9wSkF92zmxxkFkaC3QjpyDP0a654SSRadNMw sdal8RejqwwiTuSePOIAhm2ZETznZh8= 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-12-eVSp1GIAMzW-og4lhkqnbw-1; Thu, 28 Jan 2021 09:42:36 -0500 X-MC-Unique: eVSp1GIAMzW-og4lhkqnbw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 45580107ACF5; Thu, 28 Jan 2021 14:42:35 +0000 (UTC) Received: from steredhat.redhat.com (ovpn-113-219.ams2.redhat.com [10.36.113.219]) by smtp.corp.redhat.com (Postfix) with ESMTP id A45D06267D; Thu, 28 Jan 2021 14:42:29 +0000 (UTC) From: Stefano Garzarella To: virtualization@lists.linux-foundation.org Cc: Xie Yongji , "Michael S. Tsirkin" , Stefano Garzarella , Laurent Vivier , Stefan Hajnoczi , linux-kernel@vger.kernel.org, Max Gurtovoy , Jason Wang , kvm@vger.kernel.org Subject: [PATCH RFC v2 06/10] vdpa_sim: cleanup kiovs in vdpasim_free() Date: Thu, 28 Jan 2021 15:41:23 +0100 Message-Id: <20210128144127.113245-7-sgarzare@redhat.com> In-Reply-To: <20210128144127.113245-1-sgarzare@redhat.com> References: <20210128144127.113245-1-sgarzare@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org vringh_getdesc_iotlb() allocates memory to store the kvec, that is freed with vringh_kiov_cleanup(). vringh_getdesc_iotlb() is able to reuse a kvec previously allocated, so in order to avoid to allocate the kvec for each request, we are not calling vringh_kiov_cleanup() when we finished to handle a request, but we should call it when we free the entire device. Signed-off-by: Stefano Garzarella --- drivers/vdpa/vdpa_sim/vdpa_sim.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c index 53238989713d..a7aeb5d01c3e 100644 --- a/drivers/vdpa/vdpa_sim/vdpa_sim.c +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c @@ -562,8 +562,15 @@ static int vdpasim_dma_unmap(struct vdpa_device *vdpa, u64 iova, u64 size) static void vdpasim_free(struct vdpa_device *vdpa) { struct vdpasim *vdpasim = vdpa_to_sim(vdpa); + int i; cancel_work_sync(&vdpasim->work); + + for (i = 0; i < vdpasim->dev_attr.nvqs; i++) { + vringh_kiov_cleanup(&vdpasim->vqs[i].out_iov); + vringh_kiov_cleanup(&vdpasim->vqs[i].in_iov); + } + put_iova_domain(&vdpasim->iova); iova_cache_put(); kvfree(vdpasim->buffer); -- 2.29.2