Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2189862rdh; Tue, 26 Sep 2023 15:51:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGxPmlb1cmo6qCV0EvkXBO3suYBMFL1ctfvPpVfZLypXtjOZyPOCPEhB739TojDKSU/3OON X-Received: by 2002:a17:90a:a106:b0:26d:d81:82fb with SMTP id s6-20020a17090aa10600b0026d0d8182fbmr100604pjp.29.1695768681799; Tue, 26 Sep 2023 15:51:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695768681; cv=none; d=google.com; s=arc-20160816; b=EJ2T9COl1LMNAdIm8NBlpRBBfNENAKvg38fbWdGLHRPmEbi7ywzN7fvXWYwaXfgB0N FS8Jzxrc5D4dXT8jtDCy7UCEaOzlNlcAnHEN0ESMl6dfFBg6brHXwRCRkVND7pE8yQLx VtuhzhvdcZSljCcNxefiGpH5n9jCexN7RSWiehMKW425tbbkqFaFrqurIWRZyQCj7l2s LbxrD5vnE+jUmft9Xh2lgF32pGluQsFAHMW7ML1sNpY4RXTAC++kPO9XClX9NUkee0T+ rIwllLuv7XbPWkEzwFWq4NrBZWsxy90UATn84km3rW6ORADY1fBU4vI1atQ9gOCDycqb guGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:references:in-reply-to:user-agent:subject:cc:to:from :date:dkim-signature; bh=2Wn+Oz8+SPbM3gd+kYavU89kl0O459xMQgxgmk/VM0E=; fh=ppo2fxUpwoAIYRbAun3iZYZKEpx09/W0P1+vgmjr1iI=; b=STbxGJUhPZukc0FdqzTxZuMX+siTANLrt96rCDRAxd8LYQEBV130WtcEtE5uFE+v/2 zuX0yv705d82OXlaKHVGLwVyrE9e9iTc6biPwYtrsg+JzX03omNMuqgZDZLZLc3Qocgc 73j6gL3ESWab/03emT8gI2Zf70YQ+Jn+oLRpZeAk8KhGkII/ppgSSKddD2PYxj+gBcJt vnUK1AhD+pXF4ieIH7xKqjsPJhkYRmO273zeEepdtmkt6QgQt9xA2CB5cgQnuoxdxmqy GX03K9n2GKEvaa5+A5ZJOejearmNnCrqCl4lwr2V0gZ1RoW8GSHcQAi11/noT2Bl8qw9 r4UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b="PW/4mwwJ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id nh18-20020a17090b365200b002772ff87ee4si8401693pjb.82.2023.09.26.15.51.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 15:51:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b="PW/4mwwJ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id CAA40822741C; Tue, 26 Sep 2023 10:29:25 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232053AbjIZR3L (ORCPT + 99 others); Tue, 26 Sep 2023 13:29:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233944AbjIZR3G (ORCPT ); Tue, 26 Sep 2023 13:29:06 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9537910A; Tue, 26 Sep 2023 10:28:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:Content-Type :MIME-Version:Message-ID:References:In-Reply-To:Subject:CC:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=2Wn+Oz8+SPbM3gd+kYavU89kl0O459xMQgxgmk/VM0E=; b=PW/4mwwJSkE5uCeJsb1NRLo74E c81VBL5z/cVcAbgi+RGrzlAa+sfBbEOk+XCOdtv5imVUZ9Yh+o4UVlhOTj/fN2mO+4fN3lGTRua4G /dz3vqXNhQBld8zpXB9KvVhoYDGp0oCdZxTaSBbYoc59imE7aCQ891xEyKfOvFzXDzbrx98NR1Bf7 mRrkNUZRYHVDiS+oSuUeO38a8ZdAAuFCffZzYqN3QuqidZlerV65faz5IijQ1Li5df0UhqcHwqXr2 ZNOKfdx7eCTVFu4yiclNf47flHE8ZJeIIeKRmXYfW3XGvyM1h+kKVI8lBYdLTz1niaxdk+P9fJ2lg tjn479nQ==; Received: from [31.94.19.5] (helo=[127.0.0.1]) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qlBra-002zDy-2y; Tue, 26 Sep 2023 17:28:48 +0000 Date: Tue, 26 Sep 2023 19:28:45 +0200 From: David Woodhouse To: Paolo Bonzini , Alexander Graf CC: kvm@vger.kernel.org, Peter Zijlstra , Sean Christopherson , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org, Nicolas Saenz Julienne , "Griffoul, Fred" Subject: =?US-ASCII?Q?Re=3A_=5BRFC=5D_KVM=3A_x86=3A_Allow_userspace_exi?= =?US-ASCII?Q?t_on_HLT_and_MWAIT=2C_else_yield_on_MWAIT?= User-Agent: K-9 Mail for Android In-Reply-To: References: <1b52b557beb6606007f7ec5672eab0adf1606a34.camel@infradead.org> <3dc66987-49c7-abda-eb70-1898181ef3fe@redhat.com> Message-ID: <21C2A5D8-66D9-4EF0-A416-4B1049C91E83@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SRS-Rewrite: SMTP reverse-path rewritten from by desiato.infradead.org. See http://www.infradead.org/rpr.html X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Tue, 26 Sep 2023 10:29:25 -0700 (PDT) On 26 September 2023 19:20:24 CEST, Paolo Bonzini = wrote: >On Sat, Sep 23, 2023 at 6:44=E2=80=AFPM Alexander Graf = wrote: >> On 23=2E09=2E23 11:24, Paolo Bonzini wrote: >> > Why do you need it? You can just use KVM_RUN to go to sleep, and if = you >> > get another job you kick out the vCPU with pthread_kill=2E (I also d= idn't >> > get the VSM reference)=2E >> >> With the original VSM patches, we used to make a vCPU aware of the fact >> that it can morph into one of many VTLs=2E That approach turned out to = be >> insanely intrusive and fragile and so we're currently reimplementing >> everything as VTLs as vCPUs=2E That allows us to move the majority of V= SM >> functionality to user space=2E Everything we've seen so far looks as if >> there is no real performance loss with that approach=2E > >Yes, that was also what I remember, sharing the FPU somehow while >having separate vCPU file descriptors=2E > >> One small problem with that is that now user space is responsible for >> switching between VTLs: It determines which VTL is currently running an= d >> leaves all others (read: all other vCPUs) as stopped=2E That means if y= ou >> are running happily in KVM_RUN in VTL0 and VTL1 gets an interrupt, user >> space needs to stop VTL0 and unpause VTL1 until it triggers VTL_RETURN >> at which point VTL1 stops execution and VTL0 runs again=2E > >That's with IPIs in VTL1, right? I understand now=2E My idea was, since >we need a link from VTL1 to VTL0 for the FPU, to use the same link to >trigger a vmexit to userspace if source VTL > destination VTL=2E I am >not sure how you would handle the case where the destination vCPU is >not running; probably by detecting the IPI when VTL0 restarts on the >destination vCPU? > >In any case, making vCPUs poll()-able is sensible=2E Thinking about this a bit more, even for HLT it probably isn't just as sim= ple as checking for mp_state changes=2E If there's a REQ_EVENT outstanding = for something like a timer delivery, that won't get handled and the IRQ act= ually delivered to the local APIC until the vCPU is actually *run*, will it= ?