Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp675330rdb; Tue, 19 Sep 2023 07:09:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHALKPWrxPn25ooZMTtXDxF2y6eZfcvHO0O5Xp94yxipkV5rafU3VuA3ClJlcKyGfx40dif X-Received: by 2002:a05:6a00:813:b0:68e:39b5:7e63 with SMTP id m19-20020a056a00081300b0068e39b57e63mr12877678pfk.16.1695132588963; Tue, 19 Sep 2023 07:09:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695132588; cv=none; d=google.com; s=arc-20160816; b=EN0a8r2YfjselgSHsGt52lywnSKlRgf+8hkM0I9lsuoGeYb1OJZ2DOT+KcJ7wvlVFJ Gz0NK243dRfeXCpzKzvgpHT4EOB9YiN0VhUp711SG+tFJmjHGQIq6Fgwpjg0eIgW7aai NjIbmf7xZv5kLTLKI4XBVkCFxv5AmLWHuDBT/wv6yCRgNV5e/8vegVMtr9P9+TYttkTF 2iGVbGPQhD4ZyfoKBbcMOjROlqT9hdrh8iwWQ5xw8mPZSAimOcI4Olf7PuhNxqP/x2XX AA2aXqsQPsIUi/VnHaPu+RGtBz7asP79AhU1MmTjRRa0co1q6t3ER3VbXN+hjGuD5sB6 qiSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=9Um9xivfZIzOpGAbhiiXrCDCVB724N5qIHjbsLgt4Ac=; fh=obXTxf3VXFHeJuTFRM2Iw4APXowTJvtS1lORpYHRdWE=; b=kbi1PDAkQcKd4QOQgvQ4BR+DjmIriUxYHypzxO4Y/W1oOpqwWaElrm7CQtr9EIvzEw DeMwCN4IxR5vt+6kBDp4osz9cSkwPBNI21Snvh/GhMaPvocUw6pThFD5CVvAG7+zdRrR YRqT/00eVKxKeqwEvcsI4vdvIB6jkuJdXGnKhBR0EW+fjYRMLVjAzDyahOTgJ0N0Px7y qLdLLoWP6eLmzeGQUuKer0VKfwGt3xIzz5WkgK97vkdytTlotfVZ35gMmIBhlw5W/rCL 8JhhsctNtIpJR7b0Xn7PtFXXTdgGiG1p+R4fWZk1HYc+2xtAEoRtsh5WTcg6p4SY97SR eeAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=iZvMDqxg; 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 Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id o124-20020a62cd82000000b006871178848csi9617099pfg.208.2023.09.19.07.09.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 07:09:48 -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=@infradead.org header.s=casper.20170209 header.b=iZvMDqxg; 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 Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 19A768233512; Tue, 19 Sep 2023 02:05:27 -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 S230477AbjISJFT (ORCPT + 99 others); Tue, 19 Sep 2023 05:05:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230424AbjISJFR (ORCPT ); Tue, 19 Sep 2023 05:05:17 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84A63114; Tue, 19 Sep 2023 02:05:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=9Um9xivfZIzOpGAbhiiXrCDCVB724N5qIHjbsLgt4Ac=; b=iZvMDqxgfVG849kaE5gtwfVFMM YNYWJLuio+/Rs8inIPe/YyI7Rr6GVuUwmlpiqnStl1uQDFzxqdmU2p6+HsopumMBvl/UZYqGzDhoC EQJIEePHbzuHZKCM0DIT/5+E8x8UD6OhQxJRy4A0O77fQ+ej6MIEHr3Q2jSg/WjpDWqdlhG6J/aqq q+w8YLveHwMZF8wwmkMRp2cOLKzd8et2daNDzFZT1U9AxOAVfwh+lUE6hsHfdue0cbkfDuPOTc9NE 1K6YV47tOLe+BdI2tVe0FFQPK/l+GXJqi7PRKo2sqe32njJAfdrpA7lx1hbcpxaJldo0Y5ONJlkNm sIQVfavQ==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1qiWf1-00GKUe-4M; Tue, 19 Sep 2023 09:04:47 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id C60CF30042E; Tue, 19 Sep 2023 11:04:46 +0200 (CEST) Date: Tue, 19 Sep 2023 11:04:46 +0200 From: Peter Zijlstra To: Alexander Graf Cc: David Woodhouse , kvm@vger.kernel.org, Sean Christopherson , Paolo Bonzini , 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: Re: [RFC] KVM: x86: Allow userspace exit on HLT and MWAIT, else yield on MWAIT Message-ID: <20230919090446.GC21729@noisy.programming.kicks-ass.net> References: <1b52b557beb6606007f7ec5672eab0adf1606a34.camel@infradead.org> <63b382bf-d1fb-464f-ab06-4185f796a85f@amazon.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 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]); Tue, 19 Sep 2023 02:05:27 -0700 (PDT) On Mon, Sep 18, 2023 at 01:59:50PM +0200, Alexander Graf wrote: > The problem with MWAIT is that you don't really know when it's done. This isn't really a problem. MWAIT is allowed (expected even) to return early. REP;NOP is a valid implementation of MWAIT. MWAIT must not delay waking (much) after either: - write to monitored address - interrupt pending But it doesn't say anything about not waking up sooner. Now, obviously on real hardware you prefer if MWAIT were to also do the whole C-state thing and safe your some actual power, but this is virt, real hardware is not a concern and wakeup-timeliness also not much. IIRC the ARM64 WFE thing has a 10khz timer or something it wakes from if nothing else. So I suppose what I'm saying is that: nanosleep(100000) might be a suitable MWAIT implementation. It's virt, it sucks anyway :-)