Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3604485pxb; Sun, 31 Jan 2021 22:50:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJzZIZLbGVYVsZe71s9ckH94reMESHlcl4Lo43ajoO8wxxI34dPRByUydyxCy9hTg1BMr8zJ X-Received: by 2002:a17:906:33d9:: with SMTP id w25mr4374184eja.489.1612162257776; Sun, 31 Jan 2021 22:50:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612162257; cv=none; d=google.com; s=arc-20160816; b=pOSu4d3//FVRvuv5/WoVp4+IS6bwaTbHz6qjz4pXuSo3Npq9wpolQfgJtsX/47F6kP SimjpKwvTczUlEyO2M/76D8xL7ueFkZZW4nEa/j4Rv5muJwGG2lrqzQZkCtBS0lgnaYe Q+tnyNNJYlDptuR/BSLUnI4TJ5/J7aSu3BgL6xpj4E+hdQY6MuZV1z9I7kIKS4wfKfz+ nMCs4fliiq+xDztdg135Me2pKEcEpEWENchfhPd2j6V0Dsl35ebs7hi4BIChzk0l6TzO EW2A0+rVFm+EkY7PQghtUR1pwCJB/71D4eL3ycfnXQQRPl15DB6YAo/3QU/d60OY3gVu r5fA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=qzygt8PY+ejYaTw5CY3AQHjM5FXiYjRfhZf967nzudg=; b=HrRx3pWNfX3copsOJhvHR7iJ2c2uolZ1IbfduyDwx8Jbc66IDOC+sSMIqWKOaNWJ7f SMb2MxWZbwZLhp0ius+wn6whYKL90JNuHpV25T711mAYk1E8HLhV5Q8+cG4/IGjrQ6Dd Idrr+yxP49W8NCuUs+t2m/ws/USfybEoOccbCwOwa+ZxyRBTS6l9SKmP9wVMJOfGcxky l7QTo0/unopUDABfl3nYLWefv0TepI8uU94fKKYdiYlkeexwCKKXRQkKYUdQ1XwOt2Yr wu5zTLBcg+8rGoRqy6SmiPo8yi2tXerWauKRJeIed84wSnVnPlqjTBGxmQfsL1olbdyI vMzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IDHqnYqk; 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 p26si9950201eji.9.2021.01.31.22.50.33; Sun, 31 Jan 2021 22:50:57 -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=IDHqnYqk; 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 S231575AbhBAGrb (ORCPT + 99 others); Mon, 1 Feb 2021 01:47:31 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:30004 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231614AbhBAFss (ORCPT ); Mon, 1 Feb 2021 00:48:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612158442; 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=qzygt8PY+ejYaTw5CY3AQHjM5FXiYjRfhZf967nzudg=; b=IDHqnYqk9YFbH3V8qOgIK928evfA6BFyHsJZT99nBAhppWq72WDCk1jMS/KFgqvMG7B6Tk N0vg7u0so/ruOVVo1WKV3IWh1YXF7AxdRTiR6zmeLUQPRarHIfY1DQA9cwx8NuPcBeNmVz esRBtLjEzriLPVBm92ullTgEUkX7h4Q= 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-237-adswYuZvO16IX_bbRm2ArQ-1; Mon, 01 Feb 2021 00:47:20 -0500 X-MC-Unique: adswYuZvO16IX_bbRm2ArQ-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 7405E425D2; Mon, 1 Feb 2021 05:47:19 +0000 (UTC) Received: from [10.72.13.120] (ovpn-13-120.pek2.redhat.com [10.72.13.120]) by smtp.corp.redhat.com (Postfix) with ESMTP id 67DC563BB8; Mon, 1 Feb 2021 05:47:10 +0000 (UTC) Subject: Re: [PATCH RFC v2 06/10] vdpa_sim: cleanup kiovs in vdpasim_free() To: Stefano Garzarella , virtualization@lists.linux-foundation.org Cc: Xie Yongji , "Michael S. Tsirkin" , Laurent Vivier , Stefan Hajnoczi , linux-kernel@vger.kernel.org, Max Gurtovoy , kvm@vger.kernel.org References: <20210128144127.113245-1-sgarzare@redhat.com> <20210128144127.113245-7-sgarzare@redhat.com> From: Jason Wang Message-ID: <9a7051ae-8ae4-7d17-f662-fe8448606e34@redhat.com> Date: Mon, 1 Feb 2021 13:47:08 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20210128144127.113245-7-sgarzare@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/1/28 下午10:41, Stefano Garzarella wrote: > 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 Acked-by: Jason Wang > --- > 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);