Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp1737833rdb; Sat, 20 Jan 2024 11:06:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IGL+RoT/ChdXOTOG0M3MChAuEWRpJbSj7Vtp1PYDHqP0XzGJcLW/WLbEL2x7dTPpsESqwE3 X-Received: by 2002:a1c:7315:0:b0:40e:5327:91b4 with SMTP id d21-20020a1c7315000000b0040e532791b4mr998144wmb.222.1705777566332; Sat, 20 Jan 2024 11:06:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705777566; cv=pass; d=google.com; s=arc-20160816; b=Tg6KFX3sU9HS7VbWO1pd0oj3bBziJa3wUypNqG6tAwlil0ZFH+jpCfjyD7wQC3ce5b 49craN7jEa7YyEHwqAgFBr3TcDTggy66O9AiYJOtL0NnRLSoSi+0RI/oZrh5etySBKht hC/hXNShcJFy34VIRmiPFHYN7wgTeItNiUoGBg3Xjro2PbWeGZKMdVPgZRrlLTHHv56E mI5wz5o4z8lWPqNYCzgaOTlK9i5DG/52U7JECuM417nI7Wo5Qhy0xw45ZMWIf2i9QYS0 t2iLRAlEs9tFL7YOt+gki4x6+yYtEtv1Qwv2hGqfq7SCRpdrYALin96K6tZdIRTE8CZH yTpw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=SprmNfSe/qgS3f5QvXvkRzwH+0s17wzY9N8HsavF8do=; fh=975nUjm/5Tvv+TwDZcgMRfki0UMZiSZXCwYjYR8WL5I=; b=X8+7mm5Jx8ofmOIx4R1SVNUuWKYXKZgwEzDvDxcMlHct+bAiPBy2Tj2ZEJsBdrSAmb kFvRhOgWNuebiirl5PGm0k1ZNlhCF8VroxJdGDu6WcnzsjEElwPw5A0Y7NwCooz2qej4 ISoRPHB+t2IKaYeVin5nyX/MgAB7QQGBSAXrFVdwmmE1zVUmXOW7Xe42XDw0l8YLyZk+ bzwGrqf7Vyfa1AsF3vyiRrHj6ETwLMdjZ7Toq0tbXG4KYCjAojdy+ly/p+f2qB6Cw5zz OK1G7Xsh2v+12X33W2SauNprjBWh5S99Xl022JA+WIAPwVU+6LETEC167c0BV3oTZpz1 /ozQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Pu6jsdCh; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-31832-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-31832-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id g2-20020a170906198200b00a2cdeb3916esi7887384ejd.165.2024.01.20.11.06.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jan 2024 11:06:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-31832-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=@intel.com header.s=Intel header.b=Pu6jsdCh; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-31832-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-31832-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.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 A86431F22990 for ; Sat, 20 Jan 2024 15:27:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C9BFE107A9; Sat, 20 Jan 2024 15:27:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Pu6jsdCh" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) (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 75B98FBEF; Sat, 20 Jan 2024 15:27:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.12 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705764447; cv=none; b=KrZ/l96b/j2PAtxWkFeUGrlZVc0uPTgFH1YuUxXFduq2itwOr8hREpIjIrVSptgpOiHFH9PtGYBt/fzqQ5xb6+cJxUsbHjgjoPMSyIupmfQ05Z71SwcQ4xcZvWOrQhE5ydOZ7xlfW8cV/LkWhbL8jsaoRvy1b9m3avj0thjcP+k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705764447; c=relaxed/simple; bh=Ba1yk/kIdw9umf8+nzddJN9Ry40uVoGOLOWeX9s8zzs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=a9Whr9NHFUE0iS+6rnrpPlAYq1K1YqDMeUEmEGYJDFp8y+YJHLdw1X7z4haFmeIgJkBCS7To7jBCeRj2qRsyfTpkfPynsWtedgEhdGGMfSEfXASZEOcWsVONqDYgXlTEym3JPzMugaCQDCRjudpT3k7fo2hBNcaMwLoT4IDh6V8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Pu6jsdCh; arc=none smtp.client-ip=192.198.163.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1705764445; x=1737300445; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=Ba1yk/kIdw9umf8+nzddJN9Ry40uVoGOLOWeX9s8zzs=; b=Pu6jsdChHaDcc2uCaFNHuR826hbrOlucsQyOTuVCs2yhWWeATpLKHIvv O8jQcD9Rn05IycMMregs8PJdBFF2d01hD6r9JImGAbzC7lWOsTeBqYBlY B4lbJay6ZkO8RMWV2tiPDXHJzREthHsX75uJyOECQuE5xw3Ewx1dHkSmu yJJeMKcz8kReZxHeeJNqkLGNmCPFL4IQtcIjWOIuG5Gw8EIRY0ZaUQgW9 Fq4z7vT0QYqqaOuP6mD80Hml6poEsr1YzLk9SNJIYINMbYy6maz+O4swR wljulDF3f8ZSTs0lpYQ3ANpq/Dhuuh2N+0FodyXxgy9D8Lo8kE3X1ujqX Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10959"; a="820806" X-IronPort-AV: E=Sophos;i="6.05,208,1701158400"; d="scan'208";a="820806" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jan 2024 07:27:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10959"; a="928631890" X-IronPort-AV: E=Sophos;i="6.05,208,1701158400"; d="scan'208";a="928631890" Received: from yilunxu-optiplex-7050.sh.intel.com (HELO localhost) ([10.239.159.165]) by fmsmga001.fm.intel.com with ESMTP; 20 Jan 2024 07:27:23 -0800 Date: Sat, 20 Jan 2024 23:24:10 +0800 From: Xu Yilun To: Sean Christopherson Cc: Paolo Bonzini , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, David Matlack Subject: Re: [PATCH 2/4] KVM: Put mm immediately after async #PF worker completes remote gup() Message-ID: References: <20240110011533.503302-1-seanjc@google.com> <20240110011533.503302-3-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240110011533.503302-3-seanjc@google.com> On Tue, Jan 09, 2024 at 05:15:31PM -0800, Sean Christopherson wrote: > Put the async #PF worker's reference to the VM's address space as soon as > the worker is done with the mm. This will allow deferring getting a > reference to the worker itself without having to track whether or not > getting a reference succeeded. > > Note, if the vCPU is still alive, there is no danger of the worker getting > stuck with tearing down the host page tables, as userspace also holds a > reference (obviously), i.e. there is no risk of delaying the page-present > notification due to triggering the slow path in mmput(). > > Signed-off-by: Sean Christopherson Reviewed-by: Xu Yilun > --- > virt/kvm/async_pf.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/virt/kvm/async_pf.c b/virt/kvm/async_pf.c > index 876927a558ad..d5dc50318aa6 100644 > --- a/virt/kvm/async_pf.c > +++ b/virt/kvm/async_pf.c > @@ -64,6 +64,7 @@ static void async_pf_execute(struct work_struct *work) > get_user_pages_remote(mm, addr, 1, FOLL_WRITE, NULL, &locked); > if (locked) > mmap_read_unlock(mm); > + mmput(mm); > > if (IS_ENABLED(CONFIG_KVM_ASYNC_PF_SYNC)) > kvm_arch_async_page_present(vcpu, apf); > @@ -85,8 +86,6 @@ static void async_pf_execute(struct work_struct *work) > trace_kvm_async_pf_completed(addr, cr2_or_gpa); > > __kvm_vcpu_wake_up(vcpu); > - > - mmput(mm); > } > > static void kvm_flush_and_free_async_pf_work(struct kvm_async_pf *work) > -- > 2.43.0.472.g3155946c3a-goog >