From patchwork Wed Jan 10 20:40:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 187074 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp1044849dyi; Wed, 10 Jan 2024 12:45:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IGYTBWC5jb5irUpWjiGYWqxbr+821EkuHXbhn/yLefQEYgHEfzrj415NV4b4svbLEyyk8eJ X-Received: by 2002:a25:c706:0:b0:dbd:3ffb:5178 with SMTP id w6-20020a25c706000000b00dbd3ffb5178mr181671ybe.104.1704919527986; Wed, 10 Jan 2024 12:45:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704919527; cv=none; d=google.com; s=arc-20160816; b=vczcBoShjDNkjg3bYUEoaxaAv6keO1zxocozfPuk/DbsVzpXbszd8Wf6b6qRhuyEgG uz/cpRspBzxucBZauTAHV2qO0u32yjhbm59QKCiUCAWzyaWf7rmQOWDkVlKaMGfvEUA+ CHJLCEFoK51e+Gl0/R5JiPNsEyPFhQV+nisJNhU8R00Az/gZHZqo0Snh+b3CTB/hscJ5 X7zqh39LP6q8hgirgiHyYnWhDKurqnL2tdanCsDoMNJlku4e8n6oi4xtIkZGzV/KHrsS q2Ji1zQmuXGzlLpUEl7auHKjv3OO7mXGRFHbG9mcDLCcfMnqdHhKtVIe2J9fRa2Ya/GL dQew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=KZgdO8D8ThqWqmTr9W+5D2aKyTLHuIlU6faRNQ9Rhag=; fh=NLOUc4UpZ/0A9JrieYT9bxhjFpxay5qeZXON7PgxqoM=; b=FgZXs9CPd1NIduJjrimywzkMfOiMmGUfvQoEWqSPcW4g09JP2I3nf/8QZGF0VF+gCM qAAwfO6wWXrqap5WF5a6SoejLiolxgWS4SkSDX+yCUhmYnvIpU4AMi1/7tgOgsZxh5tZ 3GF1ZbUsNgacDE8AICO+VPO6gSte4yt6kTRMWQF9IO2s0Z96uew8CNrs9Q+S7vC2y5eL Rn/svsq1pbsbpiHM9YrPPuHrV0RMfjWVE2zi4CbQUjwjs7RA0p4ijCtj1PATey+eC+0v HrLAFwK8df2w6k79W3+gPscIA/zSE8i98FnokvPxWUIZYJZOjeUnxYujjI/GaLBaoqh3 2cow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-11-20 header.b=WbPA2ye3; spf=pass (google.com: domain of linux-kernel+bounces-22763-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22763-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id r8-20020ac85c88000000b00429bc1c4a65si1037364qta.629.2024.01.10.12.45.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 12:45:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-22763-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-11-20 header.b=WbPA2ye3; spf=pass (google.com: domain of linux-kernel+bounces-22763-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22763-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 372091C21171 for ; Wed, 10 Jan 2024 20:45:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 85AEA57301; Wed, 10 Jan 2024 20:40:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="WbPA2ye3" Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2AE1B4F8AD for ; Wed, 10 Jan 2024 20:40:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com 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 40AK8Rre021239; Wed, 10 Jan 2024 20:40:24 GMT 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=KZgdO8D8ThqWqmTr9W+5D2aKyTLHuIlU6faRNQ9Rhag=; b=WbPA2ye3JVDFRNlWxlIhbD458+tsIL5a6Q5z9y5rLA3TrrgvYRTuZQo+0NeIiMSYhW8g qsfhgN4lnb4/pZCOwmMk0UZRmmXx8+yPn3Km+gZwpMMlPaUZgM2j52jAJnXzBquPzSLU YH5s66pHhs0YnOLPIdn9XRDvzTQQV4GvV0VtbINYs2jHDNuob/a+K6IT9KG6OsJ/EoTl rA0iYpBMVlaDJhkezyfaok/KwGmxlokKlIeGGWTcj3gnMMldJkzUSjHgv2LRMsiz7zoV gVj9cqdL5cKgrOoQlxe4M8XIv9JdulCagneN2kRrhQI3DyBZEpi1q+8kxFXFRMJvzePn MQ== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3vj1atg550-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Jan 2024 20:40: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 40AKUqbL030093; Wed, 10 Jan 2024 20:40:23 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3vfutp5xad-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Jan 2024 20:40: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 40AKeGrd005067; Wed, 10 Jan 2024 20:40:22 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3vfutp5x5e-8; Wed, 10 Jan 2024 20:40:22 +0000 From: Steve Sistare To: virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Cc: "Michael S. Tsirkin" , Jason Wang , Si-Wei Liu , Eugenio Perez Martin , Xuan Zhuo , Dragos Tatulea , Eli Cohen , Xie Yongji , Steve Sistare Subject: [RFC V1 07/13] vhost-vdpa: flush workers on suspend Date: Wed, 10 Jan 2024 12:40:09 -0800 Message-Id: <1704919215-91319-8-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1704919215-91319-1-git-send-email-steven.sistare@oracle.com> References: <1704919215-91319-1-git-send-email-steven.sistare@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=2024-01-10_10,2024-01-10_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 adultscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401100163 X-Proofpoint-ORIG-GUID: JTWauBm8GQEyesMnMyowOTvYe7YbdRP1 X-Proofpoint-GUID: JTWauBm8GQEyesMnMyowOTvYe7YbdRP1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787737699169935493 X-GMAIL-MSGID: 1787737699169935493 To pass ownership of a live vdpa device to a new process, the user suspends the device, calls VHOST_NEW_OWNER to change the mm, and calls VHOST_IOTLB_REMAP to change the user virtual addresses to match the new mm. Flush workers in suspend to guarantee that no worker sees the new mm and old VA in between. Signed-off-by: Steve Sistare --- drivers/vhost/vdpa.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index 8fe1562d24af..9673e8e20d11 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -591,10 +591,14 @@ static long vhost_vdpa_suspend(struct vhost_vdpa *v) { struct vdpa_device *vdpa = v->vdpa; const struct vdpa_config_ops *ops = vdpa->config; + struct vhost_dev *vdev = &v->vdev; if (!ops->suspend) return -EOPNOTSUPP; + if (vdev->use_worker) + vhost_dev_flush(vdev); + return ops->suspend(vdpa); }