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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B668C0032E for ; Wed, 25 Oct 2023 12:42:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234862AbjJYMmh (ORCPT ); Wed, 25 Oct 2023 08:42:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231648AbjJYMmg (ORCPT ); Wed, 25 Oct 2023 08:42:36 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFACC8F for ; Wed, 25 Oct 2023 05:42:33 -0700 (PDT) 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") 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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.