Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp1229923rdd; Wed, 10 Jan 2024 12:46:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IEYmU6u+f9SOW+asiKFzfvLUiOHFSshRTxw5AglQ4HFoRrKNW333bx2DmFuUbaBdgfxfzP3 X-Received: by 2002:a05:600c:c09:b0:40e:526d:5df with SMTP id fm9-20020a05600c0c0900b0040e526d05dfmr3241wmb.233.1704919576807; Wed, 10 Jan 2024 12:46:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704919576; cv=none; d=google.com; s=arc-20160816; b=RpwS0G5KBGHo0e1rjdKxdj4Z7cKCocgoirjatuGqO6717yTIfl+gBTtIiAKDGmvvNI Qz1g1fV75EmIi5ldQm84UEyyxGpIalcyZEfe5AtKqxUcAk+Sj1Ca2ZrkGv0yetAmST5m aFRReQsrCQhJnBcYVai+SeAQqHvrwCsUlhJOIRoAYoTxLIaSarbWQZRr8DZHryM3AIue hzIu4ZJOINJynulzte5L6F2riejJr7hjON28f512OEKx86KPvrYHCHSCb7FumW96qmu1 j0uYIhInv1x2e3QKsOlggyy2pt0/4hBxJrRqSrrcpoEvxQrNyfjpM25Kf/ON0J4TfScT GZ/g== 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=NFZx/EFKZOPMSB3OaPzQiVb/lgOe0vt9g+rSbf9Taic=; fh=NLOUc4UpZ/0A9JrieYT9bxhjFpxay5qeZXON7PgxqoM=; b=i52mp6GgBH0UfOiXFa0jQfa9V1NWMND3pUICiZbTfowH6oZRLWna4W9IHlFDFjP1eZ 0PGdXmV5ej1Mja0xauWEk6RBO+qvYf2rM3ctw0C1WhNPHRbu8ZL+B+Zw29EYQ1Dmui4b mjjwjBlJ7eyY5JzEXEGeB7tQBSBsKCSMooKLlZmUN8pzJ1y5IbVv2KM47/SgRTzjZhtU sZkeykIR1Ekx9ryld6G8ML/8i3HI6EJu5XTYKTAowbePsLJdX9z3k96RlO7NAE/TRYJn 78fCuNGzdv2nL09LhwJpcdLlqE9DPsjXMDuXEK8mh6Nm55rglEuW5JFJzxySEBQr8MnW 6Amw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-11-20 header.b=GXDavQHm; spf=pass (google.com: domain of linux-kernel+bounces-22768-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22768-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id y4-20020a170906524400b00a232a3191f0si2099002ejm.254.2024.01.10.12.46.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 12:46:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-22768-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-11-20 header.b=GXDavQHm; spf=pass (google.com: domain of linux-kernel+bounces-22768-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22768-linux.lists.archive=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 am.mirrors.kernel.org (Postfix) with ESMTPS id BDB391F210F9 for ; Wed, 10 Jan 2024 20:46:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3C6A457871; Wed, 10 Jan 2024 20:40:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="GXDavQHm" Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.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 2567357339 for ; Wed, 10 Jan 2024 20:40:46 +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 (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 40AJfmVQ028156; Wed, 10 Jan 2024 20:40:26 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=NFZx/EFKZOPMSB3OaPzQiVb/lgOe0vt9g+rSbf9Taic=; b=GXDavQHmS5tUjLInShR585JNceUqkw1Lcofpv0QDo4qb/0J+I24z9u6xaAnHQQ5COOHK xupM/kJoP5+xpbhsc4+BpaarrutY+fbyD3h8TzkJ9/xeS+RF/YM5Tr6dr8IC2mKeGpe0 aumsDcU3D3JWqPq/VVG7mDXZrgQsJ8TckBpNVlkVoV3Cg3BXUqCXmIf+2m0tzkP9y02k ssXh82bebZ2Mj7K3bwfoLYzpOYod6dRs0sjOd5DXdEA2eqyCejWnUWKxEvO4Kae/eN+u NjS7xZaIMbblmX76WAZO9miDAttcQYJAxP9xoMV/uCBTq16DzlmkG6PbLMNwRjBSQGAm dA== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3vj1m404ac-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Jan 2024 20:40:26 +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 40AIvv0U030295; Wed, 10 Jan 2024 20:40:25 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3vfutp5xcd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Jan 2024 20:40: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 40AKeGrj005067; Wed, 10 Jan 2024 20:40:24 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-11; Wed, 10 Jan 2024 20:40:24 +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 10/13] vdpa_sim: flush workers on suspend Date: Wed, 10 Jan 2024 12:40:12 -0800 Message-Id: <1704919215-91319-11-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: R2OpFmtsJ-lX7DSIEv1LxOHwtgQ4LfMP X-Proofpoint-GUID: R2OpFmtsJ-lX7DSIEv1LxOHwtgQ4LfMP Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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/vdpa/vdpa_sim/vdpa_sim.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c index 6304cb0b4770..8734834983cb 100644 --- a/drivers/vdpa/vdpa_sim/vdpa_sim.c +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c @@ -74,6 +74,17 @@ static void vdpasim_worker_change_mm_sync(struct vdpasim *vdpasim, kthread_flush_work(work); } +static void flush_work_fn(struct kthread_work *work) {} + +static void vdpasim_flush_work(struct vdpasim *vdpasim) +{ + struct kthread_work work; + + kthread_init_work(&work, flush_work_fn); + kthread_queue_work(vdpasim->worker, &work); + kthread_flush_work(&work); +} + static struct vdpasim *vdpa_to_sim(struct vdpa_device *vdpa) { return container_of(vdpa, struct vdpasim, vdpa); @@ -512,6 +523,8 @@ static int vdpasim_suspend(struct vdpa_device *vdpa) vdpasim->running = false; mutex_unlock(&vdpasim->mutex); + vdpasim_flush_work(vdpasim); + return 0; } -- 2.39.3