From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 C57111CA94 for ; Wed, 25 Oct 2023 12:42:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="aTHVLM06" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 92C1EC433C8; Wed, 25 Oct 2023 12:42:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698237753; bh=yzeS0gUSkHVygnq8OBWI5G21PAVnebjTnO/tgesGvY4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=aTHVLM06ImMeTx5eBRFuUsk+lpLtp2AmANegiS100h0WJMrcqkmiH5TE+ISfV2oup qqBmFAfFfdShDPXmVPcGF4xrFj8/4CfOUIUNGKUsD7kO2K5mJ8awHlpOQk1dkOcH9x Tp5FsC0makMBovsRWQPIydexLyem0/Fn9AQ8KilDeIUPqtfZWNqgXAvhpCkchqw5mT rnGgNkehZWCaopERZ0+nbdMHuaG4M9YJZ/Kz9Zl8CfxzaMOWdBN7CkS7qrcjeRZAsR OrnYyObxWM2cyN17Dy0OuYjopi/3jfPQtW+vEVGV7whzPzSYK2cqQQVi8B4InjB6p5 8a7wKr2YzZaYQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1qvdDS-007YoD-RZ; Wed, 25 Oct 2023 13:42:31 +0100 Date: Wed, 25 Oct 2023 13:42:30 +0100 Message-ID: <86cyx250w9.wl-maz@kernel.org> From: Marc Zyngier To: Jan Henrik Weinstock Cc: oliver.upton@linux.dev, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, Lukas =?UTF-8?B?SsO8bmdlcg==?= Subject: Re: KVM exit to userspace on WFI In-Reply-To: References: <87ttql5aq7.wl-maz@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/29.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) Precedence: bulk X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: jan@mwa.re, oliver.upton@linux.dev, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, lukas@mwa.re X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Wed, 25 Oct 2023 13:12:14 +0100, Jan Henrik Weinstock wrote: > > Hi Marc, > > Thanks for your feedback. I understand that request_interrupt_window > is not to be used. I assume a setting a flag is a better way, > something similar to KVM_ARCH_FLAG_RETURN_NISV_IO_ABORT_TO_USER, e.g. > KVM_ARCH_FLAG_WFX_EXIT_TO_USER. > > I will also check that WFx traps are always enabled while this mode is > active to make sure userspace does not get blocked/scheduled out. Why would that be an acceptable behaviour? > The reason for this is that we cannot have the thread that executes > KVM_RUN to be blocked or scheduled out whenever it hits a WFI. Why? If that's not acceptable, how do you even cope with the basic preemption? > Nop-WFIs are not a problem, since the PE will just continue executing > instructions, which is fine. We are currently using a timeout signal > that kicks KVM_RUN back into userspace, but we are seeing a lot of > time wasted because our KVM thread hangs in WFI/WFEs. It would be > better if we could just return from KVM_RUN immediately if the thread > would otherwise be blocked. On the face of it, this makes little sense: - While in userspace, no interrupt source that normally delivered without any userpsace intervention will be blocked (timers, VLPIs...). I cannot how this can be a good idea. - Trapping WFE is an important scheduling hint, and returning to userspace defeats it. Contended spinlocks, for example, will be even slower to acquire. I'm sure you have a particular use case for such a degraded behaviour, but since you are not describing it, I'm not at all inclined to actively break KVM's performance and scalability. Thanks, M. -- Without deviation from the norm, progress is not possible. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7D91DC07545 for ; Wed, 25 Oct 2023 12:43:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Subject:Cc:To:From:Message-ID:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=K0mg7HhTXKdqC6menvvdGgEDrRI/LVzOiSWkJ/RBBiw=; b=E8K9WsaAEE8m9L IuPHzRbnSHTMJoJz2n0shY4GPK8wmd7sTL0FEXCIPsrEpOAUGBOMAafFkIGjD8bFaSR/bscofNhXC 1GK/4qVqU9MZ7chne2pFOK3h1uBS6NrcoByeAglDmL/rOjSoQvL5AqtmSIBs09LT4/64dXDViDUNf 2QkkkOpPuxBuurH856WJrTKRLxdjqJJCnMpGY2toRQaqBUGk7oM/ds2mBfwWMI89iADKJuIuKCnQR NeoLcl/+tL3lpOf73H4Jx5XCcd/ZyH4G1rF1NtryX2ud3kFUcYI45D7VluTy8m3SW0zwvV5JtwWwo HIM0TBr2XBRxcQWjEjcg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qvdDc-00CKEI-32; Wed, 25 Oct 2023 12:42:40 +0000 Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qvdDZ-00CKDc-30 for linux-arm-kernel@lists.infradead.org; Wed, 25 Oct 2023 12:42:39 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 6F437CE3849; Wed, 25 Oct 2023 12:42:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 92C1EC433C8; Wed, 25 Oct 2023 12:42:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698237753; bh=yzeS0gUSkHVygnq8OBWI5G21PAVnebjTnO/tgesGvY4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=aTHVLM06ImMeTx5eBRFuUsk+lpLtp2AmANegiS100h0WJMrcqkmiH5TE+ISfV2oup qqBmFAfFfdShDPXmVPcGF4xrFj8/4CfOUIUNGKUsD7kO2K5mJ8awHlpOQk1dkOcH9x Tp5FsC0makMBovsRWQPIydexLyem0/Fn9AQ8KilDeIUPqtfZWNqgXAvhpCkchqw5mT rnGgNkehZWCaopERZ0+nbdMHuaG4M9YJZ/Kz9Zl8CfxzaMOWdBN7CkS7qrcjeRZAsR OrnYyObxWM2cyN17Dy0OuYjopi/3jfPQtW+vEVGV7whzPzSYK2cqQQVi8B4InjB6p5 8a7wKr2YzZaYQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1qvdDS-007YoD-RZ; Wed, 25 Oct 2023 13:42:31 +0100 Date: Wed, 25 Oct 2023 13:42:30 +0100 Message-ID: <86cyx250w9.wl-maz@kernel.org> From: Marc Zyngier To: Jan Henrik Weinstock Cc: oliver.upton@linux.dev, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, Lukas =?UTF-8?B?SsO8bmdlcg==?= Subject: Re: KVM exit to userspace on WFI In-Reply-To: References: <87ttql5aq7.wl-maz@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/29.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: jan@mwa.re, oliver.upton@linux.dev, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, lukas@mwa.re X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231025_054238_329439_5A662033 X-CRM114-Status: GOOD ( 23.95 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, 25 Oct 2023 13:12:14 +0100, Jan Henrik Weinstock wrote: > > Hi Marc, > > Thanks for your feedback. I understand that request_interrupt_window > is not to be used. I assume a setting a flag is a better way, > something similar to KVM_ARCH_FLAG_RETURN_NISV_IO_ABORT_TO_USER, e.g. > KVM_ARCH_FLAG_WFX_EXIT_TO_USER. > > I will also check that WFx traps are always enabled while this mode is > active to make sure userspace does not get blocked/scheduled out. Why would that be an acceptable behaviour? > The reason for this is that we cannot have the thread that executes > KVM_RUN to be blocked or scheduled out whenever it hits a WFI. Why? If that's not acceptable, how do you even cope with the basic preemption? > Nop-WFIs are not a problem, since the PE will just continue executing > instructions, which is fine. We are currently using a timeout signal > that kicks KVM_RUN back into userspace, but we are seeing a lot of > time wasted because our KVM thread hangs in WFI/WFEs. It would be > better if we could just return from KVM_RUN immediately if the thread > would otherwise be blocked. On the face of it, this makes little sense: - While in userspace, no interrupt source that normally delivered without any userpsace intervention will be blocked (timers, VLPIs...). I cannot how this can be a good idea. - Trapping WFE is an important scheduling hint, and returning to userspace defeats it. Contended spinlocks, for example, will be even slower to acquire. I'm sure you have a particular use case for such a degraded behaviour, but since you are not describing it, I'm not at all inclined to actively break KVM's performance and scalability. Thanks, M. -- Without deviation from the norm, progress is not possible. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel