From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6AC1F42B9A; Thu, 25 May 2023 13:20:32 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 439F640DF8; Thu, 25 May 2023 13:20:32 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id B692D40DDB for ; Thu, 25 May 2023 13:20:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685013630; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Lgcrntl0pYq0YWImWHuipzmApxShujLt5HBMve3ZIAA=; b=GSFwpDO6GAmKPT6tKSb72sqpWQmDzpDxRlIFdkW30sApBnhYFImyOu0lhGKtYi28lHCNl1 ENLXibx8/L3yWEnRfNy0OX9zguPHReD19x+SwF8fA5IT6qAXVXm9GFooangLybGv/pQK6E lcUW+SRT6g63hX3AGdmmr5oNRIJtPTA= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-665-3RpFVF6MMye3laTn1Fa86g-1; Thu, 25 May 2023 07:20:27 -0400 X-MC-Unique: 3RpFVF6MMye3laTn1Fa86g-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CE2D4185A78B; Thu, 25 May 2023 11:20:26 +0000 (UTC) Received: from [10.39.208.23] (unknown [10.39.208.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 74D731121314; Thu, 25 May 2023 11:20:24 +0000 (UTC) Message-ID: Date: Thu, 25 May 2023 13:20:22 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [RFC 12/27] vhost: add IOTLB cache entry removal callback To: "Xia, Chenbo" , "dev@dpdk.org" , "david.marchand@redhat.com" , "mkp@redhat.com" , "fbl@redhat.com" , "jasowang@redhat.com" , "Liang, Cunming" , "Xie, Yongji" , "echaudro@redhat.com" , "eperezma@redhat.com" , "amorenoz@redhat.com" References: <20230331154259.1447831-1-maxime.coquelin@redhat.com> <20230331154259.1447831-13-maxime.coquelin@redhat.com> From: Maxime Coquelin In-Reply-To: X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On 5/5/23 07:07, Xia, Chenbo wrote: > Hi Maxime, > >> -----Original Message----- >> From: Maxime Coquelin >> Sent: Friday, March 31, 2023 11:43 PM >> To: dev@dpdk.org; david.marchand@redhat.com; Xia, Chenbo >> ; mkp@redhat.com; fbl@redhat.com; >> jasowang@redhat.com; Liang, Cunming ; Xie, Yongji >> ; echaudro@redhat.com; eperezma@redhat.com; >> amorenoz@redhat.com >> Cc: Maxime Coquelin >> Subject: [RFC 12/27] vhost: add IOTLB cache entry removal callback >> >> VDUSE will need to munmap() the IOTLB entry on removal >> from the cache, as it performs mmap() before insertion. >> >> This patch introduces a callback that VDUSE layer will >> implement to achieve this. >> >> Signed-off-by: Maxime Coquelin >> --- >> lib/vhost/iotlb.c | 12 ++++++++++++ >> lib/vhost/vhost.h | 4 ++++ >> 2 files changed, 16 insertions(+) >> >> diff --git a/lib/vhost/iotlb.c b/lib/vhost/iotlb.c >> index 188dfb8e38..86b0be62b4 100644 >> --- a/lib/vhost/iotlb.c >> +++ b/lib/vhost/iotlb.c >> @@ -25,6 +25,15 @@ struct vhost_iotlb_entry { >> >> #define IOTLB_CACHE_SIZE 2048 >> >> +static void >> +vhost_user_iotlb_remove_notify(struct virtio_net *dev, struct >> vhost_iotlb_entry *entry) >> +{ >> + if (dev->backend_ops->iotlb_remove_notify == NULL) >> + return; >> + >> + dev->backend_ops->iotlb_remove_notify(entry->uaddr, entry->uoffset, >> entry->size); >> +} >> + >> static bool >> vhost_user_iotlb_share_page(struct vhost_iotlb_entry *a, struct >> vhost_iotlb_entry *b) >> { >> @@ -198,6 +207,7 @@ vhost_user_iotlb_cache_remove_all(struct virtio_net >> *dev) >> vhost_user_iotlb_set_dump(node); >> >> TAILQ_REMOVE(&dev->iotlb_list, node, next); >> + vhost_user_iotlb_remove_notify(dev, node); >> vhost_user_iotlb_pool_put(dev, node); >> } >> >> @@ -223,6 +233,7 @@ vhost_user_iotlb_cache_random_evict(struct virtio_net >> *dev) >> vhost_user_iotlb_clear_dump(node, prev_node, next_node); >> >> TAILQ_REMOVE(&dev->iotlb_list, node, next); >> + vhost_user_iotlb_remove_notify(dev, node); >> vhost_user_iotlb_pool_put(dev, node); >> dev->iotlb_cache_nr--; >> break; >> @@ -314,6 +325,7 @@ vhost_user_iotlb_cache_remove(struct virtio_net *dev, >> uint64_t iova, uint64_t si >> vhost_user_iotlb_clear_dump(node, prev_node, next_node); >> >> TAILQ_REMOVE(&dev->iotlb_list, node, next); >> + vhost_user_iotlb_remove_notify(dev, node); >> vhost_user_iotlb_pool_put(dev, node); >> dev->iotlb_cache_nr--; >> } else { >> diff --git a/lib/vhost/vhost.h b/lib/vhost/vhost.h >> index cc5c707205..2ad26f6951 100644 >> --- a/lib/vhost/vhost.h >> +++ b/lib/vhost/vhost.h >> @@ -89,10 +89,14 @@ >> for (iter = val; iter < num; iter++) >> #endif >> >> +struct virtio_net; > > Adding this in patch 13 could be better since this patch is not using it. Right, I changed vhost_iotlb_remove_notify cb prototype but forgot to remove struct virtio_net afterwards. Changed in upcoming v2. Thanks, Maxime > Thanks, > Chenbo > >> +typedef void (*vhost_iotlb_remove_notify)(uint64_t addr, uint64_t off, >> uint64_t size); >> + >> /** >> * Structure that contains backend-specific ops. >> */ >> struct vhost_backend_ops { >> + vhost_iotlb_remove_notify iotlb_remove_notify; >> }; >> >> /** >> -- >> 2.39.2 >