Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2537531rdb; Wed, 4 Oct 2023 04:33:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFzt6H4CruOcKzWRF34T+ox4X23hbP/M3PzJZKJDh+wwNa+/tJ5gtoH/nMubur7bMTzKl3Y X-Received: by 2002:a17:902:f546:b0:1bb:e74b:39ff with SMTP id h6-20020a170902f54600b001bbe74b39ffmr2546225plf.0.1696419206137; Wed, 04 Oct 2023 04:33:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696419206; cv=none; d=google.com; s=arc-20160816; b=klmB0VoiXGkZgDiL3++ozPCkWvLVqmiLgRQnU/sXpnokGVUFcx86OQU43d3fE6za25 TwHnI4Lr0IiIIMbxMjxTwTfuZXNeFc7B3rF5zQVyjpBp67U9+nuKLRcF5ILQ6M/6tyfM +oV3iq8XNysHIb1xF1G+++nqvfZFfOyRwTRhu8Ca3aBhnVFrDezUeGikqQGiVBHmlqBl cjASV/jii/UL6m2MsHujXrnm+sOIEu3zPUqQUIa9TX7UxGRco86ktfilHl/FV9Ha++Hn f7/ZnHZItRrcP8eFCE4lPV14QhFmDemAfPDsbh69e0m3u+p7nddLXLGdYZjoXK5hxpMV gKDA== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=LgTiEbkbWU/3dLeZ3ndl5aQ62XZwVSgJEp3sPp3BvRc=; fh=qsSs2DMOSUvxC4VnvK1ePcz+PlKRBjJdMFxREHtRxd0=; b=ktq94AlQHT1GIlL6Vw5iEKGVA0phT5JLbvGtETA4V4afxj/K3kv68zh872AXaZwDBW QddinK8jF3XDuEHHyTy0gV7ZVVImDVDo8LutOvIQkB7Ms3HnF47dna3NrrY2B2hBauG4 X7IV1JFqh6itAcjP25PT7uGBTEveoUFYcIpVOpgxeZ5HLhkon8yo4w+X0jwaY6VY6Dza liNeuhNOKNHJFGtaSbdJxf7nh2lSuUUkLzpfoM4JcgeKbx+U8xSVKdVal6oeGAMI2UiN CUM6BquFvQOoLVH+LGsAR7DVKHuswppK6i58E0Bsy4h2ZoJgW++CkDfvAnBe4sIn3XfR odMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=IRxNn1Uq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id t10-20020a1709027fca00b001bdebddc2f7si3496448plb.257.2023.10.04.04.33.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 04:33:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=IRxNn1Uq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 4F38B81A0C2E; Wed, 4 Oct 2023 04:33:22 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242241AbjJDLdR (ORCPT + 99 others); Wed, 4 Oct 2023 07:33:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232919AbjJDLdQ (ORCPT ); Wed, 4 Oct 2023 07:33:16 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47ED2A7; Wed, 4 Oct 2023 04:33:12 -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-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=LgTiEbkbWU/3dLeZ3ndl5aQ62XZwVSgJEp3sPp3BvRc=; b=IRxNn1UqLy+vTJM/bW1VgjMao3 NvMCUspVk2mwGp0Ab0bQosB3DQJivBzggsXhKjIaiH871I0oHLkonKlLszjs14ZxPliBceljl4Z42 xeb1Qyka3GIacctWSZmYGdK5PaCP94P2P2xFfatjLAeOAv8v8du001Uu1u8za51Fm/6BvEVUarV7p JtYfXvEwkTjvYnGPpOLM/bt9B68DXWSgVZqZUNGf83+Tfv6/hfwS4OiHlP7vY3S8tiJOL6WLLll70 l0fwyN3Wrs5xttrnqrH0z3t/J95bWKm0x6G8GbrjxjMhDLdrvgLpCAy60o76REIr5uaM8Z0kPIRqS +4hI4UYA==; 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 1qo07W-0037n5-SQ; Wed, 04 Oct 2023 11:32:50 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 5CE08300392; Wed, 4 Oct 2023 13:32:50 +0200 (CEST) Date: Wed, 4 Oct 2023 13:32:50 +0200 From: Peter Zijlstra To: Jim Mattson Cc: Sean Christopherson , Ingo Molnar , Dapeng Mi , Paolo Bonzini , Arnaldo Carvalho de Melo , Kan Liang , Like Xu , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , kvm@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Zhenyu Wang , Zhang Xiong , Lv Zhiyuan , Yang Weijiang , Dapeng Mi , David Dunn , Mingwei Zhang , Thomas Gleixner Subject: Re: [Patch v4 07/13] perf/x86: Add constraint for guest perf metrics event Message-ID: <20231004113250.GB5947@noisy.programming.kicks-ass.net> References: <20230929115344.GE6282@noisy.programming.kicks-ass.net> <20231002115718.GB13957@noisy.programming.kicks-ass.net> <20231002204017.GB27267@noisy.programming.kicks-ass.net> <20231003081616.GE27267@noisy.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Wed, 04 Oct 2023 04:33:22 -0700 (PDT) On Tue, Oct 03, 2023 at 11:21:46AM -0700, Jim Mattson wrote: > On Tue, Oct 3, 2023 at 8:23 AM Sean Christopherson wrote: > > > Since you steal the whole PMU, can't you re-route the PMI to something > > > that's virt friendly too? > > > > Hmm, actually, we probably could. It would require modifying the host's APIC_LVTPC > > entry when context switching the PMU, e.g. to replace the NMI with a dedicated IRQ > > vector. As gross as that sounds, it might actually be cleaner overall than > > deciphering whether an NMI belongs to the host or guest, and it would almost > > certainly yield lower latency for guest PMIs. > > Ugh. Can't KVM just install its own NMI handler? Either way, it's > possible for late PMIs to arrive in the wrong context. I don't think you realize what a horrible trainwreck the NMI handler is. Every handler has to be able to determine if the NMI is theirs to handle. If we go do this whole swizzle thing we must find a sequence of PMU 'instructions' that syncs against the PMI, because otherwise we're going to loose PMIs and that's going to be a *TON* of pain. I'll put it on the agenda for the next time I talk with the hardware folks. But IIRC the AMD thing is *much* worse in this regards than the Intel one.