Message ID | 1697185420-27213-1-git-send-email-si-wei.liu@oracle.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1740388vqb; Fri, 13 Oct 2023 01:26:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEv+Vr87b/7L+cPq4LCWXW2AnQ3/QE1Mw75S049gJxtTtwMwmUBcS2Jgmviihhv8ggnQOit X-Received: by 2002:a05:6870:bacf:b0:1e9:8ab9:11ca with SMTP id js15-20020a056870bacf00b001e98ab911camr7962697oab.3.1697185604581; Fri, 13 Oct 2023 01:26:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697185604; cv=none; d=google.com; s=arc-20160816; b=BjIHIIHijQqGohi82+0RAF5IZ2Cdm8ZskyV4x70oddkrqR/smOprzNN++Hwl62UMZd BFhCWi6XZS/O9mXUpu2I9dEYfGjq0kNuO97Eg3EMqi+gn1dI4rx/YnYZve7oYhaVMGar QWV411fxZnzJXSg/zgBCURfHPt4Iu2xzAlsfMmifOuvEOOUpr73L9A+YYsGL3K45ajaA 0fHEfqAzRtRfgSPxrbi4kAe+wFlGg4TMhynCQtI7qS4HKmQcsqyFEewnRJgyyrrxdE1K 0yZn2aAnPSMiR9z9U4mqS3L2uv73o7m47vYV/iBqY38JCgiIaeEaK7MwGaZ7OXK9SxpC QEug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=/0aZsgxCF4y1JYPEwaC9JYKgoBe2Trmk++npA7bf5y0=; fh=Ue94aJEXk9VFZlXHlJjxkTOEicDf85DzpZNDITnIKkM=; b=E3cwVbNFEwmeEl+Fo9NyPKdtEIQkZakVmcLWGHbyXAUAizjAqOKdM22fAgg8OsCNoH SS9qRuKLYDPCgw0Ky4ODbqEl/0Q1aMG6E9343OEaOwSX5KfWdT5kh4H+fRync2EXLGme jbFxD+btyOzx8fzV7gN59AYgvEztSAEAnveYr54mojaaz6aVDxtgGG6gi967f8NEobeH G5w+778Bh0NYYHNqoFB7kGazx6QBXvKRhuCjG3yC5jPYSczoFRtk5UfEmHyPBYzrcslf cwgbJEf4aIFiXmcpZfaZZWYfiVHp5SCMFy/W/zgBYbpTl0eefqn5q/BuCTfTRTNJ9UFx 33UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=yIfGRlLE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id r34-20020a634422000000b00584e05f62e1si3950727pga.297.2023.10.13.01.26.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 01:26:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=yIfGRlLE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 6BA7980DBACA; Fri, 13 Oct 2023 01:26:42 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230039AbjJMI00 (ORCPT <rfc822;rua109.linux@gmail.com> + 19 others); Fri, 13 Oct 2023 04:26:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229743AbjJMI0X (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 13 Oct 2023 04:26:23 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0DE7B91 for <linux-kernel@vger.kernel.org>; Fri, 13 Oct 2023 01:26:21 -0700 (PDT) Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 39D7Opc1013924; Fri, 13 Oct 2023 08:26:17 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2023-03-30; bh=/0aZsgxCF4y1JYPEwaC9JYKgoBe2Trmk++npA7bf5y0=; b=yIfGRlLEq+0gXPeFyUKwwaRRMbfR0usE+EYMVqFexk3LjdcmdShe7j1u5d1h+7QFnY1I 6j80BoCGHKU8PEg/oKn55odItYcfccBjT8W2iaKFXjMXl2Tn0J2n4sJ9IveAhZ3bGEk8 OYI5ESiOOiBX7p1SMHRud+oTp7ZuzHfEucpalu5o27R7Q2UVkvUcS+12ctBf7pEehzHZ nSGaJCbqdhBe0c8PoTKkRYi/nqaBPW76+D324nr2lXWwSNCPtw91ssdtFwULOmhe2Pe4 cALsLGhS8kz7GAugbpNQoIxd+eVXuygipDhZI/9y4HKtdzkigqVSFCvfQnWO4W78uHLH cQ== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3tjx8cmk76-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 13 Oct 2023 08:26:17 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 39D626bD020257; Fri, 13 Oct 2023 08:26:17 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3tptcj8d2r-1; Fri, 13 Oct 2023 08:26:16 +0000 From: Si-Wei Liu <si-wei.liu@oracle.com> To: jasowang@redhat.com, mst@redhat.com, eperezma@redhat.com, sgarzare@redhat.com Cc: virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH] vdpa_sim: implement .reset_map support Date: Fri, 13 Oct 2023 01:23:40 -0700 Message-Id: <1697185420-27213-1-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-13_03,2023-10-12_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 adultscore=0 suspectscore=0 phishscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310130069 X-Proofpoint-ORIG-GUID: y_bZp2PgS0bvm98lMFFCMa3cM5HRiHF2 X-Proofpoint-GUID: y_bZp2PgS0bvm98lMFFCMa3cM5HRiHF2 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Fri, 13 Oct 2023 01:26:42 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779628092331236112 X-GMAIL-MSGID: 1779628092331236112 |
Series |
[RFC] vdpa_sim: implement .reset_map support
|
|
Commit Message
Si-Wei Liu
Oct. 13, 2023, 8:23 a.m. UTC
RFC only. Not tested on vdpa-sim-blk with user virtual address.
Works fine with vdpa-sim-net which uses physical address to map.
This patch is based on top of [1].
[1] https://lore.kernel.org/virtualization/1696928580-7520-1-git-send-email-si-wei.liu@oracle.com/
Signed-off-by: Si-Wei Liu <si-wei.liu@oracle.com>
---
drivers/vdpa/vdpa_sim/vdpa_sim.c | 28 +++++++++++++++++++++-------
1 file changed, 21 insertions(+), 7 deletions(-)
Comments
Hi Si-Wei, On Fri, Oct 13, 2023 at 01:23:40AM -0700, Si-Wei Liu wrote: >RFC only. Not tested on vdpa-sim-blk with user virtual address. I can test it, but what I should stress? >Works fine with vdpa-sim-net which uses physical address to map. Can you share your tests? so I'll try to do the same with blk. > >This patch is based on top of [1]. > >[1] >https://lore.kernel.org/virtualization/1696928580-7520-1-git-send-email-si-wei.liu@oracle.com/ The series does not apply well on master or vhost tree. Where should I apply it? If you have a tree with all of them applied, will be easy for me ;-) Thanks, Stefano
Hi Stefano, On 10/13/2023 2:22 AM, Stefano Garzarella wrote: > Hi Si-Wei, > > On Fri, Oct 13, 2023 at 01:23:40AM -0700, Si-Wei Liu wrote: >> RFC only. Not tested on vdpa-sim-blk with user virtual address. > > I can test it, but what I should stress? Great, thank you! As you see, my patch moved vhost_iotlb_reset out of vdpasim_reset for the sake of decoupling mapping from vdpa device reset. For hardware devices this decoupling makes sense as platform IOMMU already did it. But I'm not sure if there's something in the software device (esp. with vdpa-blk and the userspace library stack) that may have to rely on the current .reset behavior that clears the vhost_iotlb. So perhaps you can try to exercise every possible case involving blk device reset, and see if anything (related to mapping) breaks? > >> Works fine with vdpa-sim-net which uses physical address to map. > > Can you share your tests? so I'll try to do the same with blk. Basically everything involving virtio device reset in the guest, e.g. reboot the VM, remove/unbind then reprobe/bind the virtio-net module/driver, then see if device I/O (which needs mapping properly) is still flowing as expected. And then everything else that could trigger QEMU's vhost_dev_start/stop paths ending up as passive vhos-vdpa backend reset, for e.g. link status change, suspend/hibernate, SVQ switch and live migration. I am not sure if vdpa-blk supports live migration through SVQ or not, if not you don't need to worry about. > >> >> This patch is based on top of [1]. >> >> [1] >> https://lore.kernel.org/virtualization/1696928580-7520-1-git-send-email-si-wei.liu@oracle.com/ > > The series does not apply well on master or vhost tree. > Where should I apply it? Sent the link through another email offline. Thanks, -Siwei > > If you have a tree with all of them applied, will be easy for me ;-) > > Thanks, > Stefano >
On Fri, Oct 13, 2023 at 10:29:26AM -0700, Si-Wei Liu wrote: >Hi Stefano, > >On 10/13/2023 2:22 AM, Stefano Garzarella wrote: >>Hi Si-Wei, >> >>On Fri, Oct 13, 2023 at 01:23:40AM -0700, Si-Wei Liu wrote: >>>RFC only. Not tested on vdpa-sim-blk with user virtual address. >> >>I can test it, but what I should stress? >Great, thank you! As you see, my patch moved vhost_iotlb_reset out of >vdpasim_reset for the sake of decoupling mapping from vdpa device >reset. For hardware devices this decoupling makes sense as platform >IOMMU already did it. But I'm not sure if there's something in the >software device (esp. with vdpa-blk and the userspace library stack) >that may have to rely on the current .reset behavior that clears the >vhost_iotlb. So perhaps you can try to exercise every possible case >involving blk device reset, and see if anything (related to mapping) >breaks? I just tried these steps without using a VM and the host kernel hangs after adding the device: [root@f38-vm-build ~]# modprobe virtio-vdpa [root@f38-vm-build ~]# modprobe vdpa-sim-blk [root@f38-vm-build ~]# vdpa dev add mgmtdev vdpasim_blk name blk0 [ 35.284575][ T563] virtio_blk virtio6: 1/0/0 default/read/poll queues [ 35.286372][ T563] virtio_blk virtio6: [vdb] 262144 512-byte logical blocks (134 MB/128 MiB) [ 35.295271][ T564] vringh: Reverting this patch (so building "vdpa/mlx5: implement .reset_map driver op") worked here. > >> >>>Works fine with vdpa-sim-net which uses physical address to map. >> >>Can you share your tests? so I'll try to do the same with blk. >Basically everything involving virtio device reset in the guest, e.g. >reboot the VM, remove/unbind then reprobe/bind the virtio-net >module/driver, then see if device I/O (which needs mapping properly) is >still flowing as expected. And then everything else that could trigger >QEMU's vhost_dev_start/stop paths ending up as passive vhos-vdpa >backend reset, for e.g. link status change, suspend/hibernate, SVQ >switch and live migration. I am not sure if vdpa-blk supports live >migration through SVQ or not, if not you don't need to worry about. > >> >>> >>>This patch is based on top of [1]. >>> >>>[1] https://lore.kernel.org/virtualization/1696928580-7520-1-git-send-email-si-wei.liu@oracle.com/ >> >>The series does not apply well on master or vhost tree. >>Where should I apply it? >Sent the link through another email offline. Received thanks! Stefano
Hi Stefano, On 10/17/2023 6:44 AM, Stefano Garzarella wrote: > On Fri, Oct 13, 2023 at 10:29:26AM -0700, Si-Wei Liu wrote: >> Hi Stefano, >> >> On 10/13/2023 2:22 AM, Stefano Garzarella wrote: >>> Hi Si-Wei, >>> >>> On Fri, Oct 13, 2023 at 01:23:40AM -0700, Si-Wei Liu wrote: >>>> RFC only. Not tested on vdpa-sim-blk with user virtual address. >>> >>> I can test it, but what I should stress? >> Great, thank you! As you see, my patch moved vhost_iotlb_reset out of >> vdpasim_reset for the sake of decoupling mapping from vdpa device >> reset. For hardware devices this decoupling makes sense as platform >> IOMMU already did it. But I'm not sure if there's something in the >> software device (esp. with vdpa-blk and the userspace library stack) >> that may have to rely on the current .reset behavior that clears the >> vhost_iotlb. So perhaps you can try to exercise every possible case >> involving blk device reset, and see if anything (related to mapping) >> breaks? > > I just tried these steps without using a VM and the host kernel hangs > after adding the device: > > [root@f38-vm-build ~]# modprobe virtio-vdpa > [root@f38-vm-build ~]# modprobe vdpa-sim-blk > [root@f38-vm-build ~]# vdpa dev add mgmtdev vdpasim_blk name blk0 > [ 35.284575][ T563] virtio_blk virtio6: 1/0/0 default/read/poll queues > [ 35.286372][ T563] virtio_blk virtio6: [vdb] 262144 512-byte > logical blocks (134 MB/128 MiB) > [ 35.295271][ T564] vringh: > > Reverting this patch (so building "vdpa/mlx5: implement .reset_map > driver op") worked here. I'm sorry, the previous RFC patch was incomplete - please see the v2 I just posted. Tested both use_va and !use_va on vdpa-sim-blk, and raw disk copy to the vdpa block simulator using dd seems fine. Just let me know how it goes on your side this time. Thanks, -Siwei > >> >>> >>>> Works fine with vdpa-sim-net which uses physical address to map. >>> >>> Can you share your tests? so I'll try to do the same with blk. >> Basically everything involving virtio device reset in the guest, >> e.g. reboot the VM, remove/unbind then reprobe/bind the virtio-net >> module/driver, then see if device I/O (which needs mapping properly) >> is still flowing as expected. And then everything else that could >> trigger QEMU's vhost_dev_start/stop paths ending up as passive >> vhos-vdpa backend reset, for e.g. link status change, >> suspend/hibernate, SVQ switch and live migration. I am not sure if >> vdpa-blk supports live migration through SVQ or not, if not you don't >> need to worry about. >> >>> >>>> >>>> This patch is based on top of [1]. >>>> >>>> [1] >>>> https://lore.kernel.org/virtualization/1696928580-7520-1-git-send-email-si-wei.liu@oracle.com/ >>> >>> The series does not apply well on master or vhost tree. >>> Where should I apply it? >> Sent the link through another email offline. > > Received thanks! > > Stefano >
diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c index 76d4105..a7455f2 100644 --- a/drivers/vdpa/vdpa_sim/vdpa_sim.c +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c @@ -151,13 +151,6 @@ static void vdpasim_do_reset(struct vdpasim *vdpasim) &vdpasim->iommu_lock); } - for (i = 0; i < vdpasim->dev_attr.nas; i++) { - vhost_iotlb_reset(&vdpasim->iommu[i]); - vhost_iotlb_add_range(&vdpasim->iommu[i], 0, ULONG_MAX, - 0, VHOST_MAP_RW); - vdpasim->iommu_pt[i] = true; - } - vdpasim->running = true; spin_unlock(&vdpasim->iommu_lock); @@ -637,6 +630,25 @@ static int vdpasim_set_map(struct vdpa_device *vdpa, unsigned int asid, return ret; } +static int vdpasim_reset_map(struct vdpa_device *vdpa, unsigned int asid) +{ + struct vdpasim *vdpasim = vdpa_to_sim(vdpa); + + if (asid >= vdpasim->dev_attr.nas) + return -EINVAL; + + spin_lock(&vdpasim->iommu_lock); + if (vdpasim->iommu_pt[asid]) + goto out; + vhost_iotlb_reset(&vdpasim->iommu[asid]); + vhost_iotlb_add_range(&vdpasim->iommu[asid], 0, ULONG_MAX, + 0, VHOST_MAP_RW); + vdpasim->iommu_pt[asid] = true; +out: + spin_unlock(&vdpasim->iommu_lock); + return 0; +} + static int vdpasim_bind_mm(struct vdpa_device *vdpa, struct mm_struct *mm) { struct vdpasim *vdpasim = vdpa_to_sim(vdpa); @@ -759,6 +771,7 @@ static void vdpasim_free(struct vdpa_device *vdpa) .set_group_asid = vdpasim_set_group_asid, .dma_map = vdpasim_dma_map, .dma_unmap = vdpasim_dma_unmap, + .reset_map = vdpasim_reset_map, .bind_mm = vdpasim_bind_mm, .unbind_mm = vdpasim_unbind_mm, .free = vdpasim_free, @@ -796,6 +809,7 @@ static void vdpasim_free(struct vdpa_device *vdpa) .get_iova_range = vdpasim_get_iova_range, .set_group_asid = vdpasim_set_group_asid, .set_map = vdpasim_set_map, + .reset_map = vdpasim_reset_map, .bind_mm = vdpasim_bind_mm, .unbind_mm = vdpasim_unbind_mm, .free = vdpasim_free,