From nobody Wed Nov 27 00:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1701975065; cv=none; d=zohomail.com; s=zohoarc; b=HsGRfIBGY24cq4Or8IfbI8o/a6WcHtjqccE57ZEnPqGfefVUubEwJx1v0kD1TvRxkVyFCZ7uGAIacieMni3f3rfT8EAH42gEwzhxcj1wkziAxSFzjzAshHFs5XfQg8UfsPRaCaGcDivKCRpMi9/tU3Qx9bDrYu0lfX/zy8siOCA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701975065; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=WV4sUfF5I3w3RvpHyGhWljID/vuAV76E/h7M5U6kv78=; b=WP9o65g1gpnmd6w8Vsmo4DMtNeXf1y1ZbOWRyYHjJU0xPdKhC74/OCtRp1sO2cOeFo3DpDy2o38kKJv0AVeUJpNDwOhBlA+IanpQJZegzC+r3VfGpXWVH7hQu8JHXfMxF5vbWUw6HDvOF7pcvy4EyERpbCuGEinfy9DmTdwuak0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1701975065771624.5848665374353; Thu, 7 Dec 2023 10:51:05 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBJRz-0003Ta-F5; Thu, 07 Dec 2023 13:50:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJRx-0003T8-OX for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:17 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJRv-0006Dv-VO for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:17 -0500 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7IDQpl023130; Thu, 7 Dec 2023 18:50:12 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3utdmbmns8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:12 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7Hb9Hc039550; Thu, 7 Dec 2023 18:50:11 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3utan7vh4g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:11 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3B7Io9xs008067; Thu, 7 Dec 2023 18:50:10 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3utan7vh2k-2; Thu, 07 Dec 2023 18:50:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=WV4sUfF5I3w3RvpHyGhWljID/vuAV76E/h7M5U6kv78=; b=GlRaKOyfLefvqxkVBaT7fPwPSab9JTMhNzlZBUZHTbzT9djiYxjlAidhHryRGr6oiKVT MclRRAdD2dyArZ/ScTHQ9oWVka4HhMaMF8pWWbrMWAF8qxO31uCCNbV1hkt3hPP43zOo GJ3zqw6gSN4OvxqKChxitPwbJ2VWwFpzdBwOGTi22GCh4TPz0JgOA2s0I/JZX08NTXJf Z/QddeV6onWCUgN6g1XMiyWUwVzbIPV3Qpxvb7zCnMyfI2ElsJlaaRMz42Ki5645kRyF ccOGXiU+eVvIe+vb1UmMQ8mAGxW6Q6a+SvHvmctIJjEaZAdcyS8GMmtzyPosTbVM4ePs cw== From: Si-Wei Liu To: eperezma@redhat.com, jasowang@redhat.com, mst@redhat.com, dtatulea@nvidia.com, leiyang@redhat.com, yin31149@gmail.com, boris.ostrovsky@oracle.com, jonah.palmer@oracle.com Cc: qemu-devel@nongnu.org Subject: [PATCH 01/40] linux-headers: add vhost_types.h and vhost.h Date: Thu, 7 Dec 2023 09:39:14 -0800 Message-Id: <1701970793-6865-2-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> References: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-07_15,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312070156 X-Proofpoint-ORIG-GUID: 15U65VgEl2kNN_4GM6IkKHJ_tpagXkKs X-Proofpoint-GUID: 15U65VgEl2kNN_4GM6IkKHJ_tpagXkKs Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.177.32; envelope-from=si-wei.liu@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1701975067990100015 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Si-Wei Liu --- include/standard-headers/linux/vhost_types.h | 13 +++++++++++++ linux-headers/linux/vhost.h | 9 +++++++++ 2 files changed, 22 insertions(+) diff --git a/include/standard-headers/linux/vhost_types.h b/include/standar= d-headers/linux/vhost_types.h index 5ad07e1..c39199b 100644 --- a/include/standard-headers/linux/vhost_types.h +++ b/include/standard-headers/linux/vhost_types.h @@ -185,5 +185,18 @@ struct vhost_vdpa_iova_range { * DRIVER_OK */ #define VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK 0x6 +/* Device can be resumed */ +#define VHOST_BACKEND_F_RESUME 0x5 +/* Device supports the driver enabling virtqueues both before and after + * DRIVER_OK + */ +#define VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK 0x6 +/* Device may expose the virtqueue's descriptor area, driver area and + * device area to a different group for ASID binding than where its + * buffers may reside. Requires VHOST_BACKEND_F_IOTLB_ASID. + */ +#define VHOST_BACKEND_F_DESC_ASID 0x7 +/* IOTLB don't flush memory mapping across device reset */ +#define VHOST_BACKEND_F_IOTLB_PERSIST 0x8 =20 #endif diff --git a/linux-headers/linux/vhost.h b/linux-headers/linux/vhost.h index f5c48b6..c61c687 100644 --- a/linux-headers/linux/vhost.h +++ b/linux-headers/linux/vhost.h @@ -219,4 +219,13 @@ */ #define VHOST_VDPA_RESUME _IO(VHOST_VIRTIO, 0x7E) =20 +/* Get the dedicated group for the descriptor table of a virtqueue: + * read index, write group in num. + * The virtqueue index is stored in the index field of vhost_vring_state. + * The group id for the descriptor table of this specific virtqueue + * is returned via num field of vhost_vring_state. + */ +#define VHOST_VDPA_GET_VRING_DESC_GROUP _IOWR(VHOST_VIRTIO, 0x7F, \ + struct vhost_vring_state) + #endif --=20 1.8.3.1 From nobody Wed Nov 27 00:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1701975065; cv=none; d=zohomail.com; s=zohoarc; b=emY+8fJI5tuJeovlbLCnZmoXYF9eZPExXNq3sMgEvnaPPL5V8C6gSoAh/G++ru6HCsaVOXwVrEhuaXPtzIa9OeetVG9a9lBtwHV2xKWruFbSKTlIwNWDqU4H3zTMJGLKj3bbexEZw+tU+PEbDHD0Imc90QrcrVyqIkHtzfnT8/w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701975065; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=TrIoq3vUpKqQshngqQYAQZZona36DrqAj6vqchuF/wo=; b=gUdjf/b7bTGQ4GIsc7vaboQPRThwR5DlY0sIbPhBhfhvlki5kU0RNgYqGAyJkmEBupE4n/RAJD04F06UoicxQKbd2sEwlWT+cZe1Tm6XTxyEc3BipZnEzbwT5tmtXikbAdt/V5gPj12VNCdfh3x6I4YWCB8az9Ff2VdG7tpglxU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1701975065705899.328944947739; Thu, 7 Dec 2023 10:51:05 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBJSA-0003X9-Th; Thu, 07 Dec 2023 13:50:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJRy-0003TS-Vb for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:19 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJRx-0006Lr-Cu for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:18 -0500 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7FDI5Y009711; Thu, 7 Dec 2023 18:50:14 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3utdrvmpev-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:14 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7IUvxb039487; Thu, 7 Dec 2023 18:50:13 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3utan7vh5k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:13 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3B7Io9xu008067; Thu, 7 Dec 2023 18:50:12 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3utan7vh2k-3; Thu, 07 Dec 2023 18:50:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=TrIoq3vUpKqQshngqQYAQZZona36DrqAj6vqchuF/wo=; b=KL3i9z0Dolluz6H13ajkTJhmcAgaEmtrjZFMPQzJzaxyzaOtvFTZEF4oV30RBXq2bvMo I+wbYkbNaDj4KmWLxX5iu5eTf1AdwPyJ3q3FC31JJlCb0rm3+Y0YUg/96TgixKHo/0Hi 6HMP4H4+TRBCR1j0CrnkVMcQkUxj7TEv4Jn9BZ8luT83B4VXTTMuugynaDYsuleSnaAg lCGGxmq4VfeA9oICx9hKUlyShQqtEDOiSxRNSQjlEQW0zJj6LleQN/3xOqCvgJbFfJ/X lenWTV2Sa0Anp3EQTBeRAb8fdlaQCITHo1LD/6f/EbXDB6SA2HdGABqknmVLMAg0+nJe 5Q== From: Si-Wei Liu To: eperezma@redhat.com, jasowang@redhat.com, mst@redhat.com, dtatulea@nvidia.com, leiyang@redhat.com, yin31149@gmail.com, boris.ostrovsky@oracle.com, jonah.palmer@oracle.com Cc: qemu-devel@nongnu.org Subject: [PATCH 02/40] vdpa: add vhost_vdpa_get_vring_desc_group Date: Thu, 7 Dec 2023 09:39:15 -0800 Message-Id: <1701970793-6865-3-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> References: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-07_15,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312070156 X-Proofpoint-GUID: bmLNHMZTQo4Ac7POoz9aONmEpHuNHn7K X-Proofpoint-ORIG-GUID: bmLNHMZTQo4Ac7POoz9aONmEpHuNHn7K Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.177.32; envelope-from=si-wei.liu@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1701975066008100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Internal API to get the descriptor group index for a specific virtqueue through the VHOST_VDPA_GET_VRING_DESC_GROUP ioctl. Signed-off-by: Si-Wei Liu Acked-by: Jason Wang --- net/vhost-vdpa.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 90f4128..887c329 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -471,6 +471,25 @@ static int64_t vhost_vdpa_get_vring_group(int device_f= d, unsigned vq_index, return state.num; } =20 +static int64_t vhost_vdpa_get_vring_desc_group(int device_fd, + unsigned vq_index, + Error **errp) +{ + struct vhost_vring_state state =3D { + .index =3D vq_index, + }; + int r =3D ioctl(device_fd, VHOST_VDPA_GET_VRING_DESC_GROUP, &state); + + if (unlikely(r < 0)) { + r =3D -errno; + error_setg_errno(errp, errno, "Cannot get VQ %u descriptor group", + vq_index); + return r; + } + + return state.num; +} + static int vhost_vdpa_set_address_space_id(struct vhost_vdpa *v, unsigned vq_group, unsigned asid_num) --=20 1.8.3.1 From nobody Wed Nov 27 00:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1701975158; cv=none; d=zohomail.com; s=zohoarc; b=CP5uZtdcX2es9toNx0e9lkazu2YbvPp+RBf3q82rADpdSR/lj6F+tdIBEn5wCGE8JvBsycoJZHen+p39W3VDCpwWh8myAqezfGfnUKWX0wglppwrcs0IRwvv1EGKo4IwZfb6K5eBbaMQtZ/+qgWlcnd7EkbKg3wzIqYfkql2vMw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701975158; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BqSj62+diHUsR87x+1wTb6AuDlUE/ZCVpHyqeDC2E4E=; b=E8kIfOaKhimBcMDJiOsipkJCQZQ/KFtJcR7J6YGaOy3I0YJ/tA/ZHIbXX0AGXBOlp33wr5tTW3zvZfthNsWgyVhTWxKtObXEuWLkp1OF8WjPmjMkEy0r8MHXhlq6fluHC7Afx0inXuoufcpXCUMTGQV+WOioeVI1dPOOsE28iWk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1701975158549488.3906312144293; Thu, 7 Dec 2023 10:52:38 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBJSI-0003Ys-4M; Thu, 07 Dec 2023 13:50:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJS6-0003U7-JB for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:28 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJS0-0006Xt-DC for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:24 -0500 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7InWTp000621; Thu, 7 Dec 2023 18:50:17 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3utd0mmh4b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:16 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7IltKg039527; Thu, 7 Dec 2023 18:50:16 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3utan7vh7d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:16 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3B7Io9xw008067; Thu, 7 Dec 2023 18:50:15 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3utan7vh2k-4; Thu, 07 Dec 2023 18:50:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=BqSj62+diHUsR87x+1wTb6AuDlUE/ZCVpHyqeDC2E4E=; b=Ii27jVM2QxmN8r8GV7zmQ12Y8VH6dWmxM+ZrDYAqjRRu+pqkSCmNwW/51VVUhd8AMY2O akMycakkvLA9FdZDlF7gxZuwPZQ5f/KjsWJWcRvcNK4nDtr8V6YLvVeU97dnR/UNLvJ/ LEUpMP6Tm+utEAd9jhtKPCPZCs4PcE8q1N2meerF9IXkMkDJLoFhr92+z030uVv7GZ45 noRG091o6W5YU91bVyvVO9yY4OqTXX7pZxP5nUAllDpZxMSCW6vaRpzt1gLbWgolc2aH NipgGh76FloBYs2164BOY8jIVkMmPIUzzgHCAVvInJItLfZ6FGt59Ey1DND9c7TqB8Lr 6g== From: Si-Wei Liu To: eperezma@redhat.com, jasowang@redhat.com, mst@redhat.com, dtatulea@nvidia.com, leiyang@redhat.com, yin31149@gmail.com, boris.ostrovsky@oracle.com, jonah.palmer@oracle.com Cc: qemu-devel@nongnu.org Subject: [PATCH 03/40] vdpa: probe descriptor group index for data vqs Date: Thu, 7 Dec 2023 09:39:16 -0800 Message-Id: <1701970793-6865-4-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> References: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-07_15,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312070156 X-Proofpoint-GUID: sr7q8q4OSq04SprcZhsiDUxgdZbDOoRP X-Proofpoint-ORIG-GUID: sr7q8q4OSq04SprcZhsiDUxgdZbDOoRP Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.165.32; envelope-from=si-wei.liu@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1701975159949100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Getting it ahead at initialization time instead of start time allows decision making independent of device status, while reducing failure possibility in starting device or during migration. Adding function vhost_vdpa_probe_desc_group() for that end. This function will be used to probe the descriptor group for data vqs. Signed-off-by: Si-Wei Liu --- net/vhost-vdpa.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 89 insertions(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 887c329..0cf3147 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -1688,6 +1688,95 @@ out: return r; } =20 +static int vhost_vdpa_probe_desc_group(int device_fd, uint64_t features, + int vq_index, int64_t *desc_grpidx, + Error **errp) +{ + uint64_t backend_features; + int64_t vq_group, desc_group; + uint8_t saved_status =3D 0; + uint8_t status =3D 0; + int r; + + ERRP_GUARD(); + + r =3D ioctl(device_fd, VHOST_GET_BACKEND_FEATURES, &backend_features); + if (unlikely(r < 0)) { + error_setg_errno(errp, errno, "Cannot get vdpa backend_features"); + return r; + } + + if (!(backend_features & BIT_ULL(VHOST_BACKEND_F_IOTLB_ASID))) { + return 0; + } + + if (!(backend_features & BIT_ULL(VHOST_BACKEND_F_DESC_ASID))) { + return 0; + } + + r =3D ioctl(device_fd, VHOST_VDPA_GET_STATUS, &saved_status); + if (unlikely(r)) { + error_setg_errno(errp, -r, "Cannot get device status"); + goto out; + } + + r =3D ioctl(device_fd, VHOST_VDPA_SET_STATUS, &status); + if (unlikely(r)) { + error_setg_errno(errp, -r, "Cannot reset device"); + goto out; + } + + r =3D ioctl(device_fd, VHOST_SET_FEATURES, &features); + if (unlikely(r)) { + error_setg_errno(errp, errno, "Cannot set features"); + } + + status =3D VIRTIO_CONFIG_S_ACKNOWLEDGE | + VIRTIO_CONFIG_S_DRIVER | + VIRTIO_CONFIG_S_FEATURES_OK; + + r =3D ioctl(device_fd, VHOST_VDPA_SET_STATUS, &status); + if (unlikely(r)) { + error_setg_errno(errp, -r, "Cannot set device status"); + goto out; + } + + vq_group =3D vhost_vdpa_get_vring_group(device_fd, vq_index, errp); + if (unlikely(vq_group < 0)) { + if (vq_group !=3D -ENOTSUP) { + r =3D vq_group; + goto out; + } + + /* + * The kernel report VHOST_BACKEND_F_IOTLB_ASID if the vdpa fronte= nd + * support ASID even if the parent driver does not. + */ + error_free(*errp); + *errp =3D NULL; + r =3D 0; + goto out; + } + + desc_group =3D vhost_vdpa_get_vring_desc_group(device_fd, vq_index, + errp); + if (unlikely(desc_group < 0)) { + r =3D desc_group; + goto out; + } else if (desc_group !=3D vq_group) { + *desc_grpidx =3D desc_group; + } + r =3D 1; + +out: + status =3D 0; + ioctl(device_fd, VHOST_VDPA_SET_STATUS, &status); + if (saved_status) { + ioctl(device_fd, VHOST_VDPA_SET_STATUS, &saved_status); + } + return r; +} + static NetClientState *net_vhost_vdpa_init(NetClientState *peer, const char *device, const char *name, --=20 1.8.3.1 From nobody Wed Nov 27 00:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1701975065; cv=none; d=zohomail.com; s=zohoarc; b=T/vAHly/HNBG5Y8T2zH8It6JrlyFUqDUv+Z1PDSH4ETnqmpmt/DSoyVjp+GHm4JRaAAsqBCS3Rr+AtMr3g3szHY6gZg7BEZp5ndIgifx5jplatWYmK4zyBWNhQ+DAOrzUGfgKlW+y52mHRlHlqCMIdLSR/E28dZh6fY+WApLWyQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701975065; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=PXaBos3iadjASSJZj10OoTka/EF5tVh7f2/9jG/IaBk=; b=DMLK27mZ/PHqqLBxgSS1ffBulu8Zqgjo4rUH94dPXqSWSlV+e/9qArID+UQ10Xc3WbnbDeHrsNqnwTqCtn0YlYlBTovq1bxi+LHAku7hbk/+dvvlLQAK0vGm6m2VFZ3ieHoAwZgCNjSvoe8rZ2l14yuUpACYc1twj6DhZvWmDBU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1701975065631902.2821324872874; Thu, 7 Dec 2023 10:51:05 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBJSC-0003XO-JO; Thu, 07 Dec 2023 13:50:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJS5-0003U6-8t for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:27 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJS0-0006Z3-DK for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:24 -0500 Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7HY0pW009542; Thu, 7 Dec 2023 18:50:19 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3utd1gcshf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:18 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7HQKhr039445; Thu, 7 Dec 2023 18:50:17 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3utan7vh90-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:17 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3B7Io900008067; Thu, 7 Dec 2023 18:50:17 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3utan7vh2k-5; Thu, 07 Dec 2023 18:50:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=PXaBos3iadjASSJZj10OoTka/EF5tVh7f2/9jG/IaBk=; b=QIomfy/rCMx5KAtw18PQeVo/HP37wR3SPJZ9wAymwaedglXoFqYf+cU5nH+7BTalpuD7 hjWwKOSTitIru0/IkRb/85U/1BqHg3PwiGL6XVZgqqs/5/o9Fam43UdmX32/nD6qm2OR zGQSlvScJiHTp8hulAD9vzISn03DBNPREXGIx+RFjRx7ahR56duC3B4WR2lYEHWaF3Xh osHxzhNZ+vrC9oe+hVQZire88BLpjXKMCQ2LmCFVqiW4TcTj9tKwoO9V+ESXu7eakQNd xTr84XVhawd80Nk3r21Bxb593kvbFyQYFtR+033slTYXSum1l/x0uKeWAxOComx7wjfB Ww== From: Si-Wei Liu To: eperezma@redhat.com, jasowang@redhat.com, mst@redhat.com, dtatulea@nvidia.com, leiyang@redhat.com, yin31149@gmail.com, boris.ostrovsky@oracle.com, jonah.palmer@oracle.com Cc: qemu-devel@nongnu.org Subject: [PATCH 04/40] vdpa: piggyback desc_group index when probing isolated cvq Date: Thu, 7 Dec 2023 09:39:17 -0800 Message-Id: <1701970793-6865-5-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> References: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-07_15,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312070156 X-Proofpoint-ORIG-GUID: h2pRchlMPATXGGR-NWKj99Zcx7z4f-Fx X-Proofpoint-GUID: h2pRchlMPATXGGR-NWKj99Zcx7z4f-Fx Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.177.32; envelope-from=si-wei.liu@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1701975066019100003 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Same as the previous commit, but do it for cvq instead of data vqs. Signed-off-by: Si-Wei Liu --- net/vhost-vdpa.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 0cf3147..cb5705d 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -1601,16 +1601,19 @@ static const VhostShadowVirtqueueOps vhost_vdpa_net= _svq_ops =3D { }; =20 /** - * Probe if CVQ is isolated + * Probe if CVQ is isolated, and piggyback its descriptor group + * index if supported * * @device_fd The vdpa device fd * @features Features offered by the device. * @cvq_index The control vq pair index + * @desc_grpidx The CVQ's descriptor group index to return * - * Returns <0 in case of failure, 0 if false and 1 if true. + * Returns <0 in case of failure, 0 if false and 1 if true (isolated). */ static int vhost_vdpa_probe_cvq_isolation(int device_fd, uint64_t features, - int cvq_index, Error **errp) + int cvq_index, int64_t *desc_grp= idx, + Error **errp) { uint64_t backend_features; int64_t cvq_group; @@ -1667,6 +1670,13 @@ static int vhost_vdpa_probe_cvq_isolation(int device= _fd, uint64_t features, goto out; } =20 + if (backend_features & BIT_ULL(VHOST_BACKEND_F_DESC_ASID)) { + int64_t desc_group =3D vhost_vdpa_get_vring_desc_group(device_fd, + cvq_index, er= rp); + if (likely(desc_group >=3D 0) && desc_group !=3D cvq_group) + *desc_grpidx =3D desc_group; + } + for (int i =3D 0; i < cvq_index; ++i) { int64_t group =3D vhost_vdpa_get_vring_group(device_fd, i, errp); if (unlikely(group < 0)) { @@ -1685,6 +1695,8 @@ static int vhost_vdpa_probe_cvq_isolation(int device_= fd, uint64_t features, out: status =3D 0; ioctl(device_fd, VHOST_VDPA_SET_STATUS, &status); + status =3D VIRTIO_CONFIG_S_ACKNOWLEDGE | VIRTIO_CONFIG_S_DRIVER; + ioctl(device_fd, VHOST_VDPA_SET_STATUS, &status); return r; } =20 @@ -1791,6 +1803,7 @@ static NetClientState *net_vhost_vdpa_init(NetClientS= tate *peer, Error **errp) { NetClientState *nc =3D NULL; + int64_t desc_group =3D -1; VhostVDPAState *s; int ret =3D 0; assert(name); @@ -1802,7 +1815,7 @@ static NetClientState *net_vhost_vdpa_init(NetClientS= tate *peer, } else { cvq_isolated =3D vhost_vdpa_probe_cvq_isolation(vdpa_device_fd, fe= atures, queue_pair_index * 2, - errp); + &desc_group, errp); if (unlikely(cvq_isolated < 0)) { return NULL; } --=20 1.8.3.1 From nobody Wed Nov 27 00:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1701975154; cv=none; d=zohomail.com; s=zohoarc; b=F2qCA5g/m/8NQqaA12K3PY3c0TcxkPEHUaaCYSyZuU6Y5IdqLy+yKHj4+GL4Xv4rbEF4UAqyhOG8DxN/+eUPA5n69kk9zm+VYVtTl55RvRlGsXmlEk4mGAYaWMGgnHEEzu/SayaEn7A2KfNKupFCDRCmFlci7oHy0r7ThR4EMUg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701975154; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=VXUEwdiXIGYALuEd5KfW5mDWOK4SrCBkiWVuRQsjMa4=; b=P7XR9XpKBHy7sQeXo/WFQJoXZbY0n4CW/A1gJmaMaNLc3lNnqRySfo9ch4RmKNPB4NDbVEVl/YgA9mKNZ5PV5U12zwXBtRSri9Q9miG/4rEF+ZyD0l8wJXi2VeXsNb60wD7mvp67Tr+w1KwEZ2NK2jYOL35SwBqttyjt8EVp4Lc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1701975154774209.39925053273578; Thu, 7 Dec 2023 10:52:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBJSJ-0003ZM-5t; Thu, 07 Dec 2023 13:50:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJS6-0003U8-J2 for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:28 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJS1-0006bb-Jd for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:25 -0500 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7EtISZ017262; Thu, 7 Dec 2023 18:50:20 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3utdrvmpf0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:20 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7Hb9ff039324; Thu, 7 Dec 2023 18:50:19 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3utan7vhap-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:19 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3B7Io902008067; Thu, 7 Dec 2023 18:50:18 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3utan7vh2k-6; Thu, 07 Dec 2023 18:50:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=VXUEwdiXIGYALuEd5KfW5mDWOK4SrCBkiWVuRQsjMa4=; b=QgvsHVMwQspdOf1YmV914EB0wo3+2FbdlN4orY7UmijBuCCAyc6/vkAitd1pllzL1xRE dEXeM0dXqds0nD8vif6fPLhiKhnkUDQ5tfMxRtJx7Ypz8X+GRql8eiuE27Y4mFLf9T97 NYl9RoRclTFIWdk1h9peOZUD0HOl3c5/uncZlFiwR/BDSzzcOCkea0NsFFMNte0pXWgN njc61K/SuDFuWWck+2Xl6UXR09YCtOyOAMCy/PfnxhGNCX97ACPBTnL2k/efLzEP7MJ8 rn3xfQW6GWbmwY/SFFfycvP+g/DEvZioMz1y4tHnJBYUFmeFVu5dBiUHwhC8kggMtZSz Gg== From: Si-Wei Liu To: eperezma@redhat.com, jasowang@redhat.com, mst@redhat.com, dtatulea@nvidia.com, leiyang@redhat.com, yin31149@gmail.com, boris.ostrovsky@oracle.com, jonah.palmer@oracle.com Cc: qemu-devel@nongnu.org Subject: [PATCH 05/40] vdpa: populate desc_group from net_vhost_vdpa_init Date: Thu, 7 Dec 2023 09:39:18 -0800 Message-Id: <1701970793-6865-6-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> References: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-07_15,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312070156 X-Proofpoint-GUID: xUPjONcvcF8ZQ082lNdJc9WCRsW0WXh5 X-Proofpoint-ORIG-GUID: xUPjONcvcF8ZQ082lNdJc9WCRsW0WXh5 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.177.32; envelope-from=si-wei.liu@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1701975155884100002 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add the desc_group field to struct vhost_vdpa, and get it populated when the corresponding vq is initialized at net_vhost_vdpa_init. If the vq does not have descriptor group capability, or it doesn't have a dedicated ASID group to host descriptors other than the data buffers, desc_group will be set to a negative value -1. Signed-off-by: Si-Wei Liu --- include/hw/virtio/vhost-vdpa.h | 1 + net/vhost-vdpa.c | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h index 6533ad2..63493ff 100644 --- a/include/hw/virtio/vhost-vdpa.h +++ b/include/hw/virtio/vhost-vdpa.h @@ -87,6 +87,7 @@ typedef struct vhost_vdpa { Error *migration_blocker; VhostVDPAHostNotifier notifier[VIRTIO_QUEUE_MAX]; IOMMUNotifier n; + int64_t desc_group; } VhostVDPA; =20 int vhost_vdpa_get_iova_range(int fd, struct vhost_vdpa_iova_range *iova_r= ange); diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index cb5705d..1a738b2 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -1855,11 +1855,22 @@ static NetClientState *net_vhost_vdpa_init(NetClien= tState *peer, =20 ret =3D vhost_vdpa_add(nc, (void *)&s->vhost_vdpa, queue_pair_index, n= vqs); if (ret) { - qemu_del_net_client(nc); - return NULL; + goto err; } =20 + if (is_datapath) { + ret =3D vhost_vdpa_probe_desc_group(vdpa_device_fd, features, + 0, &desc_group, errp); + if (unlikely(ret < 0)) { + goto err; + } + } + s->vhost_vdpa.desc_group =3D desc_group; return nc; + +err: + qemu_del_net_client(nc); + return NULL; } =20 static int vhost_vdpa_get_features(int fd, uint64_t *features, Error **err= p) --=20 1.8.3.1 From nobody Wed Nov 27 00:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1701975503; cv=none; d=zohomail.com; s=zohoarc; b=DitKWedu4a0Sf7QhcBKu26lqraYP48W7Fcz7i6TI1F/RAZjFtaKX0ttL7eBEd/gGS9/NW3vrnMMJne/hL6i2ODx95jC13JJdUho2QYTEh/Os6KBDqX4CpYxviB3+xYV2Pgp1eILMT9NZncZoPFTUUGcd8DD8y/ETvcdUqOyNxlc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701975503; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=bYCoqd8Qwye+lfpvk+32JEchmO62alasv1pCQMgpYZI=; b=PL18UtZrLlXBJqpb5dvUT0nuF9czWygAJfCmOqROCDBnFMedM5N5Xc3VCL+bw11n16uBnYUV5hEElVwiSRfrf1HpvIkFRCFg/ANUuPEgwx33LozxglKeERyS8Gu3Wy9t2f2SzZPNxr6UFmWgWeXj4LoLwc3eacASFvguTMCyuYs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1701975503600562.1702203812755; Thu, 7 Dec 2023 10:58:23 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBJSK-0003ah-Ty; Thu, 07 Dec 2023 13:50:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJS6-0003UD-Pw for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:28 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJS4-0006c6-C7 for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:26 -0500 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7IJEpo006221; Thu, 7 Dec 2023 18:50:22 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3utdabvgde-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:21 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7I1di0039548; Thu, 7 Dec 2023 18:50:20 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3utan7vhch-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:20 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3B7Io904008067; Thu, 7 Dec 2023 18:50:20 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3utan7vh2k-7; Thu, 07 Dec 2023 18:50:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=bYCoqd8Qwye+lfpvk+32JEchmO62alasv1pCQMgpYZI=; b=J6LYaBTF6FrqBs4x4Fb3zO6ZJLtUBPBnyzswuVdFpsNgycOLFEKnNq1jZA/S9emT9wQj M9mv1xJwlh2uh62CtaDIe0Lw2+lCQDQ+IcNPItenDqO9TxlQtoCzG80zvhdwRu5+9gnH ZHg0WL3ZD3WGsdWVihekLjyGEu1iQmR3B/hjHVFrj64budv4i4q45fh3lbOharbLTtIv BHaKWRQqlkFCPK2YRkd6yhn34FZFxCN4Q+9x+GA8iCaE7jhcaLb7Y6hBGu0cF2DdQf10 pTxv3ksvArQEIk/XCJ27xEpOWgnukrmGY+9HWL22qBu33wYBDAcv+uCbOCXP60lAdrj/ 1A== From: Si-Wei Liu To: eperezma@redhat.com, jasowang@redhat.com, mst@redhat.com, dtatulea@nvidia.com, leiyang@redhat.com, yin31149@gmail.com, boris.ostrovsky@oracle.com, jonah.palmer@oracle.com Cc: qemu-devel@nongnu.org Subject: [PATCH 06/40] vhost: make svq work with gpa without iova translation Date: Thu, 7 Dec 2023 09:39:19 -0800 Message-Id: <1701970793-6865-7-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> References: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-07_15,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312070156 X-Proofpoint-ORIG-GUID: ZPTuHOVey7VmsYHA5_lXz1rTlTS7gSQ9 X-Proofpoint-GUID: ZPTuHOVey7VmsYHA5_lXz1rTlTS7gSQ9 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.177.32; envelope-from=si-wei.liu@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1701975503869100002 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Make vhost_svq_vring_write_descs able to work with GPA directly without going through iova tree for translation. This will be needed in the next few patches where the SVQ has dedicated address space to host its virtqueues. Instead of having to translate qemu's VA to IOVA via the iova tree, with dedicated or isolated address space for SVQ descriptors, the IOVA is exactly same as the guest GPA space where translation would not be needed any more. Signed-off-by: Si-Wei Liu Reviewed-by: Eugenio P=C3=A9rez --- hw/virtio/vhost-shadow-virtqueue.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-vi= rtqueue.c index fc5f408..97ccd45 100644 --- a/hw/virtio/vhost-shadow-virtqueue.c +++ b/hw/virtio/vhost-shadow-virtqueue.c @@ -136,8 +136,8 @@ static bool vhost_svq_translate_addr(const VhostShadowV= irtqueue *svq, * Return true if success, false otherwise and print error. */ static bool vhost_svq_vring_write_descs(VhostShadowVirtqueue *svq, hwaddr = *sg, - const struct iovec *iovec, size_t = num, - bool more_descs, bool write) + const struct iovec *iovec, hwaddr = *addr, + size_t num, bool more_descs, bool = write) { uint16_t i =3D svq->free_head, last =3D svq->free_head; unsigned n; @@ -149,8 +149,15 @@ static bool vhost_svq_vring_write_descs(VhostShadowVir= tqueue *svq, hwaddr *sg, return true; } =20 - ok =3D vhost_svq_translate_addr(svq, sg, iovec, num); - if (unlikely(!ok)) { + if (svq->iova_tree) { + ok =3D vhost_svq_translate_addr(svq, sg, iovec, num); + if (unlikely(!ok)) { + return false; + } + } else if (!addr) { + qemu_log_mask(LOG_GUEST_ERROR, + "No translation found for vaddr 0x%p\n", + iovec[0].iov_base); return false; } =20 @@ -161,7 +168,7 @@ static bool vhost_svq_vring_write_descs(VhostShadowVirt= queue *svq, hwaddr *sg, } else { descs[i].flags =3D flags; } - descs[i].addr =3D cpu_to_le64(sg[n]); + descs[i].addr =3D cpu_to_le64(svq->iova_tree ? sg[n] : addr[n]); descs[i].len =3D cpu_to_le32(iovec[n].iov_len); =20 last =3D i; @@ -173,9 +180,10 @@ static bool vhost_svq_vring_write_descs(VhostShadowVir= tqueue *svq, hwaddr *sg, } =20 static bool vhost_svq_add_split(VhostShadowVirtqueue *svq, - const struct iovec *out_sg, size_t out_num, - const struct iovec *in_sg, size_t in_num, - unsigned *head) + const struct iovec *out_sg, hwaddr *out_ad= dr, + size_t out_num, + const struct iovec *in_sg, hwaddr *in_addr, + size_t in_num, unsigned *head) { unsigned avail_idx; vring_avail_t *avail =3D svq->vring.avail; @@ -191,13 +199,14 @@ static bool vhost_svq_add_split(VhostShadowVirtqueue = *svq, return false; } =20 - ok =3D vhost_svq_vring_write_descs(svq, sgs, out_sg, out_num, in_num >= 0, - false); + ok =3D vhost_svq_vring_write_descs(svq, sgs, out_sg, out_addr, out_num, + in_num > 0, false); if (unlikely(!ok)) { return false; } =20 - ok =3D vhost_svq_vring_write_descs(svq, sgs, in_sg, in_num, false, tru= e); + ok =3D vhost_svq_vring_write_descs(svq, sgs, in_sg, in_addr, in_num, + false, true); if (unlikely(!ok)) { return false; } @@ -258,7 +267,9 @@ int vhost_svq_add(VhostShadowVirtqueue *svq, const stru= ct iovec *out_sg, return -ENOSPC; } =20 - ok =3D vhost_svq_add_split(svq, out_sg, out_num, in_sg, in_num, &qemu_= head); + ok =3D vhost_svq_add_split(svq, out_sg, elem ? elem->out_addr : NULL, + out_num, in_sg, elem ? elem->in_addr : NULL, + in_num, &qemu_head); if (unlikely(!ok)) { return -EINVAL; } --=20 1.8.3.1 From nobody Wed Nov 27 00:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1701975421; cv=none; d=zohomail.com; s=zohoarc; b=gQlnhUS8VOTA6Vt+mEjzRTM1AfN/87ZjRgYEXvbz0quyfTlSWSy/m9TvNVbDkEpr03WujloJJm68cRgTKVNniH76Ex+rcdHz5SCCcaDDxRQcRe4H6Ty6065pOUw09Betc8T5SiAgiZre7tGIY5CW1kSKS1ve5HVQ1l9NfeeIXMU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701975421; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=PGF2vwqC9zOw5FzhQrsgKA+MWTLi1jrbI3MPbsVTPJs=; b=fUYdn/m+1041sIbYqswGHVLLRmVXUW2O3H4TbMpLuECZtEyLqObsS7VvxDcgMCZpiD1gd6a+zMqcuFf0CNJlkrJEK2ChyqYQan5dHZ86fCp60D/03o8cdBJ/1+L/7oK2D39q5wgC0SVr4vG+VRTmt6YmFBhi/g9beC6hf24R8o8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1701975421135757.2096423517413; Thu, 7 Dec 2023 10:57:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBJSD-0003Xn-1s; Thu, 07 Dec 2023 13:50:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJS8-0003Vc-Ol for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:28 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJS4-0006cB-Tt for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:28 -0500 Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7IhZjg029893; Thu, 7 Dec 2023 18:50:23 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3utd1gcshk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:23 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7HTkJI039553; Thu, 7 Dec 2023 18:50:22 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3utan7vhe7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:22 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3B7Io906008067; Thu, 7 Dec 2023 18:50:21 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3utan7vh2k-8; Thu, 07 Dec 2023 18:50:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=PGF2vwqC9zOw5FzhQrsgKA+MWTLi1jrbI3MPbsVTPJs=; b=ejwpsie+fYnCTtlG6cq3uEUGAeoydRVfUGNKLBKORTJ5SQbGzSE0LEwXUBWmc64SazfA MPrpCsdyA1Y9OuZH7xpl5qAp6CjQ0AYYjYW73J7tKbBoLR8bTyM9WbXsAmI44Q+gEKc8 3VVZuAZGdYVS50er2n4OeEQ58L4RST/9DRc331YRftl6ZWy6EJy3/7wbKWivYeeQ5pTB p9ef4TzNsAlSSjtWDEZvpo5yl1dQOmItClMHVf//376Jg+Z/r6OzvbRNYk9sG8ie/+9t AYo3AkSjnmovZNk+XHYsJuA51h2pE+xsLwlGcd4CCgJMlz8RsBcuNwHmh+MehHCMdTXG qg== From: Si-Wei Liu To: eperezma@redhat.com, jasowang@redhat.com, mst@redhat.com, dtatulea@nvidia.com, leiyang@redhat.com, yin31149@gmail.com, boris.ostrovsky@oracle.com, jonah.palmer@oracle.com Cc: qemu-devel@nongnu.org Subject: [PATCH 07/40] vdpa: move around vhost_vdpa_set_address_space_id Date: Thu, 7 Dec 2023 09:39:20 -0800 Message-Id: <1701970793-6865-8-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> References: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-07_15,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312070156 X-Proofpoint-ORIG-GUID: YWerNjCqHu8uuacLiG32N_6fvetHPbuP X-Proofpoint-GUID: YWerNjCqHu8uuacLiG32N_6fvetHPbuP Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.177.32; envelope-from=si-wei.liu@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1701975421934100002 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Move it a few lines ahead to make function call easier for those before it. No funtional change involved. Signed-off-by: Si-Wei Liu Acked-by: Jason Wang Reviewed-by: Eugenio P=C3=A9rez --- net/vhost-vdpa.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 1a738b2..dbfa192 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -335,6 +335,24 @@ static void vdpa_net_migration_state_notifier(Notifier= *notifier, void *data) } } =20 +static int vhost_vdpa_set_address_space_id(struct vhost_vdpa *v, + unsigned vq_group, + unsigned asid_num) +{ + struct vhost_vring_state asid =3D { + .index =3D vq_group, + .num =3D asid_num, + }; + int r; + + r =3D ioctl(v->shared->device_fd, VHOST_VDPA_SET_GROUP_ASID, &asid); + if (unlikely(r < 0)) { + error_report("Can't set vq group %u asid %u, errno=3D%d (%s)", + asid.index, asid.num, errno, g_strerror(errno)); + } + return r; +} + static void vhost_vdpa_net_data_start_first(VhostVDPAState *s) { struct vhost_vdpa *v =3D &s->vhost_vdpa; @@ -490,24 +508,6 @@ static int64_t vhost_vdpa_get_vring_desc_group(int dev= ice_fd, return state.num; } =20 -static int vhost_vdpa_set_address_space_id(struct vhost_vdpa *v, - unsigned vq_group, - unsigned asid_num) -{ - struct vhost_vring_state asid =3D { - .index =3D vq_group, - .num =3D asid_num, - }; - int r; - - r =3D ioctl(v->shared->device_fd, VHOST_VDPA_SET_GROUP_ASID, &asid); - if (unlikely(r < 0)) { - error_report("Can't set vq group %u asid %u, errno=3D%d (%s)", - asid.index, asid.num, errno, g_strerror(errno)); - } - return r; -} - static void vhost_vdpa_cvq_unmap_buf(struct vhost_vdpa *v, void *addr) { VhostIOVATree *tree =3D v->shared->iova_tree; --=20 1.8.3.1 From nobody Wed Nov 27 00:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1701975166; cv=none; d=zohomail.com; s=zohoarc; b=KGxPh6zqFaxQ7akyQES1nS7HlXuCOk26eCXFfnYTyBBePzM2S/vhpYEr/DkP1CyU4kyKVjjbtp5Oa9lKz+39W0LGqgjaHz5B2r6Qy4rF4ffdVj2+/pnVJSgyZUF9u8gJdoD6kiQxFDd5u38/YqzhWsSUTvumbwB9rH/xncgsOts= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701975166; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=AFnkWpXumI0VNgX4CkUuacA8JaKOefBrdVfykfxK9Es=; b=eRPDgbAV7/WhBfhwAkiB4bpBvlhM5bowpgUNqHgq/v+73ZwF10ORTz2nHEwYiQwOvIDs12g8kLTLNAciJUbuxGuRpSfA966HFXJTftO6+G/8Dwlh1sXZZ9XlQuIncJ1Wz+waSD0AxRK3JRXAfvoK0SdxEJ3Gx5o++556+FCbaPU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 170197516620491.2738042548317; Thu, 7 Dec 2023 10:52:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBJSf-0003em-MI; Thu, 07 Dec 2023 13:51:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJS9-0003X0-NM for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:29 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJS6-0006id-Rm for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:29 -0500 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7InVtB000565; Thu, 7 Dec 2023 18:50:24 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3utd0mmh4k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:24 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7IiBkc039465; Thu, 7 Dec 2023 18:50:23 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3utan7vhfr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:23 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3B7Io908008067; Thu, 7 Dec 2023 18:50:23 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3utan7vh2k-9; Thu, 07 Dec 2023 18:50:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=AFnkWpXumI0VNgX4CkUuacA8JaKOefBrdVfykfxK9Es=; b=FkbouOX+lr0/aGQfIuQv0U9MnOKGISxQMtTIsCZnfgivurX+o3koo3z+yPEhmuaQdcFY kamsNbNj7xTE7QQ93xDXxmxoENK+ttvPZxZK6vxt+uFwdV3h8xAiRH5aZRDhxz0n6RHe t1KXg4IkQG/MfmJFk+9S5Wf+o9AqYPUFhbNPDabYh3/Es2o6whqsEQTyLQa7NYILpMs2 LLZCTlF306JD8LnZFkDEOMH8+QIaEnIJFkladcVnCOcOYm79i/ZJr7A21FiQfdowiM2G 7831zRg9unIiBzVxkRS3rYoxLIBF+XDiQbsqrhN4y0ej3q5KmYXFl+vnYJKvKB4NZHBf zA== From: Si-Wei Liu To: eperezma@redhat.com, jasowang@redhat.com, mst@redhat.com, dtatulea@nvidia.com, leiyang@redhat.com, yin31149@gmail.com, boris.ostrovsky@oracle.com, jonah.palmer@oracle.com Cc: qemu-devel@nongnu.org Subject: [PATCH 08/40] vdpa: add back vhost_vdpa_net_first_nc_vdpa Date: Thu, 7 Dec 2023 09:39:21 -0800 Message-Id: <1701970793-6865-9-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> References: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-07_15,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312070156 X-Proofpoint-GUID: sW8woUfvFtB6gf9_u20fckzmqpo6W94W X-Proofpoint-ORIG-GUID: sW8woUfvFtB6gf9_u20fckzmqpo6W94W Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.165.32; envelope-from=si-wei.liu@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1701975168220100005 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Previous commits had it removed. Now adding it back because this function will be needed by next patches. Signed-off-by: Si-Wei Liu Reviewed-by: Eugenio P=C3=A9rez --- net/vhost-vdpa.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index dbfa192..c9bfc6f 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -287,6 +287,16 @@ static ssize_t vhost_vdpa_receive(NetClientState *nc, = const uint8_t *buf, return size; } =20 + +/** From any vdpa net client, get the netclient of the first queue pair */ +static VhostVDPAState *vhost_vdpa_net_first_nc_vdpa(VhostVDPAState *s) +{ + NICState *nic =3D qemu_get_nic(s->nc.peer); + NetClientState *nc0 =3D qemu_get_peer(nic->ncs, 0); + + return DO_UPCAST(VhostVDPAState, nc, nc0); +} + static void vhost_vdpa_net_log_global_enable(VhostVDPAState *s, bool enabl= e) { struct vhost_vdpa *v =3D &s->vhost_vdpa; @@ -566,7 +576,7 @@ dma_map_err: =20 static int vhost_vdpa_net_cvq_start(NetClientState *nc) { - VhostVDPAState *s; + VhostVDPAState *s, *s0; struct vhost_vdpa *v; int64_t cvq_group; int r; @@ -577,7 +587,8 @@ static int vhost_vdpa_net_cvq_start(NetClientState *nc) s =3D DO_UPCAST(VhostVDPAState, nc, nc); v =3D &s->vhost_vdpa; =20 - v->shadow_vqs_enabled =3D v->shared->shadow_data; + s0 =3D vhost_vdpa_net_first_nc_vdpa(s); + v->shadow_vqs_enabled =3D s0->vhost_vdpa.shadow_vqs_enabled; s->vhost_vdpa.address_space_id =3D VHOST_VDPA_GUEST_PA_ASID; =20 if (v->shared->shadow_data) { --=20 1.8.3.1 From nobody Wed Nov 27 00:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1701975065; cv=none; d=zohomail.com; s=zohoarc; b=lDOmHF2jEl86v9RQ/7de/Hs6NZXFjg2xUsvuz0cg/vy8lcZV6bM0Y7VYUcHqrZ+cJmCzy8yhi/JYKPQJ8hYE0fpj/8xfcW8oe9B07XDgzTGMUYZJrc7jogTHao+aHbHI4LSvRWrKVoS5Re/JmKMEMsl6zKytMtbMh4Reh65MM+w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701975065; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=twV6mGc+nRkfELdaEpOqp368u6C8dpOt4AY5JIu7iLY=; b=TiMydmkviNMRGsKWj5HDFHvH3FZoVVagrh/CVyDu1SEMwL6mM2qL+MrYzQPKQ+QU3fr0Jv+FOiwtnuCZ4SimqEVEMNl/Au3mZPgqt6bHQ8ccNQNhncwfu7rZN0ty8tyI8ETkDbhO9AYFqFOh0K8p3A9vpPlzThFbaKK+E1V3DJs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1701975065580149.01445951399216; Thu, 7 Dec 2023 10:51:05 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBJSJ-0003aE-Ql; Thu, 07 Dec 2023 13:50:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSA-0003XC-JC for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:30 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJS8-0006p2-RW for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:30 -0500 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 3B7HFTxO007979; Thu, 7 Dec 2023 18:50:26 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3utd0hmjt8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:25 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7HhN4P039752; Thu, 7 Dec 2023 18:50:25 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3utan7vhh4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:25 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3B7Io90A008067; Thu, 7 Dec 2023 18:50:24 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3utan7vh2k-10; Thu, 07 Dec 2023 18:50:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=twV6mGc+nRkfELdaEpOqp368u6C8dpOt4AY5JIu7iLY=; b=lstrWVEIEgBeg9R9/CfuziQOw5skbokGBSRzp6tkt0MkomJH3hJent7GA78cNjrkFTC0 +9M5YNkmdMT25HemCfRzozvFueeXwM2Ss4jLofSFY83IG4g0+c0Q31Z0BrEpuRYwQ6JR 9/jdtFyIfW39tIxwJXH4LbZUjgcFl0qKjdGx0y1jqEpD9Rl2KA3MryUn+qV+gtzd24gx dGgT+ETovTckEKbaEoIFTBkr5wQMu58fzjQV+kOvsclRNSlUwiZlaWhOjJ8naahbok+z MucjJXsEK/Q94zkvb7+yHy3ahWLbG5FEkroGJS/jKmV5gaYrHKIyoH+ZZbRDndpVOFbK Yw== From: Si-Wei Liu To: eperezma@redhat.com, jasowang@redhat.com, mst@redhat.com, dtatulea@nvidia.com, leiyang@redhat.com, yin31149@gmail.com, boris.ostrovsky@oracle.com, jonah.palmer@oracle.com Cc: qemu-devel@nongnu.org Subject: [PATCH 09/40] vdpa: no repeat setting shadow_data Date: Thu, 7 Dec 2023 09:39:22 -0800 Message-Id: <1701970793-6865-10-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> References: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-07_15,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=947 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312070156 X-Proofpoint-GUID: cHp_8aKC8Y4Ixecv0cnkyEkjc74aR3XW X-Proofpoint-ORIG-GUID: cHp_8aKC8Y4Ixecv0cnkyEkjc74aR3XW Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.165.32; envelope-from=si-wei.liu@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1701975066008100002 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Since shadow_data is now shared in the parent data struct, it just needs to be set only once by the first vq. This change will make shadow_data independent of svq enabled state, which can be optionally turned off when SVQ descritors and device driver areas are all isolated to a separate address space. Signed-off-by: Si-Wei Liu Acked-by: Jason Wang Reviewed-by: Eugenio P=C3=A9rez --- net/vhost-vdpa.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index c9bfc6f..2555897 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -387,13 +387,12 @@ static int vhost_vdpa_net_data_start(NetClientState *= nc) if (s->always_svq || migration_is_setup_or_active(migrate_get_current()->state)) { v->shadow_vqs_enabled =3D true; - v->shared->shadow_data =3D true; } else { v->shadow_vqs_enabled =3D false; - v->shared->shadow_data =3D false; } =20 if (v->index =3D=3D 0) { + v->shared->shadow_data =3D v->shadow_vqs_enabled; vhost_vdpa_net_data_start_first(s); return 0; } --=20 1.8.3.1 From nobody Wed Nov 27 00:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1701975142; cv=none; d=zohomail.com; s=zohoarc; b=ZWjgd9bpXMFiblU6KQd7Aj92Zrfbw5kq3nRZIQ2CmrjVuKT+ZnSel7SEBQPwSqe3aYiOf7wFj7SV/zbiyc+lvVWFYAmTqHX1M9EJsUAGyfiH0AsVRQznkTx+MnEfoIOpDZ56EbxTFMf0C5qC3ITzRrkBmk2p+eAqt2nrAPMXIFw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701975142; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=1qvAaetJbXbQEOsr+WeZTRGtI7xnUOGqRF8vnQO8kGM=; b=At9QCvw3Qm8bKlA2cwbCr3WPP7J+nIj89Y8TywhpdEQNnJyxm+Q9S7xGQknfEZlD2EThnim25xrTWzpXwl/d3j+N6y2a1zq1SGRLrmF3hNdS3ESrazI1+hqDf14SJ8NGmPl8ZERQYEXaxgXtnDvQVL9D8+HTrGqeTIyyqjV7fM4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1701975142292608.413084881866; Thu, 7 Dec 2023 10:52:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBJSJ-0003ZT-6p; Thu, 07 Dec 2023 13:50:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSB-0003XM-Ba for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:31 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJS9-0006pB-3M for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:30 -0500 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7IJWaO006793; Thu, 7 Dec 2023 18:50:27 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3utdabvgdh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:27 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7IZbmR039504; Thu, 7 Dec 2023 18:50:26 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3utan7vhjm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:26 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3B7Io90C008067; Thu, 7 Dec 2023 18:50:26 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3utan7vh2k-11; Thu, 07 Dec 2023 18:50:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=1qvAaetJbXbQEOsr+WeZTRGtI7xnUOGqRF8vnQO8kGM=; b=T77LF37L05otH+CIttKOwHPIxTBLkd3+rBS5EGqHCaRm3kCna9qtGu+QU4rkY6Y1Se1h 55uwT6HVhYu7jL/msADehEWlkUF+TaXOvz0FAw2ZRUqvE618pDng2z7RT4ffxf0zr0xT rmkPq4DZvrkdZTbXoPTALXqfLNzAscj7+cRfALKsz5SajZk3QeS+RzwwPOxyd1HL3wXT R5IEOl2ZsufuX+0r8d2lfjkwzJ6u1P2ZlkY3f2fnCPgjy0anRTINbNIbOaUKeP75bv7b TZjLEfSItyFyD+zd/WIQTqXlHXtVXLgJJIqzAtpK8GlnDUKIAmvVMJElxumpX/9vIyAG xQ== From: Si-Wei Liu To: eperezma@redhat.com, jasowang@redhat.com, mst@redhat.com, dtatulea@nvidia.com, leiyang@redhat.com, yin31149@gmail.com, boris.ostrovsky@oracle.com, jonah.palmer@oracle.com Cc: qemu-devel@nongnu.org Subject: [PATCH 10/40] vdpa: assign svq descriptors a separate ASID when possible Date: Thu, 7 Dec 2023 09:39:23 -0800 Message-Id: <1701970793-6865-11-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> References: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-07_15,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312070156 X-Proofpoint-ORIG-GUID: bJLr1SmqAfSzL3C9-fvdQ3nlQTxtaNzC X-Proofpoint-GUID: bJLr1SmqAfSzL3C9-fvdQ3nlQTxtaNzC Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.177.32; envelope-from=si-wei.liu@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1701975143655100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" When backend supports the VHOST_BACKEND_F_DESC_ASID feature and all the data vqs can support one or more descriptor group to host SVQ vrings and descriptors, we assign them a different ASID than where its buffers reside in guest memory address space. With this dedicated ASID for SVQs, the IOVA for what vdpa device may care effectively becomes the GPA, thus there's no need to translate IOVA address. For this reason, shadow_data can be turned off accordingly. It doesn't mean the SVQ is not enabled, but just that the translation is not needed from iova tree perspective. We can reuse CVQ's address space ID to host SVQ descriptors because both CVQ and SVQ are emulated in the same QEMU process, which will share the same VA address space. Signed-off-by: Si-Wei Liu --- hw/virtio/vhost-vdpa.c | 5 ++++- net/vhost-vdpa.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++= ---- 2 files changed, 57 insertions(+), 5 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 24844b5..30dff95 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -627,6 +627,7 @@ static int vhost_vdpa_init(struct vhost_dev *dev, void = *opaque, Error **errp) uint64_t qemu_backend_features =3D 0x1ULL << VHOST_BACKEND_F_IOTLB_MSG= _V2 | 0x1ULL << VHOST_BACKEND_F_IOTLB_BATCH= | 0x1ULL << VHOST_BACKEND_F_IOTLB_ASID | + 0x1ULL << VHOST_BACKEND_F_DESC_ASID | 0x1ULL << VHOST_BACKEND_F_SUSPEND; int ret; =20 @@ -1249,7 +1250,9 @@ static bool vhost_vdpa_svqs_start(struct vhost_dev *d= ev) goto err; } =20 - vhost_svq_start(svq, dev->vdev, vq, v->shared->iova_tree); + vhost_svq_start(svq, dev->vdev, vq, + v->desc_group >=3D 0 && v->address_space_id ? + NULL : v->shared->iova_tree); ok =3D vhost_vdpa_svq_map_rings(dev, svq, &addr, &err); if (unlikely(!ok)) { goto err_map; diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 2555897..aebaa53 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -366,20 +366,50 @@ static int vhost_vdpa_set_address_space_id(struct vho= st_vdpa *v, static void vhost_vdpa_net_data_start_first(VhostVDPAState *s) { struct vhost_vdpa *v =3D &s->vhost_vdpa; + int r; =20 migration_add_notifier(&s->migration_state, vdpa_net_migration_state_notifier); =20 + if (!v->shadow_vqs_enabled) { + if (v->desc_group >=3D 0 && + v->address_space_id !=3D VHOST_VDPA_GUEST_PA_ASID) { + vhost_vdpa_set_address_space_id(v, v->desc_group, + VHOST_VDPA_GUEST_PA_ASID); + s->vhost_vdpa.address_space_id =3D VHOST_VDPA_GUEST_PA_ASID; + } + return; + } + /* iova_tree may be initialized by vhost_vdpa_net_load_setup */ - if (v->shadow_vqs_enabled && !v->shared->iova_tree) { + if (!v->shared->iova_tree) { v->shared->iova_tree =3D vhost_iova_tree_new(v->shared->iova_range= .first, v->shared->iova_range.l= ast); } + + if (s->always_svq || v->desc_group < 0) { + return; + } + + r =3D vhost_vdpa_set_address_space_id(v, v->desc_group, + VHOST_VDPA_NET_CVQ_ASID); + if (unlikely(r < 0)) { + /* The other data vqs should also fall back to using the same ASID= */ + s->vhost_vdpa.address_space_id =3D VHOST_VDPA_GUEST_PA_ASID; + return; + } + + /* No translation needed on data SVQ when descriptor group is used */ + s->vhost_vdpa.address_space_id =3D VHOST_VDPA_NET_CVQ_ASID; + s->vhost_vdpa.shared->shadow_data =3D false; + return; } =20 static int vhost_vdpa_net_data_start(NetClientState *nc) { VhostVDPAState *s =3D DO_UPCAST(VhostVDPAState, nc, nc); + VhostVDPAState *s0 =3D vhost_vdpa_net_first_nc_vdpa(s); + struct vhost_vdpa *v =3D &s->vhost_vdpa; =20 assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA); @@ -397,6 +427,18 @@ static int vhost_vdpa_net_data_start(NetClientState *n= c) return 0; } =20 + if (v->desc_group >=3D 0 && v->desc_group !=3D s0->vhost_vdpa.desc_gro= up) { + unsigned asid; + asid =3D v->shadow_vqs_enabled ? + s0->vhost_vdpa.address_space_id : VHOST_VDPA_GUEST_PA_ASID; + if (asid !=3D s->vhost_vdpa.address_space_id) { + vhost_vdpa_set_address_space_id(v, v->desc_group, asid); + } + s->vhost_vdpa.address_space_id =3D asid; + } else { + s->vhost_vdpa.address_space_id =3D s0->vhost_vdpa.address_space_id; + } + return 0; } =20 @@ -603,13 +645,19 @@ static int vhost_vdpa_net_cvq_start(NetClientState *n= c) return 0; } =20 - if (!s->cvq_isolated) { + if (!s->cvq_isolated && v->desc_group < 0) { + if (s0->vhost_vdpa.shadow_vqs_enabled && + s0->vhost_vdpa.desc_group >=3D 0 && + s0->vhost_vdpa.address_space_id) { + v->shadow_vqs_enabled =3D false; + } return 0; } =20 - cvq_group =3D vhost_vdpa_get_vring_group(v->shared->device_fd, + cvq_group =3D s->cvq_isolated ? + vhost_vdpa_get_vring_group(v->shared->device_fd, v->dev->vq_index_end - 1, - &err); + &err) : v->desc_group; if (unlikely(cvq_group < 0)) { error_report_err(err); return cvq_group; @@ -1840,6 +1888,7 @@ static NetClientState *net_vhost_vdpa_init(NetClientS= tate *peer, s->always_svq =3D svq; s->migration_state.notify =3D NULL; s->vhost_vdpa.shadow_vqs_enabled =3D svq; + s->vhost_vdpa.address_space_id =3D VHOST_VDPA_GUEST_PA_ASID; if (queue_pair_index =3D=3D 0) { vhost_vdpa_net_valid_svq_features(features, &s->vhost_vdpa.migration_blocker= ); --=20 1.8.3.1 From nobody Wed Nov 27 00:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1701975421; cv=none; d=zohomail.com; s=zohoarc; b=Vo39owR6QKb13KRCGmcRim4X64KW6omTrJFh1vR6lNml7raTSCHQy4OQ/gHMDm7HWhcpTzmJjZ+Ce8lgwagnhg5RoidsHAC9S73eTqrzS33HntD8+rPJTO6SM0fxU4tIkcp16tCrp1Bp4+vt7siEW57KSyJ5VGja/5Yjkv9nT9s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701975421; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=DJSLEXjKaBkTa2xp+KB2j4QSquhLP8LlYyhXssczufQ=; b=b1eFl7RfM7mb5zWnkOQA6Txrs+fAgZfMTEX3zKbv0roT15kOyXXDX3eamku31xjyI5zpRP1L+wuOBZNrPl571x/T1Fu9LdMDVkGWfpTVDJ6msAIWUUmtavNPG/RvqKXpWnBWjukyBlolJjflG4R8IyLpI5f2sjJKjaTKmeiZdeU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1701975421027231.0793132975126; Thu, 7 Dec 2023 10:57:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBJSj-0003in-45; Thu, 07 Dec 2023 13:51:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSC-0003Xb-SR for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:32 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSB-0006rT-2t for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:32 -0500 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7FcRpD001073; Thu, 7 Dec 2023 18:50:29 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3utdda4h9a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:28 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7HTkJO039553; Thu, 7 Dec 2023 18:50:28 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3utan7vhky-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:28 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3B7Io90E008067; Thu, 7 Dec 2023 18:50:27 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3utan7vh2k-12; Thu, 07 Dec 2023 18:50:27 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=DJSLEXjKaBkTa2xp+KB2j4QSquhLP8LlYyhXssczufQ=; b=nBh1trneA2dARq5m1y4hIwdG4+6llvFmMeuomaGLMPhANxVh4XYdbUIuQtbfTzR1N4oo y+ont1wz188BUegm5JejhoUqUmIryS99bLFFoWgo3GWSlXm1ZYn+adCyu0yAc5J4aQJs 5ueltAG5P/hi6XmS49/IGCnJNe1ZQo3KYylF9NQOnQNEKgwztLvc04xP0PZBoR6iMmbH KslhFIwhsBaM2UVWrF5pwQj6I7cRV5JNh0cAmLFkUVHzYkhoh5IJo2yWBvBOFa4Btn7C S5TjdXtkYaZh/Mf0dH8qa2eMS7Zuwul/XGPVfsY2Ng/nhYLag48BdBSqNBCGwCdZY+0c Nw== From: Si-Wei Liu To: eperezma@redhat.com, jasowang@redhat.com, mst@redhat.com, dtatulea@nvidia.com, leiyang@redhat.com, yin31149@gmail.com, boris.ostrovsky@oracle.com, jonah.palmer@oracle.com Cc: qemu-devel@nongnu.org Subject: [PATCH 11/40] vdpa: factor out vhost_vdpa_last_dev Date: Thu, 7 Dec 2023 09:39:24 -0800 Message-Id: <1701970793-6865-12-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> References: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-07_15,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312070156 X-Proofpoint-GUID: shHTDgZARB2Axot1HvYYH6fkM8Nxt79n X-Proofpoint-ORIG-GUID: shHTDgZARB2Axot1HvYYH6fkM8Nxt79n Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.165.32; envelope-from=si-wei.liu@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1701975421933100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Generalize duplicated condition check for the last vq of vdpa device to a common function. Signed-off-by: Si-Wei Liu Acked-by: Jason Wang Reviewed-by: Eugenio P=C3=A9rez --- hw/virtio/vhost-vdpa.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 30dff95..2b1cc14 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -593,6 +593,11 @@ static bool vhost_vdpa_first_dev(struct vhost_dev *dev) return v->index =3D=3D 0; } =20 +static bool vhost_vdpa_last_dev(struct vhost_dev *dev) +{ + return dev->vq_index + dev->nvqs =3D=3D dev->vq_index_end; +} + static int vhost_vdpa_get_dev_features(struct vhost_dev *dev, uint64_t *features) { @@ -1432,7 +1437,7 @@ static int vhost_vdpa_dev_start(struct vhost_dev *dev= , bool started) goto out_stop; } =20 - if (dev->vq_index + dev->nvqs !=3D dev->vq_index_end) { + if (!vhost_vdpa_last_dev(dev)) { return 0; } =20 @@ -1467,7 +1472,7 @@ static void vhost_vdpa_reset_status(struct vhost_dev = *dev) { struct vhost_vdpa *v =3D dev->opaque; =20 - if (dev->vq_index + dev->nvqs !=3D dev->vq_index_end) { + if (!vhost_vdpa_last_dev(dev)) { return; } =20 --=20 1.8.3.1 From nobody Wed Nov 27 00:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1701975119; cv=none; d=zohomail.com; s=zohoarc; b=OYUp0Jt6oXzU/MmtPG3jKzMwJ0DaceNqIkiTiL8qrnw5k9UB8XSHESqpO7v3jvuQcqPKRWgAJShcesOLAqWPUi/0JHBQQmAflAB+sJDcLN/AvrEArAYOCsZBahiKaUfRLiuF2FbGT5mCJuI5g4BO1b/GybYszXEtsE8ORvIG9/g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701975119; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=zU7xzPRuUjddVE49divM8k5v/rSS/cjQ6pq2yfzWieA=; b=XRIIyd102+md/f5PzZuOK8fQFh/J5+vL7sax+Pa6uZtSEjYSGsCdB5uJ9P8uiiqRY5/mNsipcS+TE8BryF1HT4ZKb2sSsHtOf/8pxHZd1oWLdW9dO5iRpJX/RBLvXGK2bvJwJ4HlpxCkFfTLLMyTj6wc+d4Ef6LNUFM8L0cGuPA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1701975119336176.14140664493482; Thu, 7 Dec 2023 10:51:59 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBJSW-0003bv-Ip; Thu, 07 Dec 2023 13:50:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSE-0003YK-D8 for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:34 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSC-0006xo-Rb for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:34 -0500 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7FbkWE000492; Thu, 7 Dec 2023 18:50:30 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3utdda4h9b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:30 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7HRJY6039470; Thu, 7 Dec 2023 18:50:29 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3utan7vhne-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:29 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3B7Io90G008067; Thu, 7 Dec 2023 18:50:28 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3utan7vh2k-13; Thu, 07 Dec 2023 18:50:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=zU7xzPRuUjddVE49divM8k5v/rSS/cjQ6pq2yfzWieA=; b=JT56Z0gDbaOJHnEo2wmNaPZnyLGwvHG2/EbeFuucQOsdeVwyxS6qbKX8wS5n/3WG4q26 o0WhoXOpbG6cBw6Qsira1ier+47bbMJD6mniv33AbLpJCrOq6kQ4woMtAuLY5sXwoV3w GCQyv8l5vW+W3yM6fYR24jCFpr05stFJ35+mY0JbjidTH3pPd8WKb10+mJvN8UguEJDe vbCfeDdm03WCHlZcd/aJSaZCVeEbnySAWdCAfW1g+nWmFasnXPVieusgWwkVg//7dDQy cU6vUolFHDbMZ0AaFnGcMQmc7+Ucyjinz0V3kS/sr5mccmTby2vxvxaw/K6lxSwzjdly XQ== From: Si-Wei Liu To: eperezma@redhat.com, jasowang@redhat.com, mst@redhat.com, dtatulea@nvidia.com, leiyang@redhat.com, yin31149@gmail.com, boris.ostrovsky@oracle.com, jonah.palmer@oracle.com Cc: qemu-devel@nongnu.org Subject: [PATCH 12/40] vdpa: check map_thread_enabled before join maps thread Date: Thu, 7 Dec 2023 09:39:25 -0800 Message-Id: <1701970793-6865-13-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> References: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-07_15,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312070156 X-Proofpoint-GUID: aZH4UpDxnYV3N7kxIUvzU6ryQII79Ktx X-Proofpoint-ORIG-GUID: aZH4UpDxnYV3N7kxIUvzU6ryQII79Ktx Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.165.32; envelope-from=si-wei.liu@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1701975121222100003 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The next patches will also register memory listener on demand, hence the need to differentiate the map_thread case from the rest. Signed-off-by: Si-Wei Liu --- hw/virtio/vhost-vdpa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 2b1cc14..4f026db 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -1450,7 +1450,7 @@ static int vhost_vdpa_dev_start(struct vhost_dev *dev= , bool started) if (!v->shared->listener_registered) { memory_listener_register(&v->shared->listener, dev->vdev->dma_= as); v->shared->listener_registered =3D true; - } else { + } else if (v->shared->map_thread_enabled) { ok =3D vhost_vdpa_join_maps_thread(v->shared); if (unlikely(!ok)) { goto out_stop; --=20 1.8.3.1 From nobody Wed Nov 27 00:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1701975235; cv=none; d=zohomail.com; s=zohoarc; b=EstsvjPyAy80wc5n5cAwQMz+Eesx2TJyT3EYlEIR0AUezSo0+8P/hGHKKYTmDAWjUypJz7hLXDdhHkLRSmR8cM1SvuHJsM0zdVL8r+2PVfzX8bdEYsSLdbjD8vUORqZtt/3HdXQxmlcPXBx0Fou/A4wOTbusY5ztpRMFiB5hlmI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701975235; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BfrNOM61HQk1Refk9aUivCtpc5yjhyjOFXJvrx8vuEY=; b=ZGTWJPPR2dDhp9L4n2hTUuLTNavHKM0LubbvvDgbYaQPC1+DSnkTC/gXuIah5o4jixZpPgRMUhemg/BIZpsKmujB0AvjcU8Fs+xbMvY/KJ+leMiUq1jWAOok4xcMGRVmUc84Qd4q5nTlFbnLF9ACzSqlDe9KrnZ2pJPEja/CgVs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1701975235583423.4505471410797; Thu, 7 Dec 2023 10:53:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBJSL-0003bB-VY; Thu, 07 Dec 2023 13:50:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSF-0003YZ-1k for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:36 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSD-0006xy-7M for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:34 -0500 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7IXRY1021815; Thu, 7 Dec 2023 18:50:32 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3utdmbmnsn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:31 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7HNN8s039498; Thu, 7 Dec 2023 18:50:30 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3utan7vhpj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:30 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3B7Io90I008067; Thu, 7 Dec 2023 18:50:30 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3utan7vh2k-14; Thu, 07 Dec 2023 18:50:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=BfrNOM61HQk1Refk9aUivCtpc5yjhyjOFXJvrx8vuEY=; b=dmY5cGU+ZGNtQ2mD9MOouxy7sZjUV+YMUCwfcUER27O3jIeX9I4K/UWP2CGW4G+CBEwk QTbpxzXGueAQ05hzZZJDklcl4bmlOEHaV/dIXNWALpW7Nv9jp2upHC/uLj/mSQQX9obw 9PzRcJSX34TQFgwPoBz9Y2rFw+humF0hItCYeBWJYoPhQprIK9lvQIDlOW8RTN86QVyJ q0VEGMGxRjVLTvL4pxB9Mz0M9ok80g1jxp3oZ3t/tD6fBFUG/5J75IdZt/jdVr07ppQ9 XVQdVrqRQUepOT2hoM1zU15/xF28WAMaXnVjBw9YkguxPiQSt3tleNnNSownG6LXEFdv ZQ== From: Si-Wei Liu To: eperezma@redhat.com, jasowang@redhat.com, mst@redhat.com, dtatulea@nvidia.com, leiyang@redhat.com, yin31149@gmail.com, boris.ostrovsky@oracle.com, jonah.palmer@oracle.com Cc: qemu-devel@nongnu.org Subject: [PATCH 13/40] vdpa: ref counting VhostVDPAShared Date: Thu, 7 Dec 2023 09:39:26 -0800 Message-Id: <1701970793-6865-14-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> References: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-07_15,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312070156 X-Proofpoint-ORIG-GUID: pAv6TUJR0jCfrTDP25p5yCJ6gVZ-M29W X-Proofpoint-GUID: pAv6TUJR0jCfrTDP25p5yCJ6gVZ-M29W Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.177.32; envelope-from=si-wei.liu@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1701975237621100003 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Subsequent patches attempt to release VhostVDPAShared resources, for example iova tree to free and memory listener to unregister, in vdpa_dev_cleanup(). Instead of checking against the vq index, which is not always available in all of the callers, counting the usage by reference. Then it'll be easy to free resource upon the last deref. Signed-off-by: Si-Wei Liu --- include/hw/virtio/vhost-vdpa.h | 2 ++ net/vhost-vdpa.c | 14 ++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h index 63493ff..7b8d3bf 100644 --- a/include/hw/virtio/vhost-vdpa.h +++ b/include/hw/virtio/vhost-vdpa.h @@ -70,6 +70,8 @@ typedef struct vhost_vdpa_shared { =20 /* Vdpa must send shadow addresses as IOTLB key for data queues, not G= PA */ bool shadow_data; + + unsigned refcnt; } VhostVDPAShared; =20 typedef struct vhost_vdpa { diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index aebaa53..a126e5c 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -236,11 +236,11 @@ static void vhost_vdpa_cleanup(NetClientState *nc) g_free(s->vhost_net); s->vhost_net =3D NULL; } - if (s->vhost_vdpa.index !=3D 0) { - return; + if (--s->vhost_vdpa.shared->refcnt =3D=3D 0) { + qemu_close(s->vhost_vdpa.shared->device_fd); + g_free(s->vhost_vdpa.shared); } - qemu_close(s->vhost_vdpa.shared->device_fd); - g_free(s->vhost_vdpa.shared); + s->vhost_vdpa.shared =3D NULL; } =20 /** Dummy SetSteeringEBPF to support RSS for vhost-vdpa backend */ @@ -1896,6 +1896,7 @@ static NetClientState *net_vhost_vdpa_init(NetClientS= tate *peer, s->vhost_vdpa.shared->device_fd =3D vdpa_device_fd; s->vhost_vdpa.shared->iova_range =3D iova_range; s->vhost_vdpa.shared->shadow_data =3D svq; + s->vhost_vdpa.shared->refcnt++; } else if (!is_datapath) { s->cvq_cmd_out_buffer =3D mmap(NULL, vhost_vdpa_net_cvq_cmd_page_l= en(), PROT_READ | PROT_WRITE, @@ -1910,6 +1911,7 @@ static NetClientState *net_vhost_vdpa_init(NetClientS= tate *peer, } if (queue_pair_index !=3D 0) { s->vhost_vdpa.shared =3D shared; + s->vhost_vdpa.shared->refcnt++; } =20 ret =3D vhost_vdpa_add(nc, (void *)&s->vhost_vdpa, queue_pair_index, n= vqs); @@ -1928,6 +1930,10 @@ static NetClientState *net_vhost_vdpa_init(NetClient= State *peer, return nc; =20 err: + if (--s->vhost_vdpa.shared->refcnt =3D=3D 0) { + g_free(s->vhost_vdpa.shared); + } + s->vhost_vdpa.shared =3D NULL; qemu_del_net_client(nc); return NULL; } --=20 1.8.3.1 From nobody Wed Nov 27 00:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1701975414; cv=none; d=zohomail.com; s=zohoarc; b=nipLY90oJY8pEnOreJBMxlSvE673LBUnscE/Ky6LUXgG0Bjm5UzqT876gbAjIy2s7RKhLwUnp6KOlK1CsnshWaJH4YAB7fuc7kQhIrSo86JNA3uIDI7qWAvd+xL6puDvMueWXfHwQYq8NT3O1mSB4wodMeyjEvGuGBxtiCYXsJc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701975414; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=e0mpqwBWjWSiuQVcV0ZNzMbrYl/rSZxxr7/pXeGCxhg=; b=FQpo8KgOidpiKGfe2YP/l1D2T+hU00QkV/vQOaimlz2Kb9A0hCvbPuypVW0ZGGioYgpkDKF1EoTpteO6v9Y+1xU8nmfhRtM2DBKbA8FHOa4nVEWKy5NeVylLp6sNSZaKVUQMK/LzwUaGpoSzQh5eKoT+KD+ChJ/LfyIn0SSC4Mc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17019754140281008.0763194176817; Thu, 7 Dec 2023 10:56:54 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBJSc-0003cs-K5; Thu, 07 Dec 2023 13:50:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSG-0003Ym-QQ for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:37 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSE-00074A-Mv for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:36 -0500 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7GDP6M031570; Thu, 7 Dec 2023 18:50:33 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3utdrvmpf8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:33 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7HW79B039466; Thu, 7 Dec 2023 18:50:32 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3utan7vhqp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:32 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3B7Io90K008067; Thu, 7 Dec 2023 18:50:31 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3utan7vh2k-15; Thu, 07 Dec 2023 18:50:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=e0mpqwBWjWSiuQVcV0ZNzMbrYl/rSZxxr7/pXeGCxhg=; b=WKTjdpyJb9DfeGSt3HQz3MFCe+mTiE3INyI3GLxJQIor33DtlGu+KNPeL11m0JYeRKD7 wbhJ3P5qa+mFXByWHUNj1+ps5D4YNbtH6ZhxUnBKxaLk6rV72LJ3KUm0EdWSaOe32rFq MfVvzbUezhxzyQ9IH/Mg5q22FxG2G7ZOxYZNL1jeYRQhXD77aDaWy9TgTGrMXoG4Q/YA 90aJyDncdmWLGgA706U/MqG6caIaBny0Rdhly9M+OOobNUsTzTKnhJsf2W3FUMD0ykZU j8qvWLv+10p3FivS2dgu9uZ7LcOzoyFVYjAtobveClXgFBxjUsS6xTHkbEW/AjGmgB6X bA== From: Si-Wei Liu To: eperezma@redhat.com, jasowang@redhat.com, mst@redhat.com, dtatulea@nvidia.com, leiyang@redhat.com, yin31149@gmail.com, boris.ostrovsky@oracle.com, jonah.palmer@oracle.com Cc: qemu-devel@nongnu.org Subject: [PATCH 14/40] vdpa: convert iova_tree to ref count based Date: Thu, 7 Dec 2023 09:39:27 -0800 Message-Id: <1701970793-6865-15-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> References: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-07_15,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312070156 X-Proofpoint-GUID: G7S8G0A10AUV155r3ZU6Dkd7LnaxHw3A X-Proofpoint-ORIG-GUID: G7S8G0A10AUV155r3ZU6Dkd7LnaxHw3A Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.177.32; envelope-from=si-wei.liu@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1701975415804100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" So that it can be freed from vhost_vdpa_cleanup on the last deref. The next few patches will try to make iova tree life cycle not depend on memory listener, and there's possiblity to keep iova tree around when memory mapping is not changed across device reset. Signed-off-by: Si-Wei Liu --- net/vhost-vdpa.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index a126e5c..7b8f047 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -238,6 +238,8 @@ static void vhost_vdpa_cleanup(NetClientState *nc) } if (--s->vhost_vdpa.shared->refcnt =3D=3D 0) { qemu_close(s->vhost_vdpa.shared->device_fd); + g_clear_pointer(&s->vhost_vdpa.shared->iova_tree, + vhost_iova_tree_delete); g_free(s->vhost_vdpa.shared); } s->vhost_vdpa.shared =3D NULL; @@ -461,19 +463,12 @@ static int vhost_vdpa_net_data_load(NetClientState *n= c) static void vhost_vdpa_net_client_stop(NetClientState *nc) { VhostVDPAState *s =3D DO_UPCAST(VhostVDPAState, nc, nc); - struct vhost_dev *dev; =20 assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA); =20 if (s->vhost_vdpa.index =3D=3D 0) { migration_remove_notifier(&s->migration_state); } - - dev =3D s->vhost_vdpa.dev; - if (dev->vq_index + dev->nvqs =3D=3D dev->vq_index_end) { - g_clear_pointer(&s->vhost_vdpa.shared->iova_tree, - vhost_iova_tree_delete); - } } =20 static int vhost_vdpa_net_load_setup(NetClientState *nc, NICState *nic) --=20 1.8.3.1 From nobody Wed Nov 27 00:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1701975401; cv=none; d=zohomail.com; s=zohoarc; b=NspD6fiY8uJl3X8bq1D5eoudFHbpoctDAoyYxIcn2Uy6BcKJE4QLVuElDejDLG3MnPYzb9sUdaZ0t1hVbPwgAdzx0sIJaLukEhoM9lWGrVjPjer8r5vmX3zvDlyj7v4/EDRYrittUO7QWReOnXu+ySsMGcf/bx1jUXoWDmCD+1k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701975401; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=xDxSIA4rvNU4sQYtYIHv8uaWbJt9DwDRsPu40Jb1QUI=; b=R6eL6e3N7O3iysc1hvRFK/YPdyRzD6wHdU3M8HrNS9G8veO0c/A4xzYEFZfa9V5Dvh/a07BDaisw9cg2DynCXVqPmwj0QSfJuMOp1QS+c8j7Qf/T3QUfcHExnZ6Ke4yJF57kyUjfmItZpD4xWr9RIhcp6ZJUbFuqm1dHhfr2dHE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1701975401509277.2336910787734; Thu, 7 Dec 2023 10:56:41 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBJSc-0003ct-JA; Thu, 07 Dec 2023 13:50:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSJ-0003Zn-BU for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:39 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSG-00074X-Hl for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:38 -0500 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7IXRY3021815; Thu, 7 Dec 2023 18:50:35 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3utdmbmnst-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:34 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7Hb9fu039324; Thu, 7 Dec 2023 18:50:33 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3utan7vhrs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:33 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3B7Io90M008067; Thu, 7 Dec 2023 18:50:33 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3utan7vh2k-16; Thu, 07 Dec 2023 18:50:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=xDxSIA4rvNU4sQYtYIHv8uaWbJt9DwDRsPu40Jb1QUI=; b=aX/2yZCAjmgE3OKkgp4Quteporg5ySBoF79SJleuUtReVD60iY22agclRRyjVJL/oIGM lEwExZxJSFbgiHVUm7sIyj7qSb00qr/MZps89in8FuHdIfa1tzYK2ZgpPmb0c34YV7Q8 47jP0ne2dlg+/fh/4QVouGfaP7RoO+6ZDZ2mltRLmWnT2CnvWstVMt3zcprf99ry5uh/ oRvbhRgBT5jBkrlOJ9Gx2xIWNBAbs5ATJAn2JShPYzr5rnYIam4rY61oItL/XevQ2R5j pOfJBtLTix9AlvIK6KPSeffWarcYme7BpLOArPELsvvzDyNOmgu4gT9+QkNaWxgXhedv BQ== From: Si-Wei Liu To: eperezma@redhat.com, jasowang@redhat.com, mst@redhat.com, dtatulea@nvidia.com, leiyang@redhat.com, yin31149@gmail.com, boris.ostrovsky@oracle.com, jonah.palmer@oracle.com Cc: qemu-devel@nongnu.org Subject: [PATCH 15/40] vdpa: add svq_switching and flush_map to header Date: Thu, 7 Dec 2023 09:39:28 -0800 Message-Id: <1701970793-6865-16-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> References: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-07_15,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312070156 X-Proofpoint-ORIG-GUID: egULmAtzU0HAE4lm2Z15uVhpElIubHmc X-Proofpoint-GUID: egULmAtzU0HAE4lm2Z15uVhpElIubHmc Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.177.32; envelope-from=si-wei.liu@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1701975403527100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Will be used in next patches. Signed-off-by: Si-Wei Liu --- include/hw/virtio/vhost-vdpa.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h index 7b8d3bf..0fe0f60 100644 --- a/include/hw/virtio/vhost-vdpa.h +++ b/include/hw/virtio/vhost-vdpa.h @@ -72,6 +72,12 @@ typedef struct vhost_vdpa_shared { bool shadow_data; =20 unsigned refcnt; + + /* SVQ switching is in progress? 1: turn on SVQ, -1: turn off SVQ */ + int svq_switching; + + /* Flush mappings on reset due to shared address space */ + bool flush_map; } VhostVDPAShared; =20 typedef struct vhost_vdpa { --=20 1.8.3.1 From nobody Wed Nov 27 00:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1701975433; cv=none; d=zohomail.com; s=zohoarc; b=nhD/Afxg+eRMrFy5bOb0ZfbqTCHbR4C+atZ3ZB8ntVNH97kFg9FnDQA82pMNvrF/L4psnqJ3bhE6pKSOarkHrIpD+m52NW4l6BL/zvAy/qFIR6M1B+6kcw69O2V6Sl4wICln21LYfryYPkIB3kOMv8NZYD1usXgFxQeFT9KZ8Ac= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701975433; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=q/OD/SQMRrvfSZtobhfq0UPv1L+/kMxXzcbtd0Vkdy8=; b=Qrq9aDVzjG93m2tn6SPI9MaH+f5eq3fkEi8rAF9FG+LB1QrvMz62kqkISPBikJP1HE3HUCsu5zbRUQwU0FN6mv4rA/v8vu2MZWrWMrkqw6+VyMBj1AahJSNQK2zXZqQ675KQUDmxsJcv27IeYTWw+naLCj6jVM1E9kq0DSp9hLM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1701975433408462.65448678954556; Thu, 7 Dec 2023 10:57:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBJSj-0003mf-QY; Thu, 07 Dec 2023 13:51:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSM-0003bD-25 for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:42 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSJ-00074q-3K for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:40 -0500 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 3B7HFTxP007979; Thu, 7 Dec 2023 18:50:36 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3utd0hmjtj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:36 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7HW79E039466; Thu, 7 Dec 2023 18:50:35 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3utan7vhtc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:35 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3B7Io90O008067; Thu, 7 Dec 2023 18:50:34 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3utan7vh2k-17; Thu, 07 Dec 2023 18:50:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=q/OD/SQMRrvfSZtobhfq0UPv1L+/kMxXzcbtd0Vkdy8=; b=g52EoJ5jXOZ34zk1SZVNWxuGqQrD2O1C0iQkwXINSzKibrZbw9dd804gBoi52VSG1tCO tBrDcsKB0FuZGPC9WSrX6l33SzBlhTSMfoap+9CO5e0gdyMMGQnonN2r+rnWS5imA1SZ xpfnmp68OPvQH5Mge1UVb1lejBg6bzX2QzjnL2EUybxJWQEXIGNTjBmuXcHkrjZD3MJw 7FR3Nv2MlLNthqMr7ZtXkjHlAA//i/CplTj4oJ0CG78KTH2t4bc+/5itGwMJHxbKKuEF v05A2uc8LiqRMrvZYc6agSDPebUYvzqDbHpagMhXq3QZaA3Xy0Bw12Ddf4yKR1DKuooy OA== From: Si-Wei Liu To: eperezma@redhat.com, jasowang@redhat.com, mst@redhat.com, dtatulea@nvidia.com, leiyang@redhat.com, yin31149@gmail.com, boris.ostrovsky@oracle.com, jonah.palmer@oracle.com Cc: qemu-devel@nongnu.org Subject: [PATCH 16/40] vdpa: indicate SVQ switching via flag Date: Thu, 7 Dec 2023 09:39:29 -0800 Message-Id: <1701970793-6865-17-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> References: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-07_15,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=959 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312070156 X-Proofpoint-GUID: T7qjZS8JQ86YnXnSajyUbZQKDxKYOjEt X-Proofpoint-ORIG-GUID: T7qjZS8JQ86YnXnSajyUbZQKDxKYOjEt Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.165.32; envelope-from=si-wei.liu@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1701975434116100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" svq_switching indicates the case where SVQ mode change is on going. Positive (1) means switching from the normal passthrough mode to SVQ mode, and negative (-1) meaning switch SVQ back to the passthrough; zero (0) indicates that there's no SVQ mode switch taking place. Signed-off-by: Si-Wei Liu --- net/vhost-vdpa.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 7b8f047..04718b2 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -320,6 +320,7 @@ static void vhost_vdpa_net_log_global_enable(VhostVDPAS= tate *s, bool enable) data_queue_pairs =3D n->multiqueue ? n->max_queue_pairs : 1; cvq =3D virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ) ? n->max_ncs - n->max_queue_pairs : 0; + v->shared->svq_switching =3D enable ? 1 : -1; /* * TODO: vhost_net_stop does suspend, get_base and reset. We can be sm= arter * in the future and resume the device if read-only operations between @@ -332,6 +333,7 @@ static void vhost_vdpa_net_log_global_enable(VhostVDPAS= tate *s, bool enable) if (unlikely(r < 0)) { error_report("unable to start vhost net: %s(%d)", g_strerror(-r), = -r); } + v->shared->svq_switching =3D 0; } =20 static void vdpa_net_migration_state_notifier(Notifier *notifier, void *da= ta) --=20 1.8.3.1 From nobody Wed Nov 27 00:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1701975342; cv=none; d=zohomail.com; s=zohoarc; b=EcZFq7dBOSYZHuAYoRRNlkOB6icOHY9Xook9YTRhja5lzj96DIS6qL1Avugla0uHhB82i9DXVEwwMC0BWU3CBBZztyb2Hxovb3MjrQ+2MQVceFxOUyr9QAVHU2AtDE28lZG9TnOta2Fk+fhAhesJSrIjpf1vzokf4tmCJz7K1oY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701975342; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=DAJgRMVF30Cp8qjJnARfP/QyVuDoThEW/b3dYAUZDFA=; b=BPbB/Lx9vnznv9tM9GCecpTSPogCTYlBNrzCrii9mdjIS95hELZpAPNpVvrkKnLBxcv44DLTKTChWOWkz1gepwgK4rGTBqpm1HnG+MwIblEVMRzPR7XWSmv1hGaTGo4eYqwSlU42r9zCMge1qUhLKhqszjSjeZLss0EU6TOfoLA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 170197534226221.978887980162085; Thu, 7 Dec 2023 10:55:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBJSg-0003eX-KG; Thu, 07 Dec 2023 13:51:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSL-0003bC-VD for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:42 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSJ-000750-4N for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:40 -0500 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7IJEpq006221; Thu, 7 Dec 2023 18:50:38 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3utdabvgds-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:37 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7IltL1039527; Thu, 7 Dec 2023 18:50:36 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3utan7vhup-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:36 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3B7Io90Q008067; Thu, 7 Dec 2023 18:50:36 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3utan7vh2k-18; Thu, 07 Dec 2023 18:50:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=DAJgRMVF30Cp8qjJnARfP/QyVuDoThEW/b3dYAUZDFA=; b=SsiFgE/It4NP+DNrlL/5otSYr8bt53TZF8qVdpClG0OML2pAAvwGeKN+vikiaBr02Hq1 PqZ1qTSob7MzAxguAcEkxhBvEkFGv7VuCkxciiY6vXHZJgRb04Hh3yNr53AG3rHQroa8 GsWUOCOEDRaXvf33o/LnJNZ5KCe0ZDSKkIboNtNqk7aJLxyR+sRa7hYX3o3fV3XSz/ZS wLtINid2rix7QuWAD6tvV4wXhtPc74yvc0xknhz7x0Qz8VrHNac73YVLurxPYYWY63pa e844cyzLjpvGhwh9VMXXUTxy18iDl+LDNREdLqsFv7CRsICQgaeLKkeHQlcZ/mKCwTkB Dg== From: Si-Wei Liu To: eperezma@redhat.com, jasowang@redhat.com, mst@redhat.com, dtatulea@nvidia.com, leiyang@redhat.com, yin31149@gmail.com, boris.ostrovsky@oracle.com, jonah.palmer@oracle.com Cc: qemu-devel@nongnu.org Subject: [PATCH 17/40] vdpa: judge if map can be kept across reset Date: Thu, 7 Dec 2023 09:39:30 -0800 Message-Id: <1701970793-6865-18-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> References: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-07_15,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312070156 X-Proofpoint-ORIG-GUID: flPk4cZaL6HQcNu2WbdikwEePuRy0azc X-Proofpoint-GUID: flPk4cZaL6HQcNu2WbdikwEePuRy0azc Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.177.32; envelope-from=si-wei.liu@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1701975344073100008 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The descriptor group for SVQ ASID allows the guest memory mapping to retain across SVQ switching, same as how isolated CVQ can do with a different ASID than the guest GPA space. Introduce an evaluation function to judge whether to flush or keep iotlb maps based on virtqueue's descriptor group and cvq isolation capability. Have to hook the evaluation function to NetClient's .poll op as .vhost_reset_status runs ahead of .stop, and .vhost_dev_start don't have access to the vhost-vdpa net's information. Signed-off-by: Si-Wei Liu --- net/vhost-vdpa.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 04718b2..e9b96ed 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -504,12 +504,36 @@ static int vhost_vdpa_net_load_cleanup(NetClientState= *nc, NICState *nic) n->parent_obj.status & VIRTIO_CONFIG_S_DRIVER= _OK); } =20 +static void vhost_vdpa_net_data_eval_flush(NetClientState *nc, bool stop) +{ + VhostVDPAState *s =3D DO_UPCAST(VhostVDPAState, nc, nc); + struct vhost_vdpa *v =3D &s->vhost_vdpa; + + if (!stop) { + return; + } + + if (s->vhost_vdpa.index =3D=3D 0) { + if (s->always_svq) { + v->shared->flush_map =3D true; + } else if (!v->shared->svq_switching || v->desc_group >=3D 0) { + v->shared->flush_map =3D false; + } else { + v->shared->flush_map =3D true; + } + } else if (!s->always_svq && v->shared->svq_switching && + v->desc_group < 0) { + v->shared->flush_map =3D true; + } +} + static NetClientInfo net_vhost_vdpa_info =3D { .type =3D NET_CLIENT_DRIVER_VHOST_VDPA, .size =3D sizeof(VhostVDPAState), .receive =3D vhost_vdpa_receive, .start =3D vhost_vdpa_net_data_start, .load =3D vhost_vdpa_net_data_load, + .poll =3D vhost_vdpa_net_data_eval_flush, .stop =3D vhost_vdpa_net_client_stop, .cleanup =3D vhost_vdpa_cleanup, .has_vnet_hdr =3D vhost_vdpa_has_vnet_hdr, @@ -1368,12 +1392,28 @@ static int vhost_vdpa_net_cvq_load(NetClientState *= nc) return 0; } =20 +static void vhost_vdpa_net_cvq_eval_flush(NetClientState *nc, bool stop) +{ + VhostVDPAState *s =3D DO_UPCAST(VhostVDPAState, nc, nc); + struct vhost_vdpa *v =3D &s->vhost_vdpa; + + if (!stop) { + return; + } + + if (!v->shared->flush_map && !v->shared->svq_switching && + !s->cvq_isolated && v->desc_group < 0) { + v->shared->flush_map =3D true; + } +} + static NetClientInfo net_vhost_vdpa_cvq_info =3D { .type =3D NET_CLIENT_DRIVER_VHOST_VDPA, .size =3D sizeof(VhostVDPAState), .receive =3D vhost_vdpa_receive, .start =3D vhost_vdpa_net_cvq_start, .load =3D vhost_vdpa_net_cvq_load, + .poll =3D vhost_vdpa_net_cvq_eval_flush, .stop =3D vhost_vdpa_net_cvq_stop, .cleanup =3D vhost_vdpa_cleanup, .has_vnet_hdr =3D vhost_vdpa_has_vnet_hdr, --=20 1.8.3.1 From nobody Wed Nov 27 00:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1701975367; cv=none; d=zohomail.com; s=zohoarc; b=mTieJYOdKAPyLC7bPWx4T2wNwqTBfYzTuybcdUwHTyNLoeFWkV3UIyWXSiaQjTBmPAgHSc2ofPWNwIIx5WZ1cSznhQ6Eh5+ii7anaRXklUo6+DHaUSqTetYNnxGXgcA15VD/pBZ14A3620Ey1g7pfVsJrL1H4Hgy+pXaeHQUvPM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701975367; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=GzAQNxB1Ds4Wl3bN9BqEVFr1k5fVdLUM7iPUgjnRZus=; b=T1I/pI14fLw6/svOeM3GdgzlVnSqWSAo/NRkzGvzzbAuRngSLcHTS96mrPffuNQ+qKv8Zbf0oI4g+5rB22yxZkMdsiVXCH4lMeoVSLdKaaWtUkIV6MvKva73+//IURt9Clb7SAfeJyGXG9AeWGuCE1UAjm9ltfpjCchbkHozUYg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1701975367794825.841135852658; Thu, 7 Dec 2023 10:56:07 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBJSe-0003eW-L9; Thu, 07 Dec 2023 13:51:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSN-0003bk-S5 for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:44 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSM-00075C-6F for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:43 -0500 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7ISPbf031783; Thu, 7 Dec 2023 18:50:39 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3utdda4h9q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:38 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7I27i7039472; Thu, 7 Dec 2023 18:50:38 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3utan7vhvw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:38 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3B7Io90S008067; Thu, 7 Dec 2023 18:50:37 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3utan7vh2k-19; Thu, 07 Dec 2023 18:50:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=GzAQNxB1Ds4Wl3bN9BqEVFr1k5fVdLUM7iPUgjnRZus=; b=SMxSJt91aeBW8blW22QdImDgwZ6oW5kCW1f6ZHdpVqCKYYje2Zbgj3R2PcA1MsNuDQqd omg45NmdnMqxXdNXRwJ+9s1cswgrcqvAyUUnVF10IBpcUmnm+luxvpjILzQ6/h25l2+1 ePBvgOQ4Z5YHDCGOcYmEhhw763XikOF1ViBDYmnX5ptAWJj4pSjqDeSMawLfBGENXhNN fprMgy7dmBZgsBxlG/FouxVC/cp2VBHlTQvZbcvVOuy7BUKnNgkcwyt3GYN8SSHNiPyX +jEtnO9DTh4YKykapZeM/R3P5admIUZXK++Ljcb7LFpaMGFIdE8f70Oq4cIWsKa09ao6 WA== From: Si-Wei Liu To: eperezma@redhat.com, jasowang@redhat.com, mst@redhat.com, dtatulea@nvidia.com, leiyang@redhat.com, yin31149@gmail.com, boris.ostrovsky@oracle.com, jonah.palmer@oracle.com Cc: qemu-devel@nongnu.org Subject: [PATCH 18/40] vdpa: unregister listener on last dev cleanup Date: Thu, 7 Dec 2023 09:39:31 -0800 Message-Id: <1701970793-6865-19-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> References: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-07_15,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312070156 X-Proofpoint-GUID: PVINAj-GTltoU4gOBZQ4FLMTMhfygUVu X-Proofpoint-ORIG-GUID: PVINAj-GTltoU4gOBZQ4FLMTMhfygUVu Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.165.32; envelope-from=si-wei.liu@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1701975368578100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" So that the free of iova tree struct can be safely deferred to until the last vq referencing it goes away. Signed-off-by: Si-Wei Liu --- hw/virtio/vhost-vdpa.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 4f026db..ea2dfc8 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -815,7 +815,10 @@ static int vhost_vdpa_cleanup(struct vhost_dev *dev) } =20 vhost_vdpa_host_notifiers_uninit(dev, dev->nvqs); - memory_listener_unregister(&v->shared->listener); + if (vhost_vdpa_last_dev(dev) && v->shared->listener_registered) { + memory_listener_unregister(&v->shared->listener); + v->shared->listener_registered =3D false; + } vhost_vdpa_svq_cleanup(dev); =20 dev->opaque =3D NULL; --=20 1.8.3.1 From nobody Wed Nov 27 00:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1701975278; cv=none; d=zohomail.com; s=zohoarc; b=BRi8+3rNT6LqhqBxL/aiMUGgH4hmINxX7FoAdSuYILHyaq1cccMfSitOrSc/ktcQai6/wtfI6sSKd1NMFYI0Yr5VdDSd5hp/K1HlqFM6kQzTVAJ3Ub1YzI9aamkn8RT4MkBOrEz5Uxj/ygYSK1hyPpVr3IEslsvBSaGb/2iQkWU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701975278; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Ts4cQAvsSa+oeK7OSgvPKqhJMDfUGW7pypfVyDb3Mq8=; b=lgxQxpmPpY8+YfXI1tpSFvXNbNgbcq2ZgyzgCFHQVg6dhiwV23EzMSHo+JChbFEAII/COgtPE0GtooYhFRXnlJ73/IU6EQSl8OUEUcXddZbsuBkH8nNdrHbAsjN487dAPvKWTUebzAqKsYXt5iLTN3O1PFb14CT18eMWEG4IeeY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1701975278909101.79355431024067; Thu, 7 Dec 2023 10:54:38 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBJSe-0003eT-Fi; Thu, 07 Dec 2023 13:51:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSS-0003cC-9P for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:51 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSM-00075M-Q1 for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:44 -0500 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7FbkWF000492; Thu, 7 Dec 2023 18:50:40 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3utdda4h9t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:40 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7Hb9g1039324; Thu, 7 Dec 2023 18:50:39 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3utan7vhxf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:39 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3B7Io90U008067; Thu, 7 Dec 2023 18:50:39 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3utan7vh2k-20; Thu, 07 Dec 2023 18:50:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=Ts4cQAvsSa+oeK7OSgvPKqhJMDfUGW7pypfVyDb3Mq8=; b=jSJQkpOwMOL28/CRMeHbfORlgHg9RV2YoM1Ep/lUs+U7KVeP1TMl4UZ7a0PrUSd8QyxA cVJ6OEnA0cuRuML5HtE4278ZM9GuORd9y+TE+AMSuPijwlsBhNTxoatqInydwykNuAkI wYIybStxMCNdkGwUb8fUc1Id9te3Cgp7553R80B3g/IjqY8hfGrJKr2WW2mBJHpgePkc zZLKXbU2G3+dZUVd69kKRnP8QcgnsPJAI+H5BWB6tKGNp15sP+FuChf5L11SnL/IS010 Sii7NFCuOjVnXjPmjLV15MsfTnBXc8staCFKL0+tBjns65OoaX0oOlx5LyiBGoLJaG82 yA== From: Si-Wei Liu To: eperezma@redhat.com, jasowang@redhat.com, mst@redhat.com, dtatulea@nvidia.com, leiyang@redhat.com, yin31149@gmail.com, boris.ostrovsky@oracle.com, jonah.palmer@oracle.com Cc: qemu-devel@nongnu.org Subject: [PATCH 19/40] vdpa: should avoid map flushing with persistent iotlb Date: Thu, 7 Dec 2023 09:39:32 -0800 Message-Id: <1701970793-6865-20-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> References: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-07_15,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312070156 X-Proofpoint-GUID: VmsbE7U-VPFNiBIeLW82-JtATxW-ibte X-Proofpoint-ORIG-GUID: VmsbE7U-VPFNiBIeLW82-JtATxW-ibte Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.165.32; envelope-from=si-wei.liu@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1701975280789100003 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Today memory listener is unregistered in vhost_vdpa_reset_status unconditionally, due to which all the maps will be flushed away from the iotlb. However, map flush is not always needed, and doing it from performance hot path may have innegligible latency impact that affects VM reboot time or brown out period during live migration. Leverage the IOTLB_PERSIST backend featuae, which ensures durable iotlb maps and not disappearing even across reset. When it is supported, we may conditionally keep the maps for cases where the guest memory mapping doesn't change. Prepare a function so that the next patch will be able to use it to keep the maps. Signed-off-by: Si-Wei Liu --- hw/virtio/trace-events | 1 + hw/virtio/vhost-vdpa.c | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index 77905d1..9725d44 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -66,6 +66,7 @@ vhost_vdpa_set_owner(void *dev) "dev: %p" vhost_vdpa_vq_get_addr(void *dev, void *vq, uint64_t desc_user_addr, uint6= 4_t avail_user_addr, uint64_t used_user_addr) "dev: %p vq: %p desc_user_add= r: 0x%"PRIx64" avail_user_addr: 0x%"PRIx64" used_user_addr: 0x%"PRIx64 vhost_vdpa_get_iova_range(void *dev, uint64_t first, uint64_t last) "dev: = %p first: 0x%"PRIx64" last: 0x%"PRIx64 vhost_vdpa_set_config_call(void *dev, int fd)"dev: %p fd: %d" +vhost_vdpa_maybe_flush_map(void *dev, bool reg, bool flush, bool persist) = "dev: %p registered: %d flush_map: %d iotlb_persistent: %d" =20 # virtio.c virtqueue_alloc_element(void *elem, size_t sz, unsigned in_num, unsigned o= ut_num) "elem %p size %zd in_num %u out_num %u" diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index ea2dfc8..31e0a55 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -1471,6 +1471,26 @@ out_stop: return ok ? 0 : -1; } =20 +static void vhost_vdpa_maybe_flush_map(struct vhost_dev *dev) +{ + struct vhost_vdpa *v =3D dev->opaque; + + trace_vhost_vdpa_maybe_flush_map(dev, v->shared->listener_registered, + v->shared->flush_map, + !!(dev->backend_cap & + BIT_ULL(VHOST_BACKEND_F_IOTLB_PERSIST= ))); + + if (!v->shared->listener_registered) { + return; + } + + if (!(dev->backend_cap & BIT_ULL(VHOST_BACKEND_F_IOTLB_PERSIST)) || + v->shared->flush_map) { + memory_listener_unregister(&v->shared->listener); + v->shared->listener_registered =3D false; + } +} + static void vhost_vdpa_reset_status(struct vhost_dev *dev) { struct vhost_vdpa *v =3D dev->opaque; --=20 1.8.3.1 From nobody Wed Nov 27 00:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1701975216; cv=none; d=zohomail.com; s=zohoarc; b=lf1vrNoyiPHbUMyUkvENAt/W6s0s/9lhkmgIXwRruIMebXhaQ8vpeQQCP5HZQY/GE73o82KgF4oMWrZN2nVwhsgyCXVfyNk94ljtGduhFHCCgUFuRPxieAcDE9aRpUT3VFc/+mcEZoTeNXXnkGAuIDSs/NYzBshPNGxeSsctgbM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701975216; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=EthSTSZAGUdFGpGUUgIS40/qu5PWf2EuzefpgEB0S8Y=; b=D/NXyKKAzghxdfVetllnLSqALHsxA6+1rbo77nX+fxTUhoB19mrrMxEkB/thelHQO2HDKdzQcIk1T5HaDLR0BINuHTcy+xptIKARH2b+/1MTatxdnTmqMbm1lpFZ1cWclVGtJdgeXIBdbzAKQVjZ3kVRNKMI0ZQtp4S2y3N2auE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1701975216104515.0699353914117; Thu, 7 Dec 2023 10:53:36 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBJSt-0003xI-4b; Thu, 07 Dec 2023 13:51:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSW-0003cS-3y for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:52 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSO-00075p-Pr for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:48 -0500 Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7HVdNu010826; Thu, 7 Dec 2023 18:50:42 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3utdc1cg00-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:41 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7HOJfY039780; Thu, 7 Dec 2023 18:50:41 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3utan7vhyn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:41 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3B7Io90W008067; Thu, 7 Dec 2023 18:50:40 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3utan7vh2k-21; Thu, 07 Dec 2023 18:50:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=EthSTSZAGUdFGpGUUgIS40/qu5PWf2EuzefpgEB0S8Y=; b=fiNpDcI7jkLvuU7c9McRT5f3QPpsAqnKiiZtWmucBPbpUonY3I53aERnM+56LaofjjDn rWsHB5eW2auOaBt55IpF5JNnCwXCTCCnCfHeOQcS8vCtw5sBW3wb63gktQG9hEPfDxpP wKhOC/f84hDWkLyXSW5ULbqIcm/DNnI9vw1XPJKdGADXDTzRJY+xyDyW5f9eaIHhNNqT ysoVQN0Lrn5RWJxTLNQbCqm9i8/UFtiB8stZ3DFwg1CveT4sktaAJZmtKgNbiA/mfUrM 5S0/VWIjL4w8gdQLNd5d94GSxRvc/ABOf0MDMrP6EWyfDUgFeTfJrNJed4X5472sDcmx AQ== From: Si-Wei Liu To: eperezma@redhat.com, jasowang@redhat.com, mst@redhat.com, dtatulea@nvidia.com, leiyang@redhat.com, yin31149@gmail.com, boris.ostrovsky@oracle.com, jonah.palmer@oracle.com Cc: qemu-devel@nongnu.org Subject: [PATCH 20/40] vdpa: avoid mapping flush across reset Date: Thu, 7 Dec 2023 09:39:33 -0800 Message-Id: <1701970793-6865-21-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> References: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-07_15,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312070156 X-Proofpoint-GUID: W5odj9H8iuFszJ3247q5atcCldSAVR7C X-Proofpoint-ORIG-GUID: W5odj9H8iuFszJ3247q5atcCldSAVR7C Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.165.32; envelope-from=si-wei.liu@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1701975217295100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Leverage the IOTLB_PERSIST and DESC_ASID features to achieve a slightly light weight reset path, without resorting to suspend and resume. Not as best but it offers significant time saving too, which should somehow play its role in live migration down time reduction by large. It benefits two cases: - normal virtio reset in the VM, e.g. guest reboot, don't have to tear down all iotlb mapping and set up again. - SVQ switching, in which data vq's descriptor table and vrings are moved to a different ASID than where its buffers reside. Along with the use of persistent iotlb, it would save substantial time from pinning and mapping unneccessarily when moving descriptors on to or out of shadow mode. Signed-off-by: Si-Wei Liu --- hw/virtio/vhost-vdpa.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 31e0a55..47c764b 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -633,6 +633,7 @@ static int vhost_vdpa_init(struct vhost_dev *dev, void = *opaque, Error **errp) 0x1ULL << VHOST_BACKEND_F_IOTLB_BATCH= | 0x1ULL << VHOST_BACKEND_F_IOTLB_ASID | 0x1ULL << VHOST_BACKEND_F_DESC_ASID | + 0x1ULL << VHOST_BACKEND_F_IOTLB_PERSI= ST | 0x1ULL << VHOST_BACKEND_F_SUSPEND; int ret; =20 @@ -1493,8 +1494,6 @@ static void vhost_vdpa_maybe_flush_map(struct vhost_d= ev *dev) =20 static void vhost_vdpa_reset_status(struct vhost_dev *dev) { - struct vhost_vdpa *v =3D dev->opaque; - if (!vhost_vdpa_last_dev(dev)) { return; } @@ -1502,9 +1501,7 @@ static void vhost_vdpa_reset_status(struct vhost_dev = *dev) vhost_vdpa_reset_device(dev); vhost_vdpa_add_status(dev, VIRTIO_CONFIG_S_ACKNOWLEDGE | VIRTIO_CONFIG_S_DRIVER); - memory_listener_unregister(&v->shared->listener); - v->shared->listener_registered =3D false; - + vhost_vdpa_maybe_flush_map(dev); } =20 static int vhost_vdpa_set_log_base(struct vhost_dev *dev, uint64_t base, --=20 1.8.3.1 From nobody Wed Nov 27 00:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1701975154; cv=none; d=zohomail.com; s=zohoarc; b=lIlRwjTviqsaA6JOX3F52dKffO2yBJFDDCz0rnR4padhDFJH8oBptS59VBv7HBayqADTA3Guw01FA68dgKiKbERMyIWOrvNyoDu9sooijg9FYyuC/5lQm/eFKoyi6qtgx7CUf1aqKKhrpuBccJcVfQUxex5M6znuzsIVAXgHGLw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701975154; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=rCzHnfkwKPT4JYuH9v8Cdemma7Tb5LZVKQwQbSmCGCM=; b=gyNGo4MAc9JbjT+xh7CUvAVGFrck2ZLfYiIWmnW+WNTEN0S5v8C4w2GteVF3oiwZylX1l6huzJo8MvRpyjFLBIEV5EzdYCMH36IsumvAXYygCcukdrmwU4TlKMgjBFKvva409tC+yzIeimmYoKmVGriwlCKx6FGDS6tI6hzfdLw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 170197515482555.91299673919525; Thu, 7 Dec 2023 10:52:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBJSf-0003ev-W2; Thu, 07 Dec 2023 13:51:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSa-0003d6-9h for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:58 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSS-000768-6S for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:53 -0500 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7IJFbR006249; Thu, 7 Dec 2023 18:50:43 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3utdabvge1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:43 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7Hrf0K039610; Thu, 7 Dec 2023 18:50:42 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3utan7vj0n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:42 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3B7Io90Y008067; Thu, 7 Dec 2023 18:50:42 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3utan7vh2k-22; Thu, 07 Dec 2023 18:50:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=rCzHnfkwKPT4JYuH9v8Cdemma7Tb5LZVKQwQbSmCGCM=; b=S83Bwx0Sm+W8pLeWpegkjjLL2R8EriAiSKpfVWAJgkZySy0m0FzY7zHtrG2maYA6hQe7 aiSCR4alCk7KgnJ11avOT/1c3qM3HSAWPeImwTSO4WQvKzLBuhvGPYjN+1EJjhQFBjEh nQRVQP9QJQAG/PuL2TWMhFGZPugDlfMCsaNxJe6zQaRyKPxsmsJdvhJr/CPr6nI/b8vH kjLLnzMTtzkOXeAMyg0WW+nZQK+aEXF1WgOKj3jIl47qrylZ0LDst/4aq/NJlOkaGWE2 u5qhfNtumh6f/Gc6buzBM10sERIxNGhkz36PsMAvKg2YGCbHdYEVbsYfzVMhdQs3jKZH vg== From: Si-Wei Liu To: eperezma@redhat.com, jasowang@redhat.com, mst@redhat.com, dtatulea@nvidia.com, leiyang@redhat.com, yin31149@gmail.com, boris.ostrovsky@oracle.com, jonah.palmer@oracle.com Cc: qemu-devel@nongnu.org Subject: [PATCH 21/40] vdpa: vhost_vdpa_dma_batch_end_once rename Date: Thu, 7 Dec 2023 09:39:34 -0800 Message-Id: <1701970793-6865-22-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> References: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-07_15,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312070156 X-Proofpoint-ORIG-GUID: KdXaukVOZBlx2C3Dmk_NjLvQJU1DF52c X-Proofpoint-GUID: KdXaukVOZBlx2C3Dmk_NjLvQJU1DF52c Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.177.32; envelope-from=si-wei.liu@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1701975155878100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" No functional changes. Rename only. Signed-off-by: Si-Wei Liu --- hw/virtio/vhost-vdpa.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 47c764b..013bfa2 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -191,7 +191,7 @@ static void vhost_vdpa_iotlb_batch_begin_once(VhostVDPA= Shared *s) s->iotlb_batch_begin_sent =3D true; } =20 -static void vhost_vdpa_dma_end_batch(VhostVDPAShared *s) +static void vhost_vdpa_dma_batch_end_once(VhostVDPAShared *s) { struct vhost_msg_v2 msg =3D {}; int fd =3D s->device_fd; @@ -229,7 +229,7 @@ static void vhost_vdpa_listener_commit(MemoryListener *= listener) { VhostVDPAShared *s =3D container_of(listener, VhostVDPAShared, listene= r); =20 - vhost_vdpa_dma_end_batch(s); + vhost_vdpa_dma_batch_end_once(s); } =20 static void vhost_vdpa_iommu_map_notify(IOMMUNotifier *n, IOMMUTLBEntry *i= otlb) @@ -1367,7 +1367,7 @@ static void *vhost_vdpa_load_map(void *opaque) vhost_vdpa_iotlb_batch_begin_once(shared); break; case VHOST_IOTLB_BATCH_END: - vhost_vdpa_dma_end_batch(shared); + vhost_vdpa_dma_batch_end_once(shared); break; default: error_report("Invalid IOTLB msg type %d", msg->iotlb.type); --=20 1.8.3.1 From nobody Wed Nov 27 00:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1701975480; cv=none; d=zohomail.com; s=zohoarc; b=iQ6tUn0r1ycRk+uTJGQnrsNYa1fsFG1ybQSUUkoHV5W1w0Rytw0JJoT5lq52D73EQ2V+l3TBu14pr5hRGL4R9p0nVN2SWeXUrfDdI4OTS0wtFuYnEWkjNHZPWnUaNX1Ai76rgejum0QQyMcBjaN7r+0as5tS/q+hsMs7uxbKoW4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701975480; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=oSWk8NLfi5dV39YdUg3W+vNsFQfTt4s1cR4DL0KLrSY=; b=c/54tdL1XGAizuw+kqbzIeUOVqINnWIw9xnosqUdAPvSVMXv8d+w/R1NRU/qo9oNyj3rrw+PBf7SQxs6ka7gO7hOMAXqICCh/kYdyFBqxmcdAkrM/V2mat16kk04FK5MHeAVfV7l1DnyQeITF6bbau5sib5HmIGAaU9MUUdS4nw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1701975480517696.0236084567038; Thu, 7 Dec 2023 10:58:00 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBJSm-0003qE-56; Thu, 07 Dec 2023 13:51:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSW-0003cT-7D for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:53 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSR-00076R-3a for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:51 -0500 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 3B7Hx09A028566; Thu, 7 Dec 2023 18:50:45 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3utd0hmjtq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:44 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7Hcvr4039979; Thu, 7 Dec 2023 18:50:44 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3utan7vj1q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:44 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3B7Io90a008067; Thu, 7 Dec 2023 18:50:43 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3utan7vh2k-23; Thu, 07 Dec 2023 18:50:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=oSWk8NLfi5dV39YdUg3W+vNsFQfTt4s1cR4DL0KLrSY=; b=NJsCcMar4YwwEeGj0cvfLu+EtKsrs8XuD6DuVrLhUOsxgJ8+qIzWrt0if9rfgeuyE6Ci 6A1/0A3bh1vvA+s7iR30j4B7LzwqNlOeGuC0YAF6zN4JFoXKzLyHWRlPSumvBRcgPC+A xcWqAL5ECVG94vkl06kRX+NKSUnuaReceWJYBWywHdezRNgBU7yKvgQlbpm59zAx1DwC crTTdmLOxyytm1CJqhlGJTAO5GEIVI6SMJnMNkaivYztVC5qrbVUsc9wOu3isSHgjC0r tHtnh24bDHlDhDu4luBbI39yF8WWhZYdcG/rSq/s4z2Et4/QVauG4uv5A0Rnizch5RqW JQ== From: Si-Wei Liu To: eperezma@redhat.com, jasowang@redhat.com, mst@redhat.com, dtatulea@nvidia.com, leiyang@redhat.com, yin31149@gmail.com, boris.ostrovsky@oracle.com, jonah.palmer@oracle.com Cc: qemu-devel@nongnu.org Subject: [PATCH 22/40] vdpa: factor out vhost_vdpa_map_batch_begin Date: Thu, 7 Dec 2023 09:39:35 -0800 Message-Id: <1701970793-6865-23-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> References: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-07_15,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312070156 X-Proofpoint-GUID: 424P1H1d3w_4EdSqgyefR05OHlkVmnHS X-Proofpoint-ORIG-GUID: 424P1H1d3w_4EdSqgyefR05OHlkVmnHS Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.165.32; envelope-from=si-wei.liu@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1701975481393100004 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Refactoring only. No functional change. Signed-off-by: Si-Wei Liu Acked-by: Jason Wang --- hw/virtio/trace-events | 2 +- hw/virtio/vhost-vdpa.c | 25 ++++++++++++++++--------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index 9725d44..b0239b8 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -32,7 +32,7 @@ vhost_user_create_notifier(int idx, void *n) "idx:%d n:%p" # vhost-vdpa.c vhost_vdpa_dma_map(void *vdpa, int fd, uint32_t msg_type, uint32_t asid, u= int64_t iova, uint64_t size, uint64_t uaddr, uint8_t perm, uint8_t type) "v= dpa_shared:%p fd: %d msg_type: %"PRIu32" asid: %"PRIu32" iova: 0x%"PRIx64" = size: 0x%"PRIx64" uaddr: 0x%"PRIx64" perm: 0x%"PRIx8" type: %"PRIu8 vhost_vdpa_dma_unmap(void *vdpa, int fd, uint32_t msg_type, uint32_t asid,= uint64_t iova, uint64_t size, uint8_t type) "vdpa_shared:%p fd: %d msg_typ= e: %"PRIu32" asid: %"PRIu32" iova: 0x%"PRIx64" size: 0x%"PRIx64" type: %"PR= Iu8 -vhost_vdpa_listener_begin_batch(void *v, int fd, uint32_t msg_type, uint8_= t type) "vdpa_shared:%p fd: %d msg_type: %"PRIu32" type: %"PRIu8 +vhost_vdpa_map_batch_begin(void *v, int fd, uint32_t msg_type, uint8_t typ= e) "vdpa_shared:%p fd: %d msg_type: %"PRIu32" type: %"PRIu8 vhost_vdpa_listener_commit(void *v, int fd, uint32_t msg_type, uint8_t typ= e) "vdpa_shared:%p fd: %d msg_type: %"PRIu32" type: %"PRIu8 vhost_vdpa_listener_region_add_unaligned(void *v, const char *name, uint64= _t offset_as, uint64_t offset_page) "vdpa_shared: %p region %s offset_withi= n_address_space %"PRIu64" offset_within_region %"PRIu64 vhost_vdpa_listener_region_add(void *vdpa, uint64_t iova, uint64_t llend, = void *vaddr, bool readonly) "vdpa: %p iova 0x%"PRIx64" llend 0x%"PRIx64" va= ddr: %p read-only: %d" diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 013bfa2..7a1b7f4 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -161,7 +161,7 @@ int vhost_vdpa_dma_unmap(VhostVDPAShared *s, uint32_t a= sid, hwaddr iova, return ret; } =20 -static void vhost_vdpa_iotlb_batch_begin_once(VhostVDPAShared *s) +static bool vhost_vdpa_map_batch_begin(VhostVDPAShared *s) { int fd =3D s->device_fd; struct vhost_msg_v2 msg =3D { @@ -169,26 +169,33 @@ static void vhost_vdpa_iotlb_batch_begin_once(VhostVD= PAShared *s) .iotlb.type =3D VHOST_IOTLB_BATCH_BEGIN, }; =20 - if (!(s->backend_cap & (0x1ULL << VHOST_BACKEND_F_IOTLB_BATCH)) || - s->iotlb_batch_begin_sent) { - return; - } - if (s->map_thread_enabled && !qemu_thread_is_self(&s->map_thread)) { struct vhost_msg_v2 *new_msg =3D g_new(struct vhost_msg_v2, 1); =20 *new_msg =3D msg; g_async_queue_push(s->map_queue, new_msg); =20 - return; + return false; } =20 - trace_vhost_vdpa_listener_begin_batch(s, fd, msg.type, msg.iotlb.type); + trace_vhost_vdpa_map_batch_begin(s, fd, msg.type, msg.iotlb.type); if (write(fd, &msg, sizeof(msg)) !=3D sizeof(msg)) { error_report("failed to write, fd=3D%d, errno=3D%d (%s)", fd, errno, strerror(errno)); } - s->iotlb_batch_begin_sent =3D true; + return true; +} + +static void vhost_vdpa_iotlb_batch_begin_once(VhostVDPAShared *s) +{ + if (!(s->backend_cap & (0x1ULL << VHOST_BACKEND_F_IOTLB_BATCH)) || + s->iotlb_batch_begin_sent) { + return; + } + + if (vhost_vdpa_map_batch_begin(s)) { + s->iotlb_batch_begin_sent =3D true; + } } =20 static void vhost_vdpa_dma_batch_end_once(VhostVDPAShared *s) --=20 1.8.3.1 From nobody Wed Nov 27 00:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1701975198; cv=none; d=zohomail.com; s=zohoarc; b=nfcFMnvUiqmxE0TJBtZEaPmE8xle4RCYrSa/oryK0+8Uoy7baH8IZ4edKl5uOBwE9ob1oIqWgxfvOrG6I08HuJu+Ks5VgXzu15SGcV06FafUg5YmfdiDkpeQBPcm2GYSrz9xlfkNlNN1XJXg/yw4wt+R2tMHq0/OjkozifQrpEk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701975198; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=DxpWETRXyV33aWVhz27vZT9JTn25BNRlFUePIY4gwgM=; b=LxkdPtyws4xWtXFl/uL7OzF5JcF8g2S8XrpDzSWYCkf98GYrWd1DHFe0eFa3jnxpwWTOxNjAE7XLwKYpq2URfb3siagmU0lw58DPYjsU3aa95lqkwH5EFC7alkapBu1IofXTTEfAUagbT51ASEZhkPI9ZCD9j3d6oPx4iahbNXg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1701975198879177.5641229342176; Thu, 7 Dec 2023 10:53:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBJSt-0003yA-NF; Thu, 07 Dec 2023 13:51:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSa-0003d8-9h for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:58 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSW-00076j-6r for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:53 -0500 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7GDP6O031570; Thu, 7 Dec 2023 18:50:46 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3utdrvmpfn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:46 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7HNN94039498; Thu, 7 Dec 2023 18:50:45 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3utan7vj30-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:45 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3B7Io90c008067; Thu, 7 Dec 2023 18:50:45 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3utan7vh2k-24; Thu, 07 Dec 2023 18:50:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=DxpWETRXyV33aWVhz27vZT9JTn25BNRlFUePIY4gwgM=; b=Y078tMi9V5gxDYy1HeyHVhgeU/Xa9WL6n8dUqeNWMuDYiQTU0MqKHBJCII4tDEcjJpVg GMNGvtRcoW4Ov0LEYXXVQXzcoGtixd1a0AOfMAkGICYR1rkCz+nNbOWFLUG7836A//uo XjgJHI8N1GAvRiaUawQl0fNm7I7niCC/RyzPxsJO7HYAFz/YrWCSmkKEwNeaJ32GT63X +JqKHJN9Bwg0cc6V+hqYirPxQpw9f74mINBt6xZQdxhRH76ydONttEwjxbOXunkRJ15Y 40apCsKFMlYvXNAr2l0d870btKP3rlov5ed37IMwt8AFLDYiB/CczaJLRRCJkwR1H8/0 DA== From: Si-Wei Liu To: eperezma@redhat.com, jasowang@redhat.com, mst@redhat.com, dtatulea@nvidia.com, leiyang@redhat.com, yin31149@gmail.com, boris.ostrovsky@oracle.com, jonah.palmer@oracle.com Cc: qemu-devel@nongnu.org Subject: [PATCH 23/40] vdpa: vhost_vdpa_dma_batch_begin_once rename Date: Thu, 7 Dec 2023 09:39:36 -0800 Message-Id: <1701970793-6865-24-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> References: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-07_15,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312070156 X-Proofpoint-GUID: 7v0XLWao16LyHgiiiQqFsKmf-VmYa7wd X-Proofpoint-ORIG-GUID: 7v0XLWao16LyHgiiiQqFsKmf-VmYa7wd Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.177.32; envelope-from=si-wei.liu@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1701975200854100003 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" No functional changes. Rename only. Signed-off-by: Si-Wei Liu --- hw/virtio/vhost-vdpa.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 7a1b7f4..a6c6fe5 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -186,7 +186,7 @@ static bool vhost_vdpa_map_batch_begin(VhostVDPAShared = *s) return true; } =20 -static void vhost_vdpa_iotlb_batch_begin_once(VhostVDPAShared *s) +static void vhost_vdpa_dma_batch_begin_once(VhostVDPAShared *s) { if (!(s->backend_cap & (0x1ULL << VHOST_BACKEND_F_IOTLB_BATCH)) || s->iotlb_batch_begin_sent) { @@ -411,7 +411,7 @@ static void vhost_vdpa_listener_region_add(MemoryListen= er *listener, iova =3D mem_region.iova; } =20 - vhost_vdpa_iotlb_batch_begin_once(s); + vhost_vdpa_dma_batch_begin_once(s); ret =3D vhost_vdpa_dma_map(s, VHOST_VDPA_GUEST_PA_ASID, iova, int128_get64(llsize), vaddr, section->readonl= y); if (ret) { @@ -493,7 +493,7 @@ static void vhost_vdpa_listener_region_del(MemoryListen= er *listener, iova =3D result->iova; vhost_iova_tree_remove(s->iova_tree, *result); } - vhost_vdpa_iotlb_batch_begin_once(s); + vhost_vdpa_dma_batch_begin_once(s); /* * The unmap ioctl doesn't accept a full 64-bit. need to check it */ @@ -1371,7 +1371,7 @@ static void *vhost_vdpa_load_map(void *opaque) msg->iotlb.size); break; case VHOST_IOTLB_BATCH_BEGIN: - vhost_vdpa_iotlb_batch_begin_once(shared); + vhost_vdpa_dma_batch_begin_once(shared); break; case VHOST_IOTLB_BATCH_END: vhost_vdpa_dma_batch_end_once(shared); --=20 1.8.3.1 From nobody Wed Nov 27 00:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1701975342; cv=none; d=zohomail.com; s=zohoarc; b=d/3B4gvfnoA7Edom72WHa6LDlpxjby6y7zRaJJ5xR4cRaFbzqPmTQ+Vqeq06t3SkTFpfE2z3QpJv+ZrluxjLsdFT3HkZ4Is3b3OIk9x++xgn9erEnIvOZlwZkIWTt7bdglMn+ddBWrJVPvM2l8Wa0dSs8GqLkS0ZsV3GovfGErY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701975342; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BS7Msf1TqnmvtthANunCKzo/Ed1i9XdmfTaEX+ayVFI=; b=jE5ltSU/d8upqdtb5tIwePEwzt65XmP1UKUZLKwkTvy/npa2/rfcaAJunnpMW38jxLTl0rrJ9LQ/Hfk/JNfFghO3gMpJpK23w3Alq9mINrjW/FaNyujeeY34TeTCgRMgwLfUL998c5272Gg2NlQesxbE7wmir4ZEhuh8G1NPHLk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1701975342090598.7736978834336; Thu, 7 Dec 2023 10:55:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBJSp-0003ug-81; Thu, 07 Dec 2023 13:51:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSj-0003n7-Oa for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:51:05 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSg-000789-7w for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:51:05 -0500 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7IDQpq023130; Thu, 7 Dec 2023 18:50:48 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3utdmbmnt5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:47 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7HnhAw039577; Thu, 7 Dec 2023 18:50:47 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3utan7vj49-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:46 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3B7Io90e008067; Thu, 7 Dec 2023 18:50:46 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3utan7vh2k-25; Thu, 07 Dec 2023 18:50:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=BS7Msf1TqnmvtthANunCKzo/Ed1i9XdmfTaEX+ayVFI=; b=MEiCigPllYgrcPiGHSlkHzk4PEmr/Fva8BcydEFqm7XyDxj5dakVUl/STeitaHDtps+L j57r/8UpCU8pEemX/FyFCB/7JndRQNBNkLEbX8yDmUBvV4vVM3YOfMsE8O2sjsT7fDmw i13hoEgit6nZHC7+CFjmyyyq56vzPWSQQ0iCBsF5xb0xJ0ohOMNMYZkmarY3TJlb7iMb wcV0bul449HEJ5xtMO08PN31+NvpqACLN+pfiEJ3MGKBFx6Xk2EXQliEXk+0ZoFsW4vj 9YyqKYN5ycyJdnOUMSEpiuszn/Fk6biCyy8/VtKvj2nsHWMrDT4cPBWKtH1FxmOC6709 5w== From: Si-Wei Liu To: eperezma@redhat.com, jasowang@redhat.com, mst@redhat.com, dtatulea@nvidia.com, leiyang@redhat.com, yin31149@gmail.com, boris.ostrovsky@oracle.com, jonah.palmer@oracle.com Cc: qemu-devel@nongnu.org Subject: [PATCH 24/40] vdpa: factor out vhost_vdpa_dma_batch_end Date: Thu, 7 Dec 2023 09:39:37 -0800 Message-Id: <1701970793-6865-25-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> References: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-07_15,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312070156 X-Proofpoint-ORIG-GUID: wHLI1iagrlgzCyDbdjh7a-OQF9ypWRiT X-Proofpoint-GUID: wHLI1iagrlgzCyDbdjh7a-OQF9ypWRiT Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.177.32; envelope-from=si-wei.liu@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1701975344081100009 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Refactoring only. No functional change. Signed-off-by: Si-Wei Liu --- hw/virtio/trace-events | 2 +- hw/virtio/vhost-vdpa.c | 30 ++++++++++++++++++------------ 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index b0239b8..3411a07 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -33,7 +33,7 @@ vhost_user_create_notifier(int idx, void *n) "idx:%d n:%p" vhost_vdpa_dma_map(void *vdpa, int fd, uint32_t msg_type, uint32_t asid, u= int64_t iova, uint64_t size, uint64_t uaddr, uint8_t perm, uint8_t type) "v= dpa_shared:%p fd: %d msg_type: %"PRIu32" asid: %"PRIu32" iova: 0x%"PRIx64" = size: 0x%"PRIx64" uaddr: 0x%"PRIx64" perm: 0x%"PRIx8" type: %"PRIu8 vhost_vdpa_dma_unmap(void *vdpa, int fd, uint32_t msg_type, uint32_t asid,= uint64_t iova, uint64_t size, uint8_t type) "vdpa_shared:%p fd: %d msg_typ= e: %"PRIu32" asid: %"PRIu32" iova: 0x%"PRIx64" size: 0x%"PRIx64" type: %"PR= Iu8 vhost_vdpa_map_batch_begin(void *v, int fd, uint32_t msg_type, uint8_t typ= e) "vdpa_shared:%p fd: %d msg_type: %"PRIu32" type: %"PRIu8 -vhost_vdpa_listener_commit(void *v, int fd, uint32_t msg_type, uint8_t typ= e) "vdpa_shared:%p fd: %d msg_type: %"PRIu32" type: %"PRIu8 +vhost_vdpa_dma_batch_end(void *v, int fd, uint32_t msg_type, uint8_t type)= "vdpa_shared:%p fd: %d msg_type: %"PRIu32" type: %"PRIu8 vhost_vdpa_listener_region_add_unaligned(void *v, const char *name, uint64= _t offset_as, uint64_t offset_page) "vdpa_shared: %p region %s offset_withi= n_address_space %"PRIu64" offset_within_region %"PRIu64 vhost_vdpa_listener_region_add(void *vdpa, uint64_t iova, uint64_t llend, = void *vaddr, bool readonly) "vdpa: %p iova 0x%"PRIx64" llend 0x%"PRIx64" va= ddr: %p read-only: %d" vhost_vdpa_listener_region_del_unaligned(void *v, const char *name, uint64= _t offset_as, uint64_t offset_page) "vdpa_shared: %p region %s offset_withi= n_address_space %"PRIu64" offset_within_region %"PRIu64 diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index a6c6fe5..999a97a 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -198,19 +198,11 @@ static void vhost_vdpa_dma_batch_begin_once(VhostVDPA= Shared *s) } } =20 -static void vhost_vdpa_dma_batch_end_once(VhostVDPAShared *s) +static bool vhost_vdpa_dma_batch_end(VhostVDPAShared *s) { struct vhost_msg_v2 msg =3D {}; int fd =3D s->device_fd; =20 - if (!(s->backend_cap & (0x1ULL << VHOST_BACKEND_F_IOTLB_BATCH))) { - return; - } - - if (!s->iotlb_batch_begin_sent) { - return; - } - msg.type =3D VHOST_IOTLB_MSG_V2; msg.iotlb.type =3D VHOST_IOTLB_BATCH_END; =20 @@ -220,16 +212,30 @@ static void vhost_vdpa_dma_batch_end_once(VhostVDPASh= ared *s) *new_msg =3D msg; g_async_queue_push(s->map_queue, new_msg); =20 - return; + return false; } =20 - trace_vhost_vdpa_listener_commit(s, fd, msg.type, msg.iotlb.type); + trace_vhost_vdpa_dma_batch_end(s, fd, msg.type, msg.iotlb.type); if (write(fd, &msg, sizeof(msg)) !=3D sizeof(msg)) { error_report("failed to write, fd=3D%d, errno=3D%d (%s)", fd, errno, strerror(errno)); } + return true; +} + +static void vhost_vdpa_dma_batch_end_once(VhostVDPAShared *s) +{ + if (!(s->backend_cap & (0x1ULL << VHOST_BACKEND_F_IOTLB_BATCH))) { + return; + } + + if (!s->iotlb_batch_begin_sent) { + return; + } =20 - s->iotlb_batch_begin_sent =3D false; + if (vhost_vdpa_dma_batch_end(s)) { + s->iotlb_batch_begin_sent =3D false; + } } =20 static void vhost_vdpa_listener_commit(MemoryListener *listener) --=20 1.8.3.1 From nobody Wed Nov 27 00:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1701975083; cv=none; d=zohomail.com; s=zohoarc; b=b2wXw1J74FPkNX7OVWocnq/XnzmtvWhCcMkJnpc43LmjVsxuJ3ayGbn3C7FiGhCca7gmyfA1SvIfnK7aWIzlScH2ZnbCengr6EaYWVfyRqTCD4JXKFwXU6ov1uzNL95n11yw3DynmpRvM7wMzx7Wi+1mAu4tR3YlREPqyPsmf5c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701975083; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=FuWoZYg+OylOSDGU0DmVC1aA59KXXhNhadiSgZ9OM78=; b=eIGHcMQJe9Yj/MSDXYsoacw4+xMMIdUZ7b/O/eBmk3WXKMOu9xLr3Lq+ee5VatDN3XDShrEgQ9hGq/DO3+9y0OYBcaxN+U/Pq6cE42D6+PpNlB1KwbcMIPwi1qdSOSL4G5n41BlOT2yAiI3ggP0LCv39k72/uf6qoCGfKD8IJK4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1701975083674427.00501146489; Thu, 7 Dec 2023 10:51:23 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBJSl-0003pK-Qp; Thu, 07 Dec 2023 13:51:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSa-0003d9-Ag for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:58 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSW-000796-Fi for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:56 -0500 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 3B7HFTxV007979; Thu, 7 Dec 2023 18:50:49 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3utd0hmjtu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:49 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7InFew039579; Thu, 7 Dec 2023 18:50:48 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3utan7vj5c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:48 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3B7Io90g008067; Thu, 7 Dec 2023 18:50:47 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3utan7vh2k-26; Thu, 07 Dec 2023 18:50:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=FuWoZYg+OylOSDGU0DmVC1aA59KXXhNhadiSgZ9OM78=; b=ZtFFnG35R8XaUpae/IkQLgcxtp5InSCZ614k4r3QImIljrfxQUy8hB+gyY9+mptx8tgi M2EAxig/QdKD9SRNhbOzJmu5RF8S+7TW+oHXkqdZBKu9MHaDr6lFbPOiLVxBJDpzp+q5 B4UyFWI+E1GCIgHDARUYTyXpadOk0cldvcuna/D2KhHUCoHb37UgFfY2+vHFJ6UM8YNg FGx2Dww3L0SuW4xANb4ULJF1DAu8K9v3+ScDGnOv3yfzyi8S6DUCCUjz5ZBvyh7Rfftc 25G+/q2jYyjXr8oWHjmRJk4NZuTlSM7dkB5mBm7thkQPclgZnWmnXecPj7VvtROT27y6 4g== From: Si-Wei Liu To: eperezma@redhat.com, jasowang@redhat.com, mst@redhat.com, dtatulea@nvidia.com, leiyang@redhat.com, yin31149@gmail.com, boris.ostrovsky@oracle.com, jonah.palmer@oracle.com Cc: qemu-devel@nongnu.org Subject: [PATCH 25/40] vdpa: add asid to dma_batch_once API Date: Thu, 7 Dec 2023 09:39:38 -0800 Message-Id: <1701970793-6865-26-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> References: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-07_15,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312070156 X-Proofpoint-GUID: GgEBq_STXTzs1jNyPD5vEXSIz9aX4Nug X-Proofpoint-ORIG-GUID: GgEBq_STXTzs1jNyPD5vEXSIz9aX4Nug Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.165.32; envelope-from=si-wei.liu@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1701975084370100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" So that DMA batching API can operate on other ASID than 0. Signed-off-by: Si-Wei Liu --- hw/virtio/trace-events | 4 ++-- hw/virtio/vhost-vdpa.c | 14 ++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index 3411a07..196f32f 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -32,8 +32,8 @@ vhost_user_create_notifier(int idx, void *n) "idx:%d n:%p" # vhost-vdpa.c vhost_vdpa_dma_map(void *vdpa, int fd, uint32_t msg_type, uint32_t asid, u= int64_t iova, uint64_t size, uint64_t uaddr, uint8_t perm, uint8_t type) "v= dpa_shared:%p fd: %d msg_type: %"PRIu32" asid: %"PRIu32" iova: 0x%"PRIx64" = size: 0x%"PRIx64" uaddr: 0x%"PRIx64" perm: 0x%"PRIx8" type: %"PRIu8 vhost_vdpa_dma_unmap(void *vdpa, int fd, uint32_t msg_type, uint32_t asid,= uint64_t iova, uint64_t size, uint8_t type) "vdpa_shared:%p fd: %d msg_typ= e: %"PRIu32" asid: %"PRIu32" iova: 0x%"PRIx64" size: 0x%"PRIx64" type: %"PR= Iu8 -vhost_vdpa_map_batch_begin(void *v, int fd, uint32_t msg_type, uint8_t typ= e) "vdpa_shared:%p fd: %d msg_type: %"PRIu32" type: %"PRIu8 -vhost_vdpa_dma_batch_end(void *v, int fd, uint32_t msg_type, uint8_t type)= "vdpa_shared:%p fd: %d msg_type: %"PRIu32" type: %"PRIu8 +vhost_vdpa_map_batch_begin(void *v, int fd, uint32_t msg_type, uint8_t typ= e, uint32_t asid) "vdpa_shared:%p fd: %d msg_type: %"PRIu32" type: %"PRIu8= " asid: %"PRIu32 +vhost_vdpa_dma_batch_end(void *v, int fd, uint32_t msg_type, uint8_t type,= uint32_t asid) "vdpa_shared:%p fd: %d msg_type: %"PRIu32" type: %"PRIu8" = asid: %"PRIu32 vhost_vdpa_listener_region_add_unaligned(void *v, const char *name, uint64= _t offset_as, uint64_t offset_page) "vdpa_shared: %p region %s offset_withi= n_address_space %"PRIu64" offset_within_region %"PRIu64 vhost_vdpa_listener_region_add(void *vdpa, uint64_t iova, uint64_t llend, = void *vaddr, bool readonly) "vdpa: %p iova 0x%"PRIx64" llend 0x%"PRIx64" va= ddr: %p read-only: %d" vhost_vdpa_listener_region_del_unaligned(void *v, const char *name, uint64= _t offset_as, uint64_t offset_page) "vdpa_shared: %p region %s offset_withi= n_address_space %"PRIu64" offset_within_region %"PRIu64 diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 999a97a..2db2832 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -161,11 +161,12 @@ int vhost_vdpa_dma_unmap(VhostVDPAShared *s, uint32_t= asid, hwaddr iova, return ret; } =20 -static bool vhost_vdpa_map_batch_begin(VhostVDPAShared *s) +static bool vhost_vdpa_map_batch_begin(VhostVDPAShared *s, uint32_t asid) { int fd =3D s->device_fd; struct vhost_msg_v2 msg =3D { .type =3D VHOST_IOTLB_MSG_V2, + .asid =3D asid, .iotlb.type =3D VHOST_IOTLB_BATCH_BEGIN, }; =20 @@ -178,7 +179,7 @@ static bool vhost_vdpa_map_batch_begin(VhostVDPAShared = *s) return false; } =20 - trace_vhost_vdpa_map_batch_begin(s, fd, msg.type, msg.iotlb.type); + trace_vhost_vdpa_map_batch_begin(s, fd, msg.type, msg.iotlb.type, msg.= asid); if (write(fd, &msg, sizeof(msg)) !=3D sizeof(msg)) { error_report("failed to write, fd=3D%d, errno=3D%d (%s)", fd, errno, strerror(errno)); @@ -193,17 +194,18 @@ static void vhost_vdpa_dma_batch_begin_once(VhostVDPA= Shared *s) return; } =20 - if (vhost_vdpa_map_batch_begin(s)) { + if (vhost_vdpa_map_batch_begin(s, 0)) { s->iotlb_batch_begin_sent =3D true; } } =20 -static bool vhost_vdpa_dma_batch_end(VhostVDPAShared *s) +static bool vhost_vdpa_dma_batch_end(VhostVDPAShared *s, uint32_t asid) { struct vhost_msg_v2 msg =3D {}; int fd =3D s->device_fd; =20 msg.type =3D VHOST_IOTLB_MSG_V2; + msg.asid =3D asid; msg.iotlb.type =3D VHOST_IOTLB_BATCH_END; =20 if (s->map_thread_enabled && !qemu_thread_is_self(&s->map_thread)) { @@ -215,7 +217,7 @@ static bool vhost_vdpa_dma_batch_end(VhostVDPAShared *s) return false; } =20 - trace_vhost_vdpa_dma_batch_end(s, fd, msg.type, msg.iotlb.type); + trace_vhost_vdpa_dma_batch_end(s, fd, msg.type, msg.iotlb.type, msg.as= id); if (write(fd, &msg, sizeof(msg)) !=3D sizeof(msg)) { error_report("failed to write, fd=3D%d, errno=3D%d (%s)", fd, errno, strerror(errno)); @@ -233,7 +235,7 @@ static void vhost_vdpa_dma_batch_end_once(VhostVDPAShar= ed *s) return; } =20 - if (vhost_vdpa_dma_batch_end(s)) { + if (vhost_vdpa_dma_batch_end(s, 0)) { s->iotlb_batch_begin_sent =3D false; } } --=20 1.8.3.1 From nobody Wed Nov 27 00:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1701975159; cv=none; d=zohomail.com; s=zohoarc; b=akbjCdJ0gBop5zqIjyYkMvJBlAEaFQnS6hzaczsD89p3nsQTKiwURAfU3IZrXet6mfS0niTFW+zbCNF8KvGd6Yi6HANHmI892dYlbzah4W+AtztfzZ5rCdq8PK6vrMAAQRLhRvmnByYBjJ6vHSprt2zbE+uv6FrsKAgeRkywKDY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701975159; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=6xgia7g1oUY0RjFvspZ/n8yXNYyUzWdL6U6DAU8F9r4=; b=jEzeuFRMt08oI4L8J6/v+To6ySlaJmqMsXSmSfQ0mRqBfdl8CcErHIJfQfrJ/4zSNQm8yUKO/V5d5O+7RGjNaPnQk9xYNkEw9tKLCVq+OTwVDkdhypdbl+lVNZwdClG9xI8eWg0HNG/1XSucIlalr1C5bdZu3tZ1BO9f7pkq6NA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 170197515965218.820524988256466; Thu, 7 Dec 2023 10:52:39 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBJSq-0003w4-Hb; Thu, 07 Dec 2023 13:51:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSb-0003dE-FJ for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:58 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSW-00079N-LL for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:56 -0500 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7InVX4000548; Thu, 7 Dec 2023 18:50:50 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3utd0mmh5n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:50 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7HVFSx039488; Thu, 7 Dec 2023 18:50:49 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3utan7vj6c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:49 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3B7Io90i008067; Thu, 7 Dec 2023 18:50:49 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3utan7vh2k-27; Thu, 07 Dec 2023 18:50:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=6xgia7g1oUY0RjFvspZ/n8yXNYyUzWdL6U6DAU8F9r4=; b=hTnDnabomVnFFgH2CoIwMKRwtZ4aTSVcbwN8akolzv3wU2OpRwPR8gTeM+ImcmPWNJv+ 8Dx8aU86W3lr0PUPmH9BSkGkj5s6AgMm7eLUlL7ZgMBUUW+iqkL3O7UuJDAGaM01Qag2 adFZ7GUxcdFCU13xYsVW4hEybj75rX5iiZ3lDGotkxvu5qsBnPWXPWfBQOWtGV+74woT tdyNr5u1YyZIL+VJ/oS5wGyi6clp9E2uHQzO3eN4L2zkqTVKsTCUoaBBKRFN1LMlxHAh v6KxEJrFv5Npw4pUfJnNEq3NkL1vspIeE+Ja7SxtuqQ5p7b/Sy1wi9xv4899D8bGTGc9 EA== From: Si-Wei Liu To: eperezma@redhat.com, jasowang@redhat.com, mst@redhat.com, dtatulea@nvidia.com, leiyang@redhat.com, yin31149@gmail.com, boris.ostrovsky@oracle.com, jonah.palmer@oracle.com Cc: qemu-devel@nongnu.org Subject: [PATCH 26/40] vdpa: return int for dma_batch_once API Date: Thu, 7 Dec 2023 09:39:39 -0800 Message-Id: <1701970793-6865-27-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> References: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-07_15,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312070156 X-Proofpoint-GUID: QJXnP9B189LUqMPQkKgFaTfqPY7WUPVl X-Proofpoint-ORIG-GUID: QJXnP9B189LUqMPQkKgFaTfqPY7WUPVl Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.165.32; envelope-from=si-wei.liu@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1701975159957100002 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Return zero for success for now. Prepare for non-zero return in the next few patches. Signed-off-by: Si-Wei Liu --- hw/virtio/vhost-vdpa.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 2db2832..e0137f0 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -187,16 +187,18 @@ static bool vhost_vdpa_map_batch_begin(VhostVDPAShare= d *s, uint32_t asid) return true; } =20 -static void vhost_vdpa_dma_batch_begin_once(VhostVDPAShared *s) +static int vhost_vdpa_dma_batch_begin_once(VhostVDPAShared *s) { if (!(s->backend_cap & (0x1ULL << VHOST_BACKEND_F_IOTLB_BATCH)) || s->iotlb_batch_begin_sent) { - return; + return 0; } =20 if (vhost_vdpa_map_batch_begin(s, 0)) { s->iotlb_batch_begin_sent =3D true; } + + return 0; } =20 static bool vhost_vdpa_dma_batch_end(VhostVDPAShared *s, uint32_t asid) @@ -225,19 +227,21 @@ static bool vhost_vdpa_dma_batch_end(VhostVDPAShared = *s, uint32_t asid) return true; } =20 -static void vhost_vdpa_dma_batch_end_once(VhostVDPAShared *s) +static int vhost_vdpa_dma_batch_end_once(VhostVDPAShared *s) { if (!(s->backend_cap & (0x1ULL << VHOST_BACKEND_F_IOTLB_BATCH))) { - return; + return 0; } =20 if (!s->iotlb_batch_begin_sent) { - return; + return 0; } =20 if (vhost_vdpa_dma_batch_end(s, 0)) { s->iotlb_batch_begin_sent =3D false; } + + return 0; } =20 static void vhost_vdpa_listener_commit(MemoryListener *listener) --=20 1.8.3.1 From nobody Wed Nov 27 00:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1701975342; cv=none; d=zohomail.com; s=zohoarc; b=m/hczhdYnK9GTOMKiFzzwGgQXvXezxGO70HZ8kxwM+xHo6h3RUAc2Ybx/NNj/TU5YbmUyqTHRZenNe+wV9Ym2q+UPX8TCiztN2oQ7LKIIRxZ9J+zwrUev0JD0swNfu6+aDKAR4PIrXlRCHKmHvk0CqbE0MoPqCS90RZwk5Er3fw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701975342; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Jnkj8GEJTOW6vXOQA2mRArcmep3dLye1fLL8tT9XBa0=; b=Tn6ZTERPIRASgV2yG/TKVgn+EONjErUJ2RHl2XZQ2m5GxYn3o0a4Ez6eDatsC5JOddK1JZCdZlQtFaLEp+BcTanjJM/Pldf8VY7ARm34J84JENWSxzUCxKWN8HYRYwwSkjGPpPGb2wSG9A1eojIeAPpQl2o1H1JOFX/MwJQwfww= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1701975342015699.3560557562856; Thu, 7 Dec 2023 10:55:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBJSr-0003wv-Al; Thu, 07 Dec 2023 13:51:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSp-0003vj-Rs for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:51:11 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSj-0007AC-VR for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:51:11 -0500 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7EtJQM015896; Thu, 7 Dec 2023 18:50:52 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3utdmbmnt8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:52 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7IVo0G039480; Thu, 7 Dec 2023 18:50:51 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3utan7vj77-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:51 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3B7Io90k008067; Thu, 7 Dec 2023 18:50:50 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3utan7vh2k-28; Thu, 07 Dec 2023 18:50:50 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=Jnkj8GEJTOW6vXOQA2mRArcmep3dLye1fLL8tT9XBa0=; b=TMY+GN35Ciijutl/r949GpyDzd63HdaIefN+03riqV6duwNhy0RPtbqJ1vlIfTY97ohr auhF9ri3wLj38ADM+d9hsPqrOS+3wEvpmW1qggEg2xmROn1sH9tTZoVmqeoQl71tVXBx MnAQnrWsLGK3LsNCkn/TH0NV7UZiA+IE+nyRKJsD94lHyAyPuOHwS/Hq1l/yXbmnJnkR v1B/bCLUTjBaNbMOJzi0U1yb+9LpGvsETl1gKwo4+qVCOZTrB4UErZYst5DYWRf5VmCl uUa9m+WbosWQCWegY9GW/YhNUrf+BKo3yvT2K/YoqJ/Kfyyve9YPVfzK3kAmoyxzv4XT cA== From: Si-Wei Liu To: eperezma@redhat.com, jasowang@redhat.com, mst@redhat.com, dtatulea@nvidia.com, leiyang@redhat.com, yin31149@gmail.com, boris.ostrovsky@oracle.com, jonah.palmer@oracle.com Cc: qemu-devel@nongnu.org Subject: [PATCH 27/40] vdpa: add asid to all dma_batch call sites Date: Thu, 7 Dec 2023 09:39:40 -0800 Message-Id: <1701970793-6865-28-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> References: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-07_15,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312070156 X-Proofpoint-ORIG-GUID: Y8IbbPfJkJuWdiEkUypV9_KhpWVQl7xj X-Proofpoint-GUID: Y8IbbPfJkJuWdiEkUypV9_KhpWVQl7xj Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.177.32; envelope-from=si-wei.liu@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1701975344062100007 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Will allow other callers to specifcy asid when calling the dma_batch API. Signed-off-by: Si-Wei Liu --- hw/virtio/vhost-vdpa.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index e0137f0..d3f5721 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -187,14 +187,14 @@ static bool vhost_vdpa_map_batch_begin(VhostVDPAShare= d *s, uint32_t asid) return true; } =20 -static int vhost_vdpa_dma_batch_begin_once(VhostVDPAShared *s) +static int vhost_vdpa_dma_batch_begin_once(VhostVDPAShared *s, uint32_t as= id) { if (!(s->backend_cap & (0x1ULL << VHOST_BACKEND_F_IOTLB_BATCH)) || s->iotlb_batch_begin_sent) { return 0; } =20 - if (vhost_vdpa_map_batch_begin(s, 0)) { + if (vhost_vdpa_map_batch_begin(s, asid)) { s->iotlb_batch_begin_sent =3D true; } =20 @@ -227,7 +227,7 @@ static bool vhost_vdpa_dma_batch_end(VhostVDPAShared *s= , uint32_t asid) return true; } =20 -static int vhost_vdpa_dma_batch_end_once(VhostVDPAShared *s) +static int vhost_vdpa_dma_batch_end_once(VhostVDPAShared *s, uint32_t asid) { if (!(s->backend_cap & (0x1ULL << VHOST_BACKEND_F_IOTLB_BATCH))) { return 0; @@ -237,7 +237,7 @@ static int vhost_vdpa_dma_batch_end_once(VhostVDPAShare= d *s) return 0; } =20 - if (vhost_vdpa_dma_batch_end(s, 0)) { + if (vhost_vdpa_dma_batch_end(s, asid)) { s->iotlb_batch_begin_sent =3D false; } =20 @@ -248,7 +248,7 @@ static void vhost_vdpa_listener_commit(MemoryListener *= listener) { VhostVDPAShared *s =3D container_of(listener, VhostVDPAShared, listene= r); =20 - vhost_vdpa_dma_batch_end_once(s); + vhost_vdpa_dma_batch_end_once(s, VHOST_VDPA_GUEST_PA_ASID); } =20 static void vhost_vdpa_iommu_map_notify(IOMMUNotifier *n, IOMMUTLBEntry *i= otlb) @@ -423,7 +423,7 @@ static void vhost_vdpa_listener_region_add(MemoryListen= er *listener, iova =3D mem_region.iova; } =20 - vhost_vdpa_dma_batch_begin_once(s); + vhost_vdpa_dma_batch_begin_once(s, VHOST_VDPA_GUEST_PA_ASID); ret =3D vhost_vdpa_dma_map(s, VHOST_VDPA_GUEST_PA_ASID, iova, int128_get64(llsize), vaddr, section->readonl= y); if (ret) { @@ -505,7 +505,7 @@ static void vhost_vdpa_listener_region_del(MemoryListen= er *listener, iova =3D result->iova; vhost_iova_tree_remove(s->iova_tree, *result); } - vhost_vdpa_dma_batch_begin_once(s); + vhost_vdpa_dma_batch_begin_once(s, VHOST_VDPA_GUEST_PA_ASID); /* * The unmap ioctl doesn't accept a full 64-bit. need to check it */ @@ -1383,10 +1383,10 @@ static void *vhost_vdpa_load_map(void *opaque) msg->iotlb.size); break; case VHOST_IOTLB_BATCH_BEGIN: - vhost_vdpa_dma_batch_begin_once(shared); + vhost_vdpa_dma_batch_begin_once(shared, msg->asid); break; case VHOST_IOTLB_BATCH_END: - vhost_vdpa_dma_batch_end_once(shared); + vhost_vdpa_dma_batch_end_once(shared, msg->asid); break; default: error_report("Invalid IOTLB msg type %d", msg->iotlb.type); --=20 1.8.3.1 From nobody Wed Nov 27 00:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1701975383; cv=none; d=zohomail.com; s=zohoarc; b=WLieqXOlCK2ioqt64qpQlMy3aVZqrtWp4i1wx54Np6mNcd6HumRPp5vUcEkq2c3HZ2jNHTKJbhNcN/tod3aMrr3hZQWh5QhyxJWsYTxcJ2Nd8glRUVg75jPKl01wMNx8eeOw6/Y5NyYuN+nw8F8+CrWeeWAD6XEbxkTxKopWK8Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701975383; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=MS8ZsyDAdKAh6RiaLiKLs0LxEX3ZzPIG9eACCh1nyIQ=; b=Jk4S1mHyIsk+6La9K/DGbKfUP69TNRynPD7PSgj3gkxNal3JsJH/vqLbdCnDQs9TlIyjtyEw52zm5VP1ANhRRSfvownPLvhuTGbEQK5Hnmmu7Twoq8hp0w814366S/jjxMXxE5q2ECxfBS1HbH/VR0Hn+6KS+ERcwGVEto2GidU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1701975383924999.3200406095692; Thu, 7 Dec 2023 10:56:23 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBJSu-0003yj-9t; Thu, 07 Dec 2023 13:51:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSd-0003dq-IL for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:59 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSa-0007Ab-7s for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:50:59 -0500 Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7HVcZ3010797; Thu, 7 Dec 2023 18:50:54 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3utdc1cg0b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:53 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7Hcvr8039979; Thu, 7 Dec 2023 18:50:52 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3utan7vj81-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:52 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3B7Io90m008067; Thu, 7 Dec 2023 18:50:52 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3utan7vh2k-29; Thu, 07 Dec 2023 18:50:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=MS8ZsyDAdKAh6RiaLiKLs0LxEX3ZzPIG9eACCh1nyIQ=; b=KRfkzehqZY+grL0T/CA66mzcVnpwjYGhJUZk3i/JZ25wJrQmGp1CguKHLzcPuy3YUZDZ foWczM37A0fQr3Vte1CLmmsK4PjNMoxATLF5VJgivSSyhOoYpwk8MP8WFUroqS1Cf1uk 3pPkGotqqrt/IMq5vNiHaKcryshPIEtHETmwBnSMYjQOQR9yyN+Geyc9Lp8+o8yDZVnv Dr/0S4iA+F/0iqouV88wmpnn26W2Ab75xK4XVqpgb0YZMYNouAaypnd3zcn0EXlwdcfM NKzit8yOi4nF5B5AUOpt31tOSVZJuTe/M33tNuDr7fP/35nrE8K1UsOtrFXaLpRlz7Ff aA== From: Si-Wei Liu To: eperezma@redhat.com, jasowang@redhat.com, mst@redhat.com, dtatulea@nvidia.com, leiyang@redhat.com, yin31149@gmail.com, boris.ostrovsky@oracle.com, jonah.palmer@oracle.com Cc: qemu-devel@nongnu.org Subject: [PATCH 28/40] vdpa: support iotlb_batch_asid Date: Thu, 7 Dec 2023 09:39:41 -0800 Message-Id: <1701970793-6865-29-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> References: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-07_15,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312070156 X-Proofpoint-GUID: xIk5cnj65ZpX3U_GR0QXTYhXhSti7wS- X-Proofpoint-ORIG-GUID: xIk5cnj65ZpX3U_GR0QXTYhXhSti7wS- Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.165.32; envelope-from=si-wei.liu@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1701975384891100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Then it's possible to specify ASID when calling the DMA batching API. If the ASID to work on doesn't align with the ASID for ongoing transaction, the API will fail the request and return negative, and the transaction will remain intact as if no failed request ever had occured. Signed-off-by: Si-Wei Liu --- hw/virtio/vhost-vdpa.c | 25 +++++++++++++++++++------ include/hw/virtio/vhost-vdpa.h | 1 + net/vhost-vdpa.c | 1 + 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index d3f5721..b7896a8 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -189,15 +189,25 @@ static bool vhost_vdpa_map_batch_begin(VhostVDPAShare= d *s, uint32_t asid) =20 static int vhost_vdpa_dma_batch_begin_once(VhostVDPAShared *s, uint32_t as= id) { - if (!(s->backend_cap & (0x1ULL << VHOST_BACKEND_F_IOTLB_BATCH)) || - s->iotlb_batch_begin_sent) { + if (!(s->backend_cap & (0x1ULL << VHOST_BACKEND_F_IOTLB_BATCH))) { return 0; } =20 - if (vhost_vdpa_map_batch_begin(s, asid)) { - s->iotlb_batch_begin_sent =3D true; + if (s->iotlb_batch_begin_sent && s->iotlb_batch_asid !=3D asid) { + return -1; + } + + if (s->iotlb_batch_begin_sent) { + return 0; } =20 + if (!vhost_vdpa_map_batch_begin(s, asid)) { + return 0; + } + + s->iotlb_batch_begin_sent =3D true; + s->iotlb_batch_asid =3D asid; + return 0; } =20 @@ -237,10 +247,13 @@ static int vhost_vdpa_dma_batch_end_once(VhostVDPASha= red *s, uint32_t asid) return 0; } =20 - if (vhost_vdpa_dma_batch_end(s, asid)) { - s->iotlb_batch_begin_sent =3D false; + if (!vhost_vdpa_dma_batch_end(s, asid)) { + return 0; } =20 + s->iotlb_batch_begin_sent =3D false; + s->iotlb_batch_asid =3D -1; + return 0; } =20 diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h index 0fe0f60..219316f 100644 --- a/include/hw/virtio/vhost-vdpa.h +++ b/include/hw/virtio/vhost-vdpa.h @@ -61,6 +61,7 @@ typedef struct vhost_vdpa_shared { bool map_thread_enabled; =20 bool iotlb_batch_begin_sent; + uint32_t iotlb_batch_asid; =20 /* * The memory listener has been registered, so DMA maps have been sent= to diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index e9b96ed..bc72345 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -1933,6 +1933,7 @@ static NetClientState *net_vhost_vdpa_init(NetClientS= tate *peer, s->vhost_vdpa.shared->device_fd =3D vdpa_device_fd; s->vhost_vdpa.shared->iova_range =3D iova_range; s->vhost_vdpa.shared->shadow_data =3D svq; + s->vhost_vdpa.shared->iotlb_batch_asid =3D -1; s->vhost_vdpa.shared->refcnt++; } else if (!is_datapath) { s->cvq_cmd_out_buffer =3D mmap(NULL, vhost_vdpa_net_cvq_cmd_page_l= en(), --=20 1.8.3.1 From nobody Wed Nov 27 00:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1701975503; cv=none; d=zohomail.com; s=zohoarc; b=PB8rWEdZvIueUa22A9p1e5Db8omozgd0L81q/z2QzmdSTUXLwM+iyRgha5xM0juUjWWhz9j/L9ZviZFRGIp8Srt4P3Hj7vBu5zCBDoCuT0G5NiUlOZA7uXHLGQvnvQ7DvO6Fy1NbHTcp7quLwpKtkVUJiMCzuYhpceAN/1vDltI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701975503; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=i6V4YQb4G5hm1g+p/0CXNDXC0WWgyQ8rR9Uz9vRtnJI=; b=I44KKOouD3rmft3flxtj57xN+jLUFMqo5f3sjwMvBuiaLgiDWoRB6h713qh2lBdXf0uUavUzfGZIK0UCuTlgKmGF4hQGWaM+doxZ/DZE8OWiaJFlVg0RcOBgc8Ud6bzjxMoBOldXrMS+4kOOuIkhRpn0P+vCZfsZ9/l08hXinVE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17019755033031.7363980658851688; Thu, 7 Dec 2023 10:58:23 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBJSu-0003yd-2l; Thu, 07 Dec 2023 13:51:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSq-0003vx-4b for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:51:13 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSl-0007B3-71 for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:51:11 -0500 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7InVX5000548; Thu, 7 Dec 2023 18:50:55 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3utd0mmh5t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:54 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7HRJYR039470; Thu, 7 Dec 2023 18:50:54 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3utan7vj8t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:54 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3B7Io90o008067; Thu, 7 Dec 2023 18:50:53 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3utan7vh2k-30; Thu, 07 Dec 2023 18:50:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=i6V4YQb4G5hm1g+p/0CXNDXC0WWgyQ8rR9Uz9vRtnJI=; b=R1vXdULLkQlxFJb1tucQB1ZVfGngOrxUv/0BhrJ6/G3Tv69wIEpAsdXhjbSLwi5W66d2 zhpet4Lf6XFoFpkYvjysxcDzzBsekJxVsoj140CUMzlBtTauPsYsaM5ytloeGMJHKjEI DDfDdITw7l95qeaX5NI84Y89Z7Vxml8gh9XIp4HacK1oL2cH71E4wLfywPBHVjI4KT68 IpVk9QnhjOUvU/Y6loXf372spGaeNpcLBAlJodIC4Wix5eIr1FL3CYp2YVoEiK/G4jws geyctaZyTc4fXvAqoRrDz4IWSDr/MStiOgxqK3W6UebzzYZIGEL/PXPhIwR/AjATqasi YQ== From: Si-Wei Liu To: eperezma@redhat.com, jasowang@redhat.com, mst@redhat.com, dtatulea@nvidia.com, leiyang@redhat.com, yin31149@gmail.com, boris.ostrovsky@oracle.com, jonah.palmer@oracle.com Cc: qemu-devel@nongnu.org Subject: [PATCH 29/40] vdpa: expose API vhost_vdpa_dma_batch_once Date: Thu, 7 Dec 2023 09:39:42 -0800 Message-Id: <1701970793-6865-30-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> References: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-07_15,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312070156 X-Proofpoint-GUID: CJ0dY195PKGyL1AhpqpBieLNrl9Dqe0z X-Proofpoint-ORIG-GUID: CJ0dY195PKGyL1AhpqpBieLNrl9Dqe0z Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.165.32; envelope-from=si-wei.liu@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1701975503868100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" So that the batching API can be called from other file externally than the local. Signed-off-by: Si-Wei Liu --- hw/virtio/vhost-vdpa.c | 21 +++++++++++++++------ include/hw/virtio/vhost-vdpa.h | 3 +++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index b7896a8..68dc01b 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -187,7 +187,7 @@ static bool vhost_vdpa_map_batch_begin(VhostVDPAShared = *s, uint32_t asid) return true; } =20 -static int vhost_vdpa_dma_batch_begin_once(VhostVDPAShared *s, uint32_t as= id) +int vhost_vdpa_dma_batch_begin_once(VhostVDPAShared *s, uint32_t asid) { if (!(s->backend_cap & (0x1ULL << VHOST_BACKEND_F_IOTLB_BATCH))) { return 0; @@ -237,7 +237,7 @@ static bool vhost_vdpa_dma_batch_end(VhostVDPAShared *s= , uint32_t asid) return true; } =20 -static int vhost_vdpa_dma_batch_end_once(VhostVDPAShared *s, uint32_t asid) +int vhost_vdpa_dma_batch_end_once(VhostVDPAShared *s, uint32_t asid) { if (!(s->backend_cap & (0x1ULL << VHOST_BACKEND_F_IOTLB_BATCH))) { return 0; @@ -436,7 +436,12 @@ static void vhost_vdpa_listener_region_add(MemoryListe= ner *listener, iova =3D mem_region.iova; } =20 - vhost_vdpa_dma_batch_begin_once(s, VHOST_VDPA_GUEST_PA_ASID); + ret =3D vhost_vdpa_dma_batch_begin_once(s, VHOST_VDPA_GUEST_PA_ASID); + if (unlikely(ret)) { + error_report("Can't batch mapping on asid 0 (%p)", s); + goto fail_map; + } + ret =3D vhost_vdpa_dma_map(s, VHOST_VDPA_GUEST_PA_ASID, iova, int128_get64(llsize), vaddr, section->readonl= y); if (ret) { @@ -518,7 +523,11 @@ static void vhost_vdpa_listener_region_del(MemoryListe= ner *listener, iova =3D result->iova; vhost_iova_tree_remove(s->iova_tree, *result); } - vhost_vdpa_dma_batch_begin_once(s, VHOST_VDPA_GUEST_PA_ASID); + ret =3D vhost_vdpa_dma_batch_begin_once(s, VHOST_VDPA_GUEST_PA_ASID); + if (ret) { + error_report("Can't batch mapping on asid 0 (%p)", s); + } + /* * The unmap ioctl doesn't accept a full 64-bit. need to check it */ @@ -1396,10 +1405,10 @@ static void *vhost_vdpa_load_map(void *opaque) msg->iotlb.size); break; case VHOST_IOTLB_BATCH_BEGIN: - vhost_vdpa_dma_batch_begin_once(shared, msg->asid); + r =3D vhost_vdpa_dma_batch_begin_once(shared, msg->asid); break; case VHOST_IOTLB_BATCH_END: - vhost_vdpa_dma_batch_end_once(shared, msg->asid); + r =3D vhost_vdpa_dma_batch_end_once(shared, msg->asid); break; default: error_report("Invalid IOTLB msg type %d", msg->iotlb.type); diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h index 219316f..aa13679 100644 --- a/include/hw/virtio/vhost-vdpa.h +++ b/include/hw/virtio/vhost-vdpa.h @@ -106,6 +106,9 @@ int vhost_vdpa_dma_map(VhostVDPAShared *s, uint32_t asi= d, hwaddr iova, hwaddr size, void *vaddr, bool readonly); int vhost_vdpa_dma_unmap(VhostVDPAShared *s, uint32_t asid, hwaddr iova, hwaddr size); +int vhost_vdpa_dma_batch_begin_once(VhostVDPAShared *s, uint32_t asid); +int vhost_vdpa_dma_batch_end_once(VhostVDPAShared *s, uint32_t asid); + int vhost_vdpa_load_setup(VhostVDPAShared *s, AddressSpace *dma_as); int vhost_vdpa_load_cleanup(VhostVDPAShared *s, bool vhost_will_start); =20 --=20 1.8.3.1 From nobody Wed Nov 27 00:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1701975174; cv=none; d=zohomail.com; s=zohoarc; b=M1ZKCK6Vwa9Z9ELdumVzblRyzE63kY8xiPNXkjgNopqhKFh27+MjLJzhwNwkRNh/DPimMFPh5cGF12n/71HMe6htD+gF+/wDSa+SXPLargoeorvtNWflrEzHOv7odGaLg/0Lx9zr4BMBvvHdp5eiTcN9CzNdODBUlceIldgXFb4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701975174; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=5AgeQWyfy2Ho2yhA/SVB1fzSmEKhlEu+76jpsngIZG4=; b=gTvhcwRMsufE51zq4WKaFfEEezxagOs20RaHuRuTKCoBIlcvpTUN3rPVlP7AnR2ZuxZsi42gYoS7IlYsH6QRG3E+5ykLk1xXjJJS/17vilhXqtnt7gPUjTHGvEIH1F72eiLsg/jlmg1ug6eexbbNMmU+V1CM2I44//RTfwGVd+I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1701975174188126.26786001344851; Thu, 7 Dec 2023 10:52:54 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBJSu-0003ym-Ru; Thu, 07 Dec 2023 13:51:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSr-0003wk-7B for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:51:13 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSl-0007Bh-SH for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:51:12 -0500 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7GDNQ5031482; Thu, 7 Dec 2023 18:50:56 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3utdrvmpfu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:56 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7ITt8L039503; Thu, 7 Dec 2023 18:50:55 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3utan7vj9s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:55 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3B7Io90q008067; Thu, 7 Dec 2023 18:50:54 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3utan7vh2k-31; Thu, 07 Dec 2023 18:50:54 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=5AgeQWyfy2Ho2yhA/SVB1fzSmEKhlEu+76jpsngIZG4=; b=NjeL04sf86y1ZL7zO8yZOuOybt/SUtemGfiYHUFqaUYRCISz4tJ1578gK3419CODdTRT yH7zjgt9pj+Hb6wAj84+fQbSUpZMDdOeCpAIm1i1uALWJFDRO4tbmxoShitQxVRFo1SU RRocGQyABqcbEtEPnOiyFcsW393gqsmfxqjDHcw1BdIq7w8nrvJDhZIgn5qelpNXrVlg Vo6xSBd//34SvStDkQkbuR2EY7OaXnlnBf6/S3e8L61UpVYpr9kPWGPV1JK/6vbfg0kf xt6vU/hM8d1k0bFUQV6TDE7nkdgKcju1bIrM6uOZ48a/kdAmrjS+28ETcf7K0OP5ZnoQ Lg== From: Si-Wei Liu To: eperezma@redhat.com, jasowang@redhat.com, mst@redhat.com, dtatulea@nvidia.com, leiyang@redhat.com, yin31149@gmail.com, boris.ostrovsky@oracle.com, jonah.palmer@oracle.com Cc: qemu-devel@nongnu.org Subject: [PATCH 30/40] vdpa: batch map/unmap op per svq pair basis Date: Thu, 7 Dec 2023 09:39:43 -0800 Message-Id: <1701970793-6865-31-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> References: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-07_15,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312070156 X-Proofpoint-GUID: KxJwXgfLbavtyNmFEvUIyeUJEW5kqX00 X-Proofpoint-ORIG-GUID: KxJwXgfLbavtyNmFEvUIyeUJEW5kqX00 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.177.32; envelope-from=si-wei.liu@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1701975176504100003 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Coalesce multiple map or unmap operations to just one so that all mapping setup or teardown can occur in a single DMA batch. Signed-off-by: Si-Wei Liu Acked-by: Jason Wang --- hw/virtio/vhost-vdpa.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 68dc01b..d98704a 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -1288,6 +1288,7 @@ static bool vhost_vdpa_svqs_start(struct vhost_dev *d= ev) return true; } =20 + vhost_vdpa_dma_batch_begin_once(v->shared, v->address_space_id); for (i =3D 0; i < v->shadow_vqs->len; ++i) { VirtQueue *vq =3D virtio_get_queue(dev->vdev, dev->vq_index + i); VhostShadowVirtqueue *svq =3D g_ptr_array_index(v->shadow_vqs, i); @@ -1315,6 +1316,7 @@ static bool vhost_vdpa_svqs_start(struct vhost_dev *d= ev) goto err_set_addr; } } + vhost_vdpa_dma_batch_end_once(v->shared, v->address_space_id); =20 return true; =20 @@ -1323,6 +1325,7 @@ err_set_addr: =20 err_map: vhost_svq_stop(g_ptr_array_index(v->shadow_vqs, i)); + vhost_vdpa_dma_batch_end_once(v->shared, v->address_space_id); =20 err: error_reportf_err(err, "Cannot setup SVQ %u: ", i); @@ -1343,6 +1346,7 @@ static void vhost_vdpa_svqs_stop(struct vhost_dev *de= v) return; } =20 + vhost_vdpa_dma_batch_begin_once(v->shared, v->address_space_id); for (unsigned i =3D 0; i < v->shadow_vqs->len; ++i) { VhostShadowVirtqueue *svq =3D g_ptr_array_index(v->shadow_vqs, i); =20 @@ -1352,6 +1356,7 @@ static void vhost_vdpa_svqs_stop(struct vhost_dev *de= v) event_notifier_cleanup(&svq->hdev_kick); event_notifier_cleanup(&svq->hdev_call); } + vhost_vdpa_dma_batch_end_once(v->shared, v->address_space_id); } =20 static void vhost_vdpa_suspend(struct vhost_dev *dev) --=20 1.8.3.1 From nobody Wed Nov 27 00:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1701975540; cv=none; d=zohomail.com; s=zohoarc; b=Fw/OLY8aZg0JCT+D7wbPPs86U9J4WG5QOLEPS0pktInHp1U216+24e08Lu8oW1nQMfEfaQzosPKX+G/RF8qlJw3k56N54cPNvToG0/HDmdfxyv/TRDo8b5+iu+FaM1KhmuTLEUcfb0DyeFCPP9EjEB9ZwbMcr0/SOdG1WP/a4KI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701975540; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=C903EYO3s1FA0DFS86jy4RVM3891ps6An1EsefY13cI=; b=e0jN0+kI4teWXxD5VEY4I7xIekYyickLKAb5+Sa7SiMJ3z1oIPoE9xhcKFEOQE9TeJh9ZbpOUvLvaMrv/lxbQLhIJMQ7cGkgd5hguf+TF0jIhlhU6dkuepbShb/QMPw2FTyvIKKyAkNT9bweUM7Ex8okHJRkwX50DJUveWbGyBk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1701975540845471.6972488770789; Thu, 7 Dec 2023 10:59:00 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBJSx-0003zy-7R; Thu, 07 Dec 2023 13:51:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSv-0003yp-5e for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:51:17 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSo-0007Ck-1y for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:51:16 -0500 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7FbtSt000883; Thu, 7 Dec 2023 18:50:57 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3utdda4hab-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:57 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7IWvDa039587; Thu, 7 Dec 2023 18:50:56 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3utan7vjb7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:56 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3B7Io90s008067; Thu, 7 Dec 2023 18:50:56 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3utan7vh2k-32; Thu, 07 Dec 2023 18:50:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=C903EYO3s1FA0DFS86jy4RVM3891ps6An1EsefY13cI=; b=NI+ytsDEXxAVuxCg0ZBtfc6SRH+UAozTDrVTtB8DpxvHXG5XfXcdFe2DSkAKG8lkVviy d3GYoStY/M71SRfJytsMHVP2hMcLXHAchE38UzKY1P+l6GKGYsCxnKbAPKQI87Cs7T/Q yEWcEyAs/VW1Z14E7pYbcv83Sdv1DU1txJZJ0bgicEs3z5CxtuKOMpVa3Jxqmi6zc1AQ EaXcy3o9y4v0wFcshHijL3Z3iIHS0Q6tBx/cJPaZ2w0h4vxz+LEguFCd4zbcqaLnM5Ib ebK+8ouSepHFm0uRdeOumJteqy7jFHcCvT9zZFYvNeKKC/nxbFyIIzn+YnN7x0leZGss Tg== From: Si-Wei Liu To: eperezma@redhat.com, jasowang@redhat.com, mst@redhat.com, dtatulea@nvidia.com, leiyang@redhat.com, yin31149@gmail.com, boris.ostrovsky@oracle.com, jonah.palmer@oracle.com Cc: qemu-devel@nongnu.org Subject: [PATCH 31/40] vdpa: batch map and unmap around cvq svq start/stop Date: Thu, 7 Dec 2023 09:39:44 -0800 Message-Id: <1701970793-6865-32-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> References: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-07_15,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312070156 X-Proofpoint-GUID: 1tu8oQmlk6NmeiRRP-m4mFaka_Y8mJaK X-Proofpoint-ORIG-GUID: 1tu8oQmlk6NmeiRRP-m4mFaka_Y8mJaK Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.165.32; envelope-from=si-wei.liu@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1701975542559100003 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Coalesce map or unmap operations to exact one DMA batch to reduce potential impact on performance. Signed-off-by: Si-Wei Liu Acked-by: Jason Wang --- net/vhost-vdpa.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index bc72345..1c1d61f 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -715,10 +715,11 @@ out: v->shared->iova_range.l= ast); } =20 + vhost_vdpa_dma_batch_begin_once(v->shared, v->address_space_id); r =3D vhost_vdpa_cvq_map_buf(&s->vhost_vdpa, s->cvq_cmd_out_buffer, vhost_vdpa_net_cvq_cmd_page_len(), false); if (unlikely(r < 0)) { - return r; + goto err; } =20 r =3D vhost_vdpa_cvq_map_buf(&s->vhost_vdpa, s->status, @@ -727,18 +728,23 @@ out: vhost_vdpa_cvq_unmap_buf(&s->vhost_vdpa, s->cvq_cmd_out_buffer); } =20 +err: + vhost_vdpa_dma_batch_end_once(v->shared, v->address_space_id); return r; } =20 static void vhost_vdpa_net_cvq_stop(NetClientState *nc) { VhostVDPAState *s =3D DO_UPCAST(VhostVDPAState, nc, nc); + struct vhost_vdpa *v =3D &s->vhost_vdpa; =20 assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA); =20 if (s->vhost_vdpa.shadow_vqs_enabled) { + vhost_vdpa_dma_batch_begin_once(v->shared, v->address_space_id); vhost_vdpa_cvq_unmap_buf(&s->vhost_vdpa, s->cvq_cmd_out_buffer); vhost_vdpa_cvq_unmap_buf(&s->vhost_vdpa, s->status); + vhost_vdpa_dma_batch_end_once(v->shared, v->address_space_id); } =20 vhost_vdpa_net_client_stop(nc); --=20 1.8.3.1 From nobody Wed Nov 27 00:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1701975543; cv=none; d=zohomail.com; s=zohoarc; b=anxPr0SuXSsh/RmSZK7/FNqe/IZixvJ54Im/LK+sYYpH/bFEv4OpEQpt4bwy6y03o9Qe22aaSQ29Wq8DkGDQiowNeYyliI/pHrlyz5I0xxzZdlTHpUF4EBftUKf6xbX2IAiEnN03YJksBwizzGFo+7xyJv/s+8I724brrzO5ru8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701975543; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=wOBXHNRL6OZTDk0hPYLcG1XuyRPvxOOU/1I3eVVSfQc=; b=jzjt2d6u4uQf+l8DQgH1SXN+Ad685JeUiHGQBY4kBFiBdRcwMuVy/73e/E8KjvKBc7N1C98kDgfs/tEzw7IU7IDUlVHDiJ5bbARYeMVPljKvXjYb1C0UOntzO4Q0EDcI70cAgY5xsyLTgP+b+n2A16CB1uoVxV03B8d2uulUkG0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1701975543333460.65716446492286; Thu, 7 Dec 2023 10:59:03 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBJSx-000408-Og; Thu, 07 Dec 2023 13:51:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSw-0003zX-Oc for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:51:18 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSo-0007DA-P6 for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:51:18 -0500 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7EtJQN015896; Thu, 7 Dec 2023 18:50:59 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3utdmbmntd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:59 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7IVo0L039480; Thu, 7 Dec 2023 18:50:58 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3utan7vjbw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:58 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3B7Io90u008067; Thu, 7 Dec 2023 18:50:57 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3utan7vh2k-33; Thu, 07 Dec 2023 18:50:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=wOBXHNRL6OZTDk0hPYLcG1XuyRPvxOOU/1I3eVVSfQc=; b=Q8tsZkFkeKuqnhR2AVoKcXoyfTsXdN4VLji0hTjjQGhmUEwFzzQdbRJEmSrk3XQbJkUJ CnIa2KI/NsSaXAoIcErqZLl1dQlu2njcgJKuM+YlTYJiu+Hb2041nKpl9kHAWiqIW8CN bhphH7oyhZMij0Z+2buQnZBsv4VPVavjYtplY+ez1qbgzRNWXLPXxn7f1+sGqYQj3BLt Mm1CEr194IgOZhjIDoTvnSkVZmiddBZ6xujCjfnqKGW5Wlh+20pkcqhibbo4jK2On6/4 7yh/yOeUNCM9ztwAf/SPiEB6riZWBj104bP4EUD4dPYuF+05abQCIOlYOKB/6n+380XI /w== From: Si-Wei Liu To: eperezma@redhat.com, jasowang@redhat.com, mst@redhat.com, dtatulea@nvidia.com, leiyang@redhat.com, yin31149@gmail.com, boris.ostrovsky@oracle.com, jonah.palmer@oracle.com Cc: qemu-devel@nongnu.org Subject: [PATCH 32/40] vdpa: factor out vhost_vdpa_net_get_nc_vdpa Date: Thu, 7 Dec 2023 09:39:45 -0800 Message-Id: <1701970793-6865-33-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> References: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-07_15,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312070156 X-Proofpoint-ORIG-GUID: M9pmOcsCX09JoRCTcbLtQ2Ory6laTJVd X-Proofpoint-GUID: M9pmOcsCX09JoRCTcbLtQ2Ory6laTJVd Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.177.32; envelope-from=si-wei.liu@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1701975544555100007 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Introduce new API. No functional change on existing API. Signed-off-by: Si-Wei Liu Acked-by: Jason Wang --- net/vhost-vdpa.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 1c1d61f..683619f 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -290,13 +290,18 @@ static ssize_t vhost_vdpa_receive(NetClientState *nc,= const uint8_t *buf, } =20 =20 -/** From any vdpa net client, get the netclient of the first queue pair */ -static VhostVDPAState *vhost_vdpa_net_first_nc_vdpa(VhostVDPAState *s) +/** From any vdpa net client, get the netclient of the i-th queue pair */ +static VhostVDPAState *vhost_vdpa_net_get_nc_vdpa(VhostVDPAState *s, int i) { NICState *nic =3D qemu_get_nic(s->nc.peer); - NetClientState *nc0 =3D qemu_get_peer(nic->ncs, 0); + NetClientState *nc_i =3D qemu_get_peer(nic->ncs, i); + + return DO_UPCAST(VhostVDPAState, nc, nc_i); +} =20 - return DO_UPCAST(VhostVDPAState, nc, nc0); +static VhostVDPAState *vhost_vdpa_net_first_nc_vdpa(VhostVDPAState *s) +{ + return vhost_vdpa_net_get_nc_vdpa(s, 0); } =20 static void vhost_vdpa_net_log_global_enable(VhostVDPAState *s, bool enabl= e) --=20 1.8.3.1 From nobody Wed Nov 27 00:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1701975357; cv=none; d=zohomail.com; s=zohoarc; b=l+nYvaQbw86opAl4or3MYRRCA8XiNMA0nmudqG8f8jnuMI0TDbhM8r87JRDtOMPhOI6uIe6J7Z6N0kWTSHRsluzkd6OruKBs40sQXlHPei9ug6HP/67aE+PXmiMARjDp8AFFrjU0CviK3nZJfeHpXawsQPlvYGDKDNmKrzjjoCg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701975357; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=kxSpiE8Ke1O5BLHfgTteE8AERnFgFLmrr+RYhHE9PCg=; b=V+OGR1l9vfa3B32NB01YCwB6WsBKug/LtM4PFmSeWfRj06lZviuEoOyhBPU8R83/R9Ryk62CQdWxgKL5nuxUz7HLhK6TyUqpoGn+5ZcnonenChYbAIOIi3/RNujtuQMvXWzUcKPmlLvlHksa9eRJzOleMH2BIa6E0+hSEMN2QlA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1701975357903183.6781582905909; Thu, 7 Dec 2023 10:55:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBJT2-00047e-Qi; Thu, 07 Dec 2023 13:51:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJT1-000435-5e for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:51:23 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSq-0007Dc-PQ for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:51:22 -0500 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7InVX7000548; Thu, 7 Dec 2023 18:51:00 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3utd0mmh64-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:51:00 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7InFf7039579; Thu, 7 Dec 2023 18:50:59 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3utan7vjct-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:50:59 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3B7Io90w008067; Thu, 7 Dec 2023 18:50:59 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3utan7vh2k-34; Thu, 07 Dec 2023 18:50:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=kxSpiE8Ke1O5BLHfgTteE8AERnFgFLmrr+RYhHE9PCg=; b=jY9g3wdOmkIfelJ/yBFJy6tK7LjF0+RM21dYA4b5YsbYy+EimVg9CzipYKqpE5EkrieX I4fBQ6Y0vpYb9rvuvNSsRITClvZMgFBdMi3gDkucu1xSLMEkQUiLgOGO+WjLA6gc3aMC EAd3DyFqFOuJHOw9b6Y8TA7vufWz2OYxqTg4YZU7nwBzz10MbNxeelfKGiTlWpNq42Fj Pd/Bp6zH8ZAY3e8pNQVkrSumA3mEbDXbRVJCpm+pHJkmMua5WAoO49EqvWwgZtrWAFen FO4wFtisG5xMqZ7asT+h1CGn+VUHX7O38Pax7HNu7Q9CjUr/d74FQHW+BGp+dfUKwIsQ Ew== From: Si-Wei Liu To: eperezma@redhat.com, jasowang@redhat.com, mst@redhat.com, dtatulea@nvidia.com, leiyang@redhat.com, yin31149@gmail.com, boris.ostrovsky@oracle.com, jonah.palmer@oracle.com Cc: qemu-devel@nongnu.org Subject: [PATCH 33/40] vdpa: batch multiple dma_unmap to a single call for vm stop Date: Thu, 7 Dec 2023 09:39:46 -0800 Message-Id: <1701970793-6865-34-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> References: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-07_15,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312070156 X-Proofpoint-GUID: Ok6zt6Qx_oseqpQofEMTPRb2ZoIhLeDE X-Proofpoint-ORIG-GUID: Ok6zt6Qx_oseqpQofEMTPRb2ZoIhLeDE Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.165.32; envelope-from=si-wei.liu@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1701975358386100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Should help live migration downtime on source host. Below are the coalesced dma_unmap time series on 2 queue pair config (no dedicated descriptor group ASID for SVQ). 109531@1693367276.853503:vhost_vdpa_reset_device dev: 0x55c933926890 109531@1693367276.853513:vhost_vdpa_add_status dev: 0x55c933926890 status: = 0x3 109531@1693367276.853520:vhost_vdpa_flush_map dev: 0x55c933926890 doit: 1 s= vq_flush: 0 persist: 1 109531@1693367276.853524:vhost_vdpa_set_config_call dev: 0x55c933926890 fd:= -1 109531@1693367276.853579:vhost_vdpa_iotlb_begin_batch vdpa:0x7fa2aa895190 f= d: 16 msg_type: 2 type: 5 109531@1693367276.853586:vhost_vdpa_dma_unmap vdpa:0x7fa2aa895190 fd: 16 ms= g_type: 2 asid: 0 iova: 0x1000 size: 0x2000 type: 3 109531@1693367276.853600:vhost_vdpa_dma_unmap vdpa:0x7fa2aa895190 fd: 16 ms= g_type: 2 asid: 0 iova: 0x3000 size: 0x1000 type: 3 109531@1693367276.853618:vhost_vdpa_dma_unmap vdpa:0x7fa2aa895190 fd: 16 ms= g_type: 2 asid: 0 iova: 0x4000 size: 0x2000 type: 3 109531@1693367276.853625:vhost_vdpa_dma_unmap vdpa:0x7fa2aa895190 fd: 16 ms= g_type: 2 asid: 0 iova: 0x6000 size: 0x1000 type: 3 109531@1693367276.853630:vhost_vdpa_dma_unmap vdpa:0x7fa2aa84c190 fd: 16 ms= g_type: 2 asid: 0 iova: 0x7000 size: 0x2000 type: 3 109531@1693367276.853636:vhost_vdpa_dma_unmap vdpa:0x7fa2aa84c190 fd: 16 ms= g_type: 2 asid: 0 iova: 0x9000 size: 0x1000 type: 3 109531@1693367276.853642:vhost_vdpa_dma_unmap vdpa:0x7fa2aa84c190 fd: 16 ms= g_type: 2 asid: 0 iova: 0xa000 size: 0x2000 type: 3 109531@1693367276.853648:vhost_vdpa_dma_unmap vdpa:0x7fa2aa84c190 fd: 16 ms= g_type: 2 asid: 0 iova: 0xc000 size: 0x1000 type: 3 109531@1693367276.853654:vhost_vdpa_dma_unmap vdpa:0x7fa2aa6b6190 fd: 16 ms= g_type: 2 asid: 0 iova: 0xf000 size: 0x1000 type: 3 109531@1693367276.853660:vhost_vdpa_dma_unmap vdpa:0x7fa2aa6b6190 fd: 16 ms= g_type: 2 asid: 0 iova: 0x10000 size: 0x1000 type: 3 109531@1693367276.853666:vhost_vdpa_dma_unmap vdpa:0x7fa2aa6b6190 fd: 16 ms= g_type: 2 asid: 0 iova: 0xd000 size: 0x1000 type: 3 109531@1693367276.853670:vhost_vdpa_dma_unmap vdpa:0x7fa2aa6b6190 fd: 16 ms= g_type: 2 asid: 0 iova: 0xe000 size: 0x1000 type: 3 109531@1693367276.853675:vhost_vdpa_iotlb_end_batch vdpa:0x7fa2aa895190 fd:= 16 msg_type: 2 type: 6 109531@1693367277.014697:vhost_vdpa_get_vq_index dev: 0x55c933925de0 idx: 0= vq idx: 0 109531@1693367277.014747:vhost_vdpa_get_vq_index dev: 0x55c933925de0 idx: 1= vq idx: 1 109531@1693367277.014753:vhost_vdpa_get_vq_index dev: 0x55c9339262e0 idx: 2= vq idx: 2 109531@1693367277.014756:vhost_vdpa_get_vq_index dev: 0x55c9339262e0 idx: 3= vq idx: 3 Signed-off-by: Si-Wei Liu --- hw/virtio/vhost-vdpa.c | 7 +-- include/hw/virtio/vhost-vdpa.h | 3 ++ net/vhost-vdpa.c | 112 +++++++++++++++++++++++++++----------= ---- 3 files changed, 80 insertions(+), 42 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index d98704a..4010fd9 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -1162,8 +1162,8 @@ static void vhost_vdpa_svq_unmap_ring(struct vhost_vd= pa *v, hwaddr addr) vhost_iova_tree_remove(v->shared->iova_tree, *result); } =20 -static void vhost_vdpa_svq_unmap_rings(struct vhost_dev *dev, - const VhostShadowVirtqueue *svq) +void vhost_vdpa_svq_unmap_rings(struct vhost_dev *dev, + const VhostShadowVirtqueue *svq) { struct vhost_vdpa *v =3D dev->opaque; struct vhost_vring_addr svq_addr; @@ -1346,17 +1346,14 @@ static void vhost_vdpa_svqs_stop(struct vhost_dev *= dev) return; } =20 - vhost_vdpa_dma_batch_begin_once(v->shared, v->address_space_id); for (unsigned i =3D 0; i < v->shadow_vqs->len; ++i) { VhostShadowVirtqueue *svq =3D g_ptr_array_index(v->shadow_vqs, i); =20 vhost_svq_stop(svq); - vhost_vdpa_svq_unmap_rings(dev, svq); =20 event_notifier_cleanup(&svq->hdev_kick); event_notifier_cleanup(&svq->hdev_call); } - vhost_vdpa_dma_batch_end_once(v->shared, v->address_space_id); } =20 static void vhost_vdpa_suspend(struct vhost_dev *dev) diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h index aa13679..f426e2c 100644 --- a/include/hw/virtio/vhost-vdpa.h +++ b/include/hw/virtio/vhost-vdpa.h @@ -112,6 +112,9 @@ int vhost_vdpa_dma_batch_end_once(VhostVDPAShared *s, u= int32_t asid); int vhost_vdpa_load_setup(VhostVDPAShared *s, AddressSpace *dma_as); int vhost_vdpa_load_cleanup(VhostVDPAShared *s, bool vhost_will_start); =20 +void vhost_vdpa_svq_unmap_rings(struct vhost_dev *dev, + const VhostShadowVirtqueue *svq); + typedef struct vdpa_iommu { VhostVDPAShared *dev_shared; IOMMUMemoryRegion *iommu_mr; diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 683619f..41714d1 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -29,6 +29,7 @@ #include "migration/migration.h" #include "migration/misc.h" #include "hw/virtio/vhost.h" +#include "hw/virtio/vhost-vdpa.h" =20 /* Todo:need to add the multiqueue support here */ typedef struct VhostVDPAState { @@ -467,15 +468,89 @@ static int vhost_vdpa_net_data_load(NetClientState *n= c) return 0; } =20 +static void vhost_vdpa_cvq_unmap_buf(struct vhost_vdpa *v, void *addr) +{ + VhostIOVATree *tree =3D v->shared->iova_tree; + DMAMap needle =3D { + /* + * No need to specify size or to look for more translations since + * this contiguous chunk was allocated by us. + */ + .translated_addr =3D (hwaddr)(uintptr_t)addr, + }; + const DMAMap *map =3D vhost_iova_tree_find_iova(tree, &needle); + int r; + + if (unlikely(!map)) { + error_report("Cannot locate expected map"); + return; + } + + r =3D vhost_vdpa_dma_unmap(v->shared, v->address_space_id, map->iova, + map->size + 1); + if (unlikely(r !=3D 0)) { + error_report("Device cannot unmap: %s(%d)", g_strerror(r), r); + } + + vhost_iova_tree_remove(tree, *map); +} + static void vhost_vdpa_net_client_stop(NetClientState *nc) { VhostVDPAState *s =3D DO_UPCAST(VhostVDPAState, nc, nc); + struct vhost_vdpa *v =3D &s->vhost_vdpa; + struct vhost_vdpa *last_vi =3D NULL; + bool has_cvq =3D v->dev->vq_index_end % 2; + int nvqp; =20 assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA); =20 if (s->vhost_vdpa.index =3D=3D 0) { migration_remove_notifier(&s->migration_state); } + + if (v->dev->vq_index + v->dev->nvqs !=3D v->dev->vq_index_end) { + return; + } + + nvqp =3D (v->dev->vq_index_end + 1) / 2; + for (int i =3D 0; i < nvqp; ++i) { + VhostVDPAState *s_i =3D vhost_vdpa_net_get_nc_vdpa(s, i); + struct vhost_vdpa *v_i =3D &s_i->vhost_vdpa; + + if (!v_i->shadow_vqs_enabled) { + continue; + } + if (!last_vi) { + vhost_vdpa_dma_batch_begin_once(v_i->shared, + v_i->address_space_id); + last_vi =3D v_i; + } else if (last_vi->address_space_id !=3D v_i->address_space_id) { + vhost_vdpa_dma_batch_end_once(last_vi->shared, + last_vi->address_space_id); + vhost_vdpa_dma_batch_begin_once(v_i->shared, + v_i->address_space_id); + last_vi =3D v_i; + } + + for (unsigned j =3D 0; j < v_i->shadow_vqs->len; ++j) { + VhostShadowVirtqueue *svq =3D g_ptr_array_index(v_i->shadow_vq= s, j); + + vhost_vdpa_svq_unmap_rings(v_i->dev, svq); + } + } + if (has_cvq) { + if (last_vi) { + assert(last_vi->address_space_id =3D=3D v->address_space_id); + } + vhost_vdpa_cvq_unmap_buf(&s->vhost_vdpa, s->cvq_cmd_out_buffer); + vhost_vdpa_cvq_unmap_buf(&s->vhost_vdpa, s->status); + } + if (last_vi) { + vhost_vdpa_dma_batch_end_once(last_vi->shared, + last_vi->address_space_id); + last_vi =3D NULL; + } } =20 static int vhost_vdpa_net_load_setup(NetClientState *nc, NICState *nic) @@ -585,33 +660,6 @@ static int64_t vhost_vdpa_get_vring_desc_group(int dev= ice_fd, return state.num; } =20 -static void vhost_vdpa_cvq_unmap_buf(struct vhost_vdpa *v, void *addr) -{ - VhostIOVATree *tree =3D v->shared->iova_tree; - DMAMap needle =3D { - /* - * No need to specify size or to look for more translations since - * this contiguous chunk was allocated by us. - */ - .translated_addr =3D (hwaddr)(uintptr_t)addr, - }; - const DMAMap *map =3D vhost_iova_tree_find_iova(tree, &needle); - int r; - - if (unlikely(!map)) { - error_report("Cannot locate expected map"); - return; - } - - r =3D vhost_vdpa_dma_unmap(v->shared, v->address_space_id, map->iova, - map->size + 1); - if (unlikely(r !=3D 0)) { - error_report("Device cannot unmap: %s(%d)", g_strerror(r), r); - } - - vhost_iova_tree_remove(tree, *map); -} - /** Map CVQ buffer. */ static int vhost_vdpa_cvq_map_buf(struct vhost_vdpa *v, void *buf, size_t = size, bool write) @@ -740,18 +788,8 @@ err: =20 static void vhost_vdpa_net_cvq_stop(NetClientState *nc) { - VhostVDPAState *s =3D DO_UPCAST(VhostVDPAState, nc, nc); - struct vhost_vdpa *v =3D &s->vhost_vdpa; - assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA); =20 - if (s->vhost_vdpa.shadow_vqs_enabled) { - vhost_vdpa_dma_batch_begin_once(v->shared, v->address_space_id); - vhost_vdpa_cvq_unmap_buf(&s->vhost_vdpa, s->cvq_cmd_out_buffer); - vhost_vdpa_cvq_unmap_buf(&s->vhost_vdpa, s->status); - vhost_vdpa_dma_batch_end_once(v->shared, v->address_space_id); - } - vhost_vdpa_net_client_stop(nc); } =20 --=20 1.8.3.1 From nobody Wed Nov 27 00:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1701975348; cv=none; d=zohomail.com; s=zohoarc; b=bNS9ImwdzUHRiQNo7mfxKdTmF++HmUh06GAfGJPtEsTROcHO06UCNrK2w2WpuIvXCRb/Xuo1ay6P7K9xIIiI3pKToadBu61hJ6zqWud0lx5GsOsovQUHCcTpzHAGtdaDGD7UvEGUP6u9tmnRqwnS127I1hzZng3F6vTp/wiQ8io= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701975348; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=wtgVWgrJosAg3FEJdVTyDsO19N6fZxNG0z4YKtYzny0=; b=DCUTiEYWq5SNqLGsxhn7zjbOe6nuoN4M7x/R6MYpsT60Wib0N6DTTfoOMzF2d02Kp9dqMD1YvFROz7QEkeGz3WkxMlno3AAi2pY4xJmRWl3s7mfmpH7b/XV0A5cMs0BSaC9qiNj1GGarxPCO79tS84OmbJNnqg4DbPidxIxYB5k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1701975348255580.6680402009448; Thu, 7 Dec 2023 10:55:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBJT3-000486-10; Thu, 07 Dec 2023 13:51:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJT0-00041S-Vh for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:51:23 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSr-0007Du-HA for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:51:22 -0500 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7IJGFg006265; Thu, 7 Dec 2023 18:51:02 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3utdabvgef-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:51:02 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7HNN9E039498; Thu, 7 Dec 2023 18:51:01 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3utan7vjdn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:51:01 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3B7Io910008067; Thu, 7 Dec 2023 18:51:00 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3utan7vh2k-35; Thu, 07 Dec 2023 18:51:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2023-11-20; bh=wtgVWgrJosAg3FEJdVTyDsO19N6fZxNG0z4YKtYzny0=; b=g+IGzD55rD/wrCswJER52o+ck8aq66lQ4Q0shwUUt6rS8cUbXs2J0Vttqru/BM7iKy2t waMHtL3CtVfnxe75zxhJkBxehjJBSP0BC8w7DeRUwgItZGQXHFsdGIdwZnvjSHn67+UI L7nPq6aoHixssDgexjg9QjZ57AnXXp1b51ECuLJg680ig+6T9IDB6nBRcScO0x5Z/6kq tk/QpX7WANvPZdBx33tClu/rx1XEBrdAKMKAbh2SRtJpcccW7BVzrvhgU/SZ6w3ogOEa VXDA7cotZd1cujH94CtowRm3VXYfhOMickMO4vfIGZKW3xj/jmIfypqW+hVqb0v+Qogr uQ== From: Si-Wei Liu To: eperezma@redhat.com, jasowang@redhat.com, mst@redhat.com, dtatulea@nvidia.com, leiyang@redhat.com, yin31149@gmail.com, boris.ostrovsky@oracle.com, jonah.palmer@oracle.com Cc: qemu-devel@nongnu.org Subject: [PATCH 34/40] vdpa: fix network breakage after cancelling migration Date: Thu, 7 Dec 2023 09:39:47 -0800 Message-Id: <1701970793-6865-35-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> References: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-07_15,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312070156 X-Proofpoint-ORIG-GUID: A401oTK9044HLD8zykPrYHl6X1aE1Gvl X-Proofpoint-GUID: A401oTK9044HLD8zykPrYHl6X1aE1Gvl Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.177.32; envelope-from=si-wei.liu@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1701975350209100003 Fix an issue where cancellation of ongoing migration ends up with no network connectivity. When canceling migration, SVQ will be switched back to the passthrough mode, but the right call fd is not programed to the device and the svq's own call fd is still used. At the point of this transitioning period, the shadow_vqs_enabled hadn't been set back to false yet, causing the installation of call fd inadvertently bypassed. Fixes: a8ac88585da1 ("vhost: Add Shadow VirtQueue call forwarding capabilit= ies") Cc: Eugenio P=C3=A9rez Signed-off-by: Si-Wei Liu Acked-by: Jason Wang --- hw/virtio/vhost-vdpa.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 4010fd9..8ba390d 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -1647,7 +1647,12 @@ static int vhost_vdpa_set_vring_call(struct vhost_de= v *dev, =20 /* Remember last call fd because we can switch to SVQ anytime. */ vhost_svq_set_svq_call_fd(svq, file->fd); - if (v->shadow_vqs_enabled) { + /* + * In the event of SVQ switching to off, shadow_vqs_enabled has + * not been set to false yet, but the underlying call fd will + * switch back to the guest notifier for passthrough VQs. + */ + if (v->shadow_vqs_enabled && v->shared->svq_switching >=3D 0) { return 0; } =20 --=20 1.8.3.1 From nobody Wed Nov 27 00:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1701975437; cv=none; d=zohomail.com; s=zohoarc; b=VTPWRDpngcBtgMxAlFLMcx52wa3ZlihDB0asdXgSrQpTP+GH9WRO4U+NyWuwa8+DeiluOz+isbRUG/18VW/Gwq9VHy5Z8YIt/51Ie/vKsubcr9kM1LXW14TX8Xl2DpMeSPiPo8H8GxOtDTcMVxeh+T8OLUGsnOJz90o1+eVIjv0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701975437; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BU8+O9Al6PiQ7o7HvWw6WPaWNTW+Fg1nkZ5IYUEQFOo=; b=YH/f50Gttxh6W6xevDf1ECOL0DV/BKwMutVeRnTCsROR3tSEQg3XX8qraQ3hqOqxh0bmLfXaaRk5iMlgTkpFgVsEkEh9cvO3LVdyIkpV68pmjhEpV2GwvF4tt6spp8k9J+9dyreZhHo9Fu+m7AKL7/Gw3TKJO0JmbcGXDn/PI38= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1701975437196208.21249877540595; Thu, 7 Dec 2023 10:57:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBJT5-00049C-3D; Thu, 07 Dec 2023 13:51:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJT2-00047b-NL for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:51:24 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSt-0007E1-Io for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:51:24 -0500 Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7F2dui022096; Thu, 7 Dec 2023 18:51:03 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3utd1gcsjj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:51:03 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7InXqE039476; Thu, 7 Dec 2023 18:51:02 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3utan7vjed-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:51:02 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3B7Io912008067; Thu, 7 Dec 2023 18:51:02 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3utan7vh2k-36; Thu, 07 Dec 2023 18:51:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=BU8+O9Al6PiQ7o7HvWw6WPaWNTW+Fg1nkZ5IYUEQFOo=; b=CvlGWxjIDOIjN2ywMyRPU7+vQ8N1ExZVEWz1IM9IKMx3yNBPpxKVNQFSPpy4o19NMDH8 pDz32v2tOEQkJw86TmzMGym6tiKLQE+fkbgJvI/BPrqAQ53W89as5DVooglwBavdpwQH wZfUO5qMl7ZMRG4X8LcQpsU+C7q1eXxyG9vLO4C35e423o9HLzHJcTH4K8FZyPpp6JVZ xTBjQ1cPSkE5TY8mt7+Gjb1uEBT1DCQQ1MLwZV4UI+TPJvpDmNmkY/Yi57YClq9D5R7w 7PRwnH0SizCRZbyWA2QYxPlTHv0s2qQzt2A90sVjc87bfTtETbQeSHB/tfk0iTXnU49z 6g== From: Si-Wei Liu To: eperezma@redhat.com, jasowang@redhat.com, mst@redhat.com, dtatulea@nvidia.com, leiyang@redhat.com, yin31149@gmail.com, boris.ostrovsky@oracle.com, jonah.palmer@oracle.com Cc: qemu-devel@nongnu.org Subject: [PATCH 35/40] vdpa: add vhost_vdpa_set_address_space_id trace Date: Thu, 7 Dec 2023 09:39:48 -0800 Message-Id: <1701970793-6865-36-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> References: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-07_15,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312070156 X-Proofpoint-ORIG-GUID: 3hQOZX71Ea9Xuw3Xdpmb4Z3JMnSrwyOC X-Proofpoint-GUID: 3hQOZX71Ea9Xuw3Xdpmb4Z3JMnSrwyOC Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.177.32; envelope-from=si-wei.liu@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1701975438287100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" For better debuggability and observability. Signed-off-by: Si-Wei Liu Reviewed-by: Eugenio P=C3=A9rez --- net/trace-events | 3 +++ net/vhost-vdpa.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/net/trace-events b/net/trace-events index 823a071..aab666a 100644 --- a/net/trace-events +++ b/net/trace-events @@ -23,3 +23,6 @@ colo_compare_tcp_info(const char *pkt, uint32_t seq, uint= 32_t ack, int hdlen, in # filter-rewriter.c colo_filter_rewriter_pkt_info(const char *func, const char *src, const cha= r *dst, uint32_t seq, uint32_t ack, uint32_t flag) "%s: src/dst: %s/%s p: s= eq/ack=3D%u/%u flags=3D0x%x" colo_filter_rewriter_conn_offset(uint32_t offset) ": offset=3D%u" + +# vhost-vdpa.c +vhost_vdpa_set_address_space_id(void *v, unsigned vq_group, unsigned asid_= num) "vhost_vdpa: %p vq_group: %u asid: %u" diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 41714d1..84876b0 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -30,6 +30,7 @@ #include "migration/misc.h" #include "hw/virtio/vhost.h" #include "hw/virtio/vhost-vdpa.h" +#include "trace.h" =20 /* Todo:need to add the multiqueue support here */ typedef struct VhostVDPAState { @@ -365,6 +366,8 @@ static int vhost_vdpa_set_address_space_id(struct vhost= _vdpa *v, }; int r; =20 + trace_vhost_vdpa_set_address_space_id(v, vq_group, asid_num); + r =3D ioctl(v->shared->device_fd, VHOST_VDPA_SET_GROUP_ASID, &asid); if (unlikely(r < 0)) { error_report("Can't set vq group %u asid %u, errno=3D%d (%s)", --=20 1.8.3.1 From nobody Wed Nov 27 00:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1701975425; cv=none; d=zohomail.com; s=zohoarc; b=K5FLHpv2f7wyn3oBRQRaQKmdxSwhRoJNQb7L3T9KC1O8uf/mJeNbX5YCsqu0Z7sAg0bn86KtdJlEt0hibAWOBcPkMlvtPHYvs/2Wwwtg2OyaiYlnQb3vXIlvTmukxD65TDCAaTKKs2RHeSTW6HdY49WPkhf/KaDVwEykLAvFwZ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701975425; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=e90zuyHoRqXwhinSX/efqz46AUUPSKC2NBVB0QTvYoA=; b=bnXy8j5wxWg850PkR3tH88XNhTtXBKN0Xb6Y4i5wctaGonAtsxJ0HB2eyJeFdCgiePrdstdEQYbFsGy1nBwfp+Clsbbg4oyIVHsDa/kV45m4ePAuGQ9YttfEkITMXpWICg6E+uq7Qn/B3KzoeEnbnmtN3FwhHmG7w+dvzSeaeos= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1701975425466326.4836053958966; Thu, 7 Dec 2023 10:57:05 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBJT5-00049R-Nf; Thu, 07 Dec 2023 13:51:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJT4-00048V-0T for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:51:26 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSu-0007EB-TI for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:51:25 -0500 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7InWTu000605; Thu, 7 Dec 2023 18:51:04 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3utd0mmh6c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:51:04 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7IltLF039527; Thu, 7 Dec 2023 18:51:04 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3utan7vjfa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:51:03 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3B7Io914008067; Thu, 7 Dec 2023 18:51:03 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3utan7vh2k-37; Thu, 07 Dec 2023 18:51:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=e90zuyHoRqXwhinSX/efqz46AUUPSKC2NBVB0QTvYoA=; b=AhW43zry5NmVUkGNWMl/MqEA69Pn43xSg4wn7+lkXXk5gyIcroi5qURn9lg5cQzjx/T6 NtXug3kvpbDbw7lxAmZn/Yw7OXvF3K8vZ/psmHY4rAYZTHYUjznYW1+xPGWaAcyAHFAW zOdsHZx7Fhq1N4yR3TCysJSt/2h3jNkCg5hvF4OS7Oj9HevxL4bHAukm8EdUYM8atKty Ag2kydiH1JaHSIWv9y7zo8KfnE002UT71QGjTF6XCizc0uvWHJ+yWo4WtZtDdaXes/IT sr5k2aIcH8v6cqu4OzoxRssSum8U3MuKMbJh1LkLuG9U+v+ODeCV0WAV9R2FIfQ1F9V8 AQ== From: Si-Wei Liu To: eperezma@redhat.com, jasowang@redhat.com, mst@redhat.com, dtatulea@nvidia.com, leiyang@redhat.com, yin31149@gmail.com, boris.ostrovsky@oracle.com, jonah.palmer@oracle.com Cc: qemu-devel@nongnu.org Subject: [PATCH 36/40] vdpa: add vhost_vdpa_get_vring_base trace for svq mode Date: Thu, 7 Dec 2023 09:39:49 -0800 Message-Id: <1701970793-6865-37-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> References: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-07_15,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312070156 X-Proofpoint-GUID: 1P7TgylDL8yqSNW9X_W77HbMchrd9so1 X-Proofpoint-ORIG-GUID: 1P7TgylDL8yqSNW9X_W77HbMchrd9so1 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.165.32; envelope-from=si-wei.liu@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1701975426009100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" For better debuggability and observability. Signed-off-by: Si-Wei Liu Acked-by: Jason Wang Reviewed-by: Eugenio P=C3=A9rez --- hw/virtio/trace-events | 2 +- hw/virtio/vhost-vdpa.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index 196f32f..a8d3321 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -58,7 +58,7 @@ vhost_vdpa_set_log_base(void *dev, uint64_t base, unsigne= d long long size, int r vhost_vdpa_set_vring_addr(void *dev, unsigned int index, unsigned int flag= s, uint64_t desc_user_addr, uint64_t used_user_addr, uint64_t avail_user_ad= dr, uint64_t log_guest_addr) "dev: %p index: %u flags: 0x%x desc_user_addr:= 0x%"PRIx64" used_user_addr: 0x%"PRIx64" avail_user_addr: 0x%"PRIx64" log_g= uest_addr: 0x%"PRIx64 vhost_vdpa_set_vring_num(void *dev, unsigned int index, unsigned int num) = "dev: %p index: %u num: %u" vhost_vdpa_set_vring_base(void *dev, unsigned int index, unsigned int num)= "dev: %p index: %u num: %u" -vhost_vdpa_get_vring_base(void *dev, unsigned int index, unsigned int num)= "dev: %p index: %u num: %u" +vhost_vdpa_get_vring_base(void *dev, unsigned int index, unsigned int num,= bool svq) "dev: %p index: %u num: %u svq: %d" vhost_vdpa_set_vring_kick(void *dev, unsigned int index, int fd) "dev: %p = index: %u fd: %d" vhost_vdpa_set_vring_call(void *dev, unsigned int index, int fd) "dev: %p = index: %u fd: %d" vhost_vdpa_get_features(void *dev, uint64_t features) "dev: %p features: 0= x%"PRIx64 diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 8ba390d..d66936f 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -1607,6 +1607,7 @@ static int vhost_vdpa_get_vring_base(struct vhost_dev= *dev, =20 if (v->shadow_vqs_enabled) { ring->num =3D virtio_queue_get_last_avail_idx(dev->vdev, ring->ind= ex); + trace_vhost_vdpa_get_vring_base(dev, ring->index, ring->num, true); return 0; } =20 @@ -1619,7 +1620,7 @@ static int vhost_vdpa_get_vring_base(struct vhost_dev= *dev, } =20 ret =3D vhost_vdpa_call(dev, VHOST_GET_VRING_BASE, ring); - trace_vhost_vdpa_get_vring_base(dev, ring->index, ring->num); + trace_vhost_vdpa_get_vring_base(dev, ring->index, ring->num, false); return ret; } =20 --=20 1.8.3.1 From nobody Wed Nov 27 00:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1701975100; cv=none; d=zohomail.com; s=zohoarc; b=ajlNEmAhATBzkGEdm3Zr8VGELC/FW7c0O6BysQoP95Qb3zgtaneye9UQHHtQ5AwtO4V2nYCSSaYNUwczCbFB9hGKZHCWXz2GliTSKwPaj1DAcJJfej3bZZfx2wbRwTn0DpP4p7X8FNa/Mfkwd1upCsdWSu+dRiSx/nQxDxxZlZk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701975100; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=TxIsJRdr2QrceXoIu2cqfn++hSDV86DDXcv+xhCGH68=; b=eq7KjP0fhYFWBaJqAnKw+12cVHnSqFHGXnLinnYUBbb58+tGuIAwUxnikypQeStJgSXLoJFMjwRiVppFozeTZH48B6DvscfL6feBoHDB+35BNH+t/kLkXaXSgI9FmV9plzBSmK84w7mfMNmE+9r0cX2Bbu8/LeJygTXWw5vSYb4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1701975100712869.2908895332855; Thu, 7 Dec 2023 10:51:40 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBJT9-0004A1-Ol; Thu, 07 Dec 2023 13:51:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJT5-00049I-G8 for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:51:27 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSw-0007EN-9r for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:51:27 -0500 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7FDI5d009711; Thu, 7 Dec 2023 18:51:07 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3utdrvmpg9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:51:06 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7HPF63039562; Thu, 7 Dec 2023 18:51:05 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3utan7vjfu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:51:05 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3B7Io916008067; Thu, 7 Dec 2023 18:51:04 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3utan7vh2k-38; Thu, 07 Dec 2023 18:51:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=TxIsJRdr2QrceXoIu2cqfn++hSDV86DDXcv+xhCGH68=; b=TAh3wzB0W8Esfs+q5MF00k9wSD20joGtk6aGGJV7gXHBdOtvYYQkE7vqBFifWpdyRDNl t9l455BptTGl/fh03RLIyLOYB51ozOAXQZf/4VgqQ7Uv6D8SbHjL5jQ8ZOdcPGR1NSBJ +u9NwTQ+M0bM0y5Bwe9E/6q+eZEXYldlbYu2K/yDe1clCRGtZsPUJuu19oIO+6lyZyGy vNnLzuScYEwqq+EqhAd8YhW9AYxNwmbCb70e4/RSDZg7Co3MELcLYCfhmUnOxoGZ/UjH fOgNOUDQoGNMGNW2cqHMvxI05wEukw7sZNWVJhmeOpL2gxwqDXx/Mfxu2kAfN5Wy6tzN dg== From: Si-Wei Liu To: eperezma@redhat.com, jasowang@redhat.com, mst@redhat.com, dtatulea@nvidia.com, leiyang@redhat.com, yin31149@gmail.com, boris.ostrovsky@oracle.com, jonah.palmer@oracle.com Cc: qemu-devel@nongnu.org Subject: [PATCH 37/40] vdpa: add vhost_vdpa_set_dev_vring_base trace for svq mode Date: Thu, 7 Dec 2023 09:39:50 -0800 Message-Id: <1701970793-6865-38-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> References: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-07_15,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312070156 X-Proofpoint-GUID: MBJN8BQ7O_2ZYw-8XBJxT6MgKCpRantJ X-Proofpoint-ORIG-GUID: MBJN8BQ7O_2ZYw-8XBJxT6MgKCpRantJ Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.177.32; envelope-from=si-wei.liu@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1701975102846100003 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" For better debuggability and observability. Signed-off-by: Si-Wei Liu Acked-by: Jason Wang Reviewed-by: Eugenio P=C3=A9rez --- hw/virtio/trace-events | 2 +- hw/virtio/vhost-vdpa.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index a8d3321..5085607 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -57,7 +57,7 @@ vhost_vdpa_dev_start(void *dev, bool started) "dev: %p st= arted: %d" vhost_vdpa_set_log_base(void *dev, uint64_t base, unsigned long long size,= int refcnt, int fd, void *log) "dev: %p base: 0x%"PRIx64" size: %llu refcn= t: %d fd: %d log: %p" vhost_vdpa_set_vring_addr(void *dev, unsigned int index, unsigned int flag= s, uint64_t desc_user_addr, uint64_t used_user_addr, uint64_t avail_user_ad= dr, uint64_t log_guest_addr) "dev: %p index: %u flags: 0x%x desc_user_addr:= 0x%"PRIx64" used_user_addr: 0x%"PRIx64" avail_user_addr: 0x%"PRIx64" log_g= uest_addr: 0x%"PRIx64 vhost_vdpa_set_vring_num(void *dev, unsigned int index, unsigned int num) = "dev: %p index: %u num: %u" -vhost_vdpa_set_vring_base(void *dev, unsigned int index, unsigned int num)= "dev: %p index: %u num: %u" +vhost_vdpa_set_dev_vring_base(void *dev, unsigned int index, unsigned int = num, bool svq) "dev: %p index: %u num: %u svq: %d" vhost_vdpa_get_vring_base(void *dev, unsigned int index, unsigned int num,= bool svq) "dev: %p index: %u num: %u svq: %d" vhost_vdpa_set_vring_kick(void *dev, unsigned int index, int fd) "dev: %p = index: %u fd: %d" vhost_vdpa_set_vring_call(void *dev, unsigned int index, int fd) "dev: %p = index: %u fd: %d" diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index d66936f..ff4f218 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -1043,7 +1043,10 @@ static int vhost_vdpa_get_config(struct vhost_dev *d= ev, uint8_t *config, static int vhost_vdpa_set_dev_vring_base(struct vhost_dev *dev, struct vhost_vring_state *ring) { - trace_vhost_vdpa_set_vring_base(dev, ring->index, ring->num); + struct vhost_vdpa *v =3D dev->opaque; + + trace_vhost_vdpa_set_dev_vring_base(dev, ring->index, ring->num, + v->shadow_vqs_enabled); return vhost_vdpa_call(dev, VHOST_SET_VRING_BASE, ring); } =20 --=20 1.8.3.1 From nobody Wed Nov 27 00:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1701975480; cv=none; d=zohomail.com; s=zohoarc; b=kQfPJSWdi3OjDlrAPXZQLaZg9cBVWbDmx8XpIAVtYK2QYz0WkCnOWcwsMMmH9GxXn9ogN0Zt8NulPanxitP87zXXIqr/yAxN391o6tQzV8ipVnOT+5PJdWbE4inKkMM/Z4w6vy/ToI6SVb9cwQdQD/X4dBi7ABL+kaIYUbNoesI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701975480; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=guD/rAL4AbaDzj4AqYJSf7e69luBS3Cz3m5iSUNPG84=; b=VUpjdkUYjLoKHu+Q/hzn1wDE00UFCCC2sOH69SJ7qyo7PMNy42Xn3c/yY7UxpEvfL8yAn6GOiRc1yvXKdvM/ANhm4YcX9YPIKV4r7FUei3pr91W1vyi4+F7Vdf1ClKDGIYIhYP9rDPSewncvW/JeDUMcCe4JEP2CIJYYvlSOV74= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1701975480834411.0253336900247; Thu, 7 Dec 2023 10:58:00 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBJTD-0004R9-KN; Thu, 07 Dec 2023 13:51:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJT5-00049K-HA for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:51:27 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSy-0007EX-D1 for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:51:27 -0500 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7EtJQQ015896; Thu, 7 Dec 2023 18:51:08 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3utdmbmntt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:51:08 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7InXqH039476; Thu, 7 Dec 2023 18:51:07 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3utan7vjgs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:51:07 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3B7Io918008067; Thu, 7 Dec 2023 18:51:06 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3utan7vh2k-39; Thu, 07 Dec 2023 18:51:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=guD/rAL4AbaDzj4AqYJSf7e69luBS3Cz3m5iSUNPG84=; b=fSvndbRqFCmowwBNZziieAJr0s/cAI7xJRbhcr8y05J8Y1EjZQQoveG6j2QEnPCt/tXb f2XZ+dOCjrLTlhJzUrDpHpddEk6q/9p1ltLafYmQEdn5muLkZEKECp2EKHT6bFsgiOT0 iSNQ3zpt4WDJ7z8X6pBSGxAl8ULE8Uo4vq5hHeKYDuEwGRb4DwJE+r0h7vEZ1AclSqMc yMOAzCkGhrNY7qrJxeGnke+XJTVJyk9VMmMOUMsJ7xPQvw2anOEmYgtVkl1Gaw8dtuTO K4sYWo9KojT6cgFFSr8Pu7AzSAaL4GjHtB4i0tO/lr5suzk+L0jDjJ5Yh0R3ulNGTHoR Ng== From: Si-Wei Liu To: eperezma@redhat.com, jasowang@redhat.com, mst@redhat.com, dtatulea@nvidia.com, leiyang@redhat.com, yin31149@gmail.com, boris.ostrovsky@oracle.com, jonah.palmer@oracle.com Cc: qemu-devel@nongnu.org Subject: [PATCH 38/40] vdpa: add trace events for eval_flush Date: Thu, 7 Dec 2023 09:39:51 -0800 Message-Id: <1701970793-6865-39-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> References: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-07_15,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312070156 X-Proofpoint-ORIG-GUID: aLQAQNz4LNudA147DlFBEZSSvsO5-Ay2 X-Proofpoint-GUID: aLQAQNz4LNudA147DlFBEZSSvsO5-Ay2 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.177.32; envelope-from=si-wei.liu@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1701975481378100003 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" For better debuggability and observability. Signed-off-by: Si-Wei Liu --- net/trace-events | 2 ++ net/vhost-vdpa.c | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/net/trace-events b/net/trace-events index aab666a..d650c71 100644 --- a/net/trace-events +++ b/net/trace-events @@ -26,3 +26,5 @@ colo_filter_rewriter_conn_offset(uint32_t offset) ": offs= et=3D%u" =20 # vhost-vdpa.c vhost_vdpa_set_address_space_id(void *v, unsigned vq_group, unsigned asid_= num) "vhost_vdpa: %p vq_group: %u asid: %u" +vhost_vdpa_net_data_eval_flush(void *s, int qindex, int svq_switch, bool s= vq_flush) "vhost_vdpa: %p qp: %d svq_switch: %d flush_map: %d" +vhost_vdpa_net_cvq_eval_flush(void *s, int qindex, int svq_switch, bool sv= q_flush) "vhost_vdpa: %p qp: %d svq_switch: %d flush_map: %d" diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 84876b0..a0bd8cd 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -608,6 +608,9 @@ static void vhost_vdpa_net_data_eval_flush(NetClientSta= te *nc, bool stop) v->desc_group < 0) { v->shared->flush_map =3D true; } + trace_vhost_vdpa_net_data_eval_flush(v, s->vhost_vdpa.index, + v->shared->svq_switching, + v->shared->flush_map); } =20 static NetClientInfo net_vhost_vdpa_info =3D { @@ -1457,6 +1460,10 @@ static void vhost_vdpa_net_cvq_eval_flush(NetClientS= tate *nc, bool stop) !s->cvq_isolated && v->desc_group < 0) { v->shared->flush_map =3D true; } + + trace_vhost_vdpa_net_cvq_eval_flush(v, s->vhost_vdpa.index, + v->shared->svq_switching, + v->shared->flush_map); } =20 static NetClientInfo net_vhost_vdpa_cvq_info =3D { --=20 1.8.3.1 From nobody Wed Nov 27 00:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1701975504; cv=none; d=zohomail.com; s=zohoarc; b=KQFIeT1O7XCRwJt/i7p5MnnkNEYTsy+jVrUOIBpiaShKviznOUSALLEgEPr+6F8E7vYPIpJRyiZu3fCouHJM0hdiJWagbDln+78I+ViK0mtncyyLrs9SbU5nnEsSPu+T8LfR8Ka5fr7cgHtgDbq1z234VXjtizc1Y08K4Mpkzh8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701975504; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=WPm5hA3Uu3KbbEN+UqK0pesOU6z6VRZ/RI9BjPTbiq4=; b=kR2opr4nhNfJzTqA6jyRzBz9qxZXFtOO3Gd3dgjLUOB6jWi3FlRk8V2YYFFG9Pn2JcqXOR4QoBDfwlYZ8kDHWdle4jf6mt8WeTbJs22JAoY+gwPm/kjkvRSumqv+zEtHe/ezohsvpqCN43WyFRIeKqTqTf5bWy0Jdj4HwBT+W1w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1701975504506303.0764117916581; Thu, 7 Dec 2023 10:58:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBJTK-0004lC-HB; Thu, 07 Dec 2023 13:51:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJT7-0004NR-9C for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:51:31 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJSz-0007Et-5a for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:51:28 -0500 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7EtISd017262; Thu, 7 Dec 2023 18:51:10 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3utdrvmpgc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:51:09 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7Hb9IL039550; Thu, 7 Dec 2023 18:51:08 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3utan7vjht-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:51:08 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3B7Io91A008067; Thu, 7 Dec 2023 18:51:08 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3utan7vh2k-40; Thu, 07 Dec 2023 18:51:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=WPm5hA3Uu3KbbEN+UqK0pesOU6z6VRZ/RI9BjPTbiq4=; b=ZvacEikrNP3nqMuDWQTOwPIW6uSC69dshZ2cDM48Fyb232n5t3y35ZuvaSd0vmuwFjZQ RSrvuBwTjBHaTPlBVt31HKBQle4smP6JDCNW30eYypW3USljaW5TrTQSX/Nx9Dj5Dn/8 X+pj//L+/onGBf+3jwToLLRsDQroiqhmAqCsNLoMq3J0y/tg9tcjKng88RfqfIUExKqx 1qRntUZwhLgxugIaA6cZIbSwi5pdobWKTE6Wu/5OjsaiIzqsxI0KI6YazrBMLFYMiD5z mSX5lUFBmjoFbeEYPYGuNDsBO5Sf/gSo8AkmvvHEC8fJKPYTCQVZqDJD70vslVj8rKxz XA== From: Si-Wei Liu To: eperezma@redhat.com, jasowang@redhat.com, mst@redhat.com, dtatulea@nvidia.com, leiyang@redhat.com, yin31149@gmail.com, boris.ostrovsky@oracle.com, jonah.palmer@oracle.com Cc: qemu-devel@nongnu.org Subject: [PATCH 39/40] vdpa: add trace events for vhost_vdpa_net_load_cmd Date: Thu, 7 Dec 2023 09:39:52 -0800 Message-Id: <1701970793-6865-40-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> References: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-07_15,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312070156 X-Proofpoint-GUID: SfR0iKqbb0YA5_4aNqhfmt3kn_yoD1WP X-Proofpoint-ORIG-GUID: SfR0iKqbb0YA5_4aNqhfmt3kn_yoD1WP Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.177.32; envelope-from=si-wei.liu@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1701975505929100011 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" For better debuggability and observability. Signed-off-by: Si-Wei Liu Reviewed-by: Eugenio P=C3=A9rez --- net/trace-events | 2 ++ net/vhost-vdpa.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/net/trace-events b/net/trace-events index d650c71..be087e6 100644 --- a/net/trace-events +++ b/net/trace-events @@ -28,3 +28,5 @@ colo_filter_rewriter_conn_offset(uint32_t offset) ": offs= et=3D%u" vhost_vdpa_set_address_space_id(void *v, unsigned vq_group, unsigned asid_= num) "vhost_vdpa: %p vq_group: %u asid: %u" vhost_vdpa_net_data_eval_flush(void *s, int qindex, int svq_switch, bool s= vq_flush) "vhost_vdpa: %p qp: %d svq_switch: %d flush_map: %d" vhost_vdpa_net_cvq_eval_flush(void *s, int qindex, int svq_switch, bool sv= q_flush) "vhost_vdpa: %p qp: %d svq_switch: %d flush_map: %d" +vhost_vdpa_net_load_cmd(void *s, uint8_t class, uint8_t cmd, int data_num,= int data_size) "vdpa state: %p class: %u cmd: %u sg_num: %d size: %d" +vhost_vdpa_net_load_cmd_retval(void *s, uint8_t class, uint8_t cmd, int r)= "vdpa state: %p class: %u cmd: %u retval: %d" diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index a0bd8cd..61da8b4 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -885,6 +885,7 @@ static ssize_t vhost_vdpa_net_load_cmd(VhostVDPAState *= s, =20 assert(data_size < vhost_vdpa_net_cvq_cmd_page_len() - sizeof(ctrl)); cmd_size =3D sizeof(ctrl) + data_size; + trace_vhost_vdpa_net_load_cmd(s, class, cmd, data_num, data_size); if (vhost_svq_available_slots(svq) < 2 || iov_size(out_cursor, 1) < cmd_size) { /* @@ -916,6 +917,7 @@ static ssize_t vhost_vdpa_net_load_cmd(VhostVDPAState *= s, =20 r =3D vhost_vdpa_net_cvq_add(s, &out, 1, &in, 1); if (unlikely(r < 0)) { + trace_vhost_vdpa_net_load_cmd_retval(s, class, cmd, r); return r; } =20 --=20 1.8.3.1 From nobody Wed Nov 27 00:45:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1701975486; cv=none; d=zohomail.com; s=zohoarc; b=FSSBtzjozeijaKAdy49xj4++j2adnTuWkLEdAYKPiQn6y2LU6T7MdjXvHMwd7jR4iVAlY8MbjK2gRXnhPZId1KcKBtuY3/5wgTIfKLlzVTyxih3R9MESMGGM7bYcxCPUuxNSofW6Eq+n0Z3Zjg7AvZpeEmm1EnARkTLZyfhbl9o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701975486; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=p1QP117Xi8eswdzOZl72BbSbFGZ9b4zYrMMFkqmCa5k=; b=mLON1hfhawOqEhw6IXBlflBhp/6yBWg6XXp5k5Fhs/p5m7+5Pa4Ri8I4WsmGuzZFFz3sFfvXwnuXfBEDAwtTbaptDC+BW0IUKKlm5OHKToahi0ZxR1/RRc9b26LEUJXENLBS6+X6rIyDzELok/gsFm0QsNxFaxqWoZ/qZDeUOpA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1701975486040963.4736575103907; Thu, 7 Dec 2023 10:58:06 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBJTK-0004jf-ET; Thu, 07 Dec 2023 13:51:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJT7-0004NS-EB for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:51:31 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rBJT1-0007FC-MX for qemu-devel@nongnu.org; Thu, 07 Dec 2023 13:51:28 -0500 Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7IhZjh029893; Thu, 7 Dec 2023 18:51:11 GMT Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3utd1gcsjq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:51:11 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3B7HOJfs039780; Thu, 7 Dec 2023 18:51:10 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3utan7vjjs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Dec 2023 18:51:10 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3B7Io91C008067; Thu, 7 Dec 2023 18:51:09 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3utan7vh2k-41; Thu, 07 Dec 2023 18:51:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=p1QP117Xi8eswdzOZl72BbSbFGZ9b4zYrMMFkqmCa5k=; b=mQotVYr50Gy6ZZBRQ4IQ6271jXK0ZGeU9ZEewufwU1StFlfq7c2U/lsJtgnbV7NiORrL ur8H62z2ZcDUdfXHIrWZPKwLeYD1Nlnm+To0k4Ch40UhE5jgu7bwZRJo9SK23MypDKJM TCcnp+SonTtvu2Dg5gka6fx+JMD6//tqgfM+XvyMEbo3VwvG9xtTfsf5T2dMIZM/5+Sk 9SOTHo6EbWi5Nha5YPNQS2nX4KM8kEyAqtJjD1MdUcEKwRCJjAa7sQxaAfYDLIIZrvLJ PaOeiMJJuk0XFfML23Pd4I/QVe68sxjnTjsbnpfiGlDee/HSOCYFE/s7HEpqmgRUVxbZ PQ== From: Si-Wei Liu To: eperezma@redhat.com, jasowang@redhat.com, mst@redhat.com, dtatulea@nvidia.com, leiyang@redhat.com, yin31149@gmail.com, boris.ostrovsky@oracle.com, jonah.palmer@oracle.com Cc: qemu-devel@nongnu.org Subject: [PATCH 40/40] vdpa: add trace event for vhost_vdpa_net_load_mq Date: Thu, 7 Dec 2023 09:39:53 -0800 Message-Id: <1701970793-6865-41-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> References: <1701970793-6865-1-git-send-email-si-wei.liu@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-07_15,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312070156 X-Proofpoint-ORIG-GUID: 1RoSeJSsy6m9DBEPScuTtfrF6h6ay9KV X-Proofpoint-GUID: 1RoSeJSsy6m9DBEPScuTtfrF6h6ay9KV Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.177.32; envelope-from=si-wei.liu@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1701975487529100003 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" For better debuggability and observability. Signed-off-by: Si-Wei Liu Reviewed-by: Eugenio P=C3=A9rez --- net/trace-events | 1 + net/vhost-vdpa.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/net/trace-events b/net/trace-events index be087e6..c128cc4 100644 --- a/net/trace-events +++ b/net/trace-events @@ -30,3 +30,4 @@ vhost_vdpa_net_data_eval_flush(void *s, int qindex, int s= vq_switch, bool svq_flu vhost_vdpa_net_cvq_eval_flush(void *s, int qindex, int svq_switch, bool sv= q_flush) "vhost_vdpa: %p qp: %d svq_switch: %d flush_map: %d" vhost_vdpa_net_load_cmd(void *s, uint8_t class, uint8_t cmd, int data_num,= int data_size) "vdpa state: %p class: %u cmd: %u sg_num: %d size: %d" vhost_vdpa_net_load_cmd_retval(void *s, uint8_t class, uint8_t cmd, int r)= "vdpa state: %p class: %u cmd: %u retval: %d" +vhost_vdpa_net_load_mq(void *s, int ncurqps) "vdpa state: %p current_qpair= s: %d" diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 61da8b4..17b8d01 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -1109,6 +1109,8 @@ static int vhost_vdpa_net_load_mq(VhostVDPAState *s, return 0; } =20 + trace_vhost_vdpa_net_load_mq(s, n->curr_queue_pairs); + mq.virtqueue_pairs =3D cpu_to_le16(n->curr_queue_pairs); const struct iovec data =3D { .iov_base =3D &mq, --=20 1.8.3.1