Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2531889rda; Wed, 25 Oct 2023 05:42:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHv/+Fibrny+FjsBGUoODbbZwgTc2sgNRgOn8CVqaf8JE5NzMnK/76t0wZxs7PC4HSeUKXr X-Received: by 2002:a25:8212:0:b0:d9a:4bc3:226e with SMTP id q18-20020a258212000000b00d9a4bc3226emr13615029ybk.37.1698237767515; Wed, 25 Oct 2023 05:42:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698237767; cv=none; d=google.com; s=arc-20160816; b=p9tt/uJR9NNt/74KW/h8rSIkR1gKVfXy0HFHQRidykzXEMqkcMuQspuSVJqWc4+MZJ tUi5pyw1OQxbRGKll64uQ+t+B9j4xFgy6vWPr6HC5QrrtCyk5Ybamv2liWDShdRJXEPm 8tUWj7ywJw7Kub3aCILWuv+I/k7kVyPM4eGPqM+Y3/WDTkp2JMbqhIBTfZ7+QaN5++pT XqiavYkqxOfx6dzF2FIuC7/mC95dpwxcaI8HWFxxFx+VCBs3oF1oTS+IouvmnrZdOsnL sIJbiObgpiYOg8Uod0p2p3TrLbYAlP/m9cA7JqyRYw3KrJ84uajdT1qLIEqoRSaHjFlz 7PAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature; bh=uy67YTxKO1H9IB70Ee2gK5p/5p1sydeoBthOFArrle4=; fh=Zqa9pQKdV1ogoxefhu2MEbaWEHbvjsGDNzwWyUJeGq4=; b=S1a+2dAJ3Ub8F/5+/CUZBygM002m+H0t70v2b4I/vpQ5AQ/WjwiKQQmiUt8py7FlcX 1p1sKSPdAKlgoeZCJhh5be/XhR5b3Ble1N7hvt6AQbAZnI5TqYTZpJmU7DmNWaZtR1GK QYRm9UrJQ/zqLnAkvBdEW634W2KvjE1e3LRl/oCzPbconptOoS4tjDzLafrvfWWEblOc W6o66FAC25j61qo0Ev1qkxxILkkRdq7bcn6udKHt32H9PE2ISn4fWtnhmPk3apJRRjyQ rnquc/A2Ap5rvslKBV/EKP7qCDHrDb7C+SE0VqqTN6ZHZCOPU6IcjS5ybKlx2yRF62Lx dRtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aTHVLM06; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id x10-20020a25ac8a000000b00d7b9ffa802bsi10341200ybi.470.2023.10.25.05.42.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 05:42:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aTHVLM06; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id A12D4810835D; Wed, 25 Oct 2023 05:42:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234594AbjJYMmh (ORCPT + 99 others); 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 X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Wed, 25 Oct 2023 05:42:44 -0700 (PDT) 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.