Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp852298rdg; Wed, 11 Oct 2023 07:21:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEnGlE1KDs2lpG8YSSw7VQMChO4SF394uN+0mwkZussIvKUOBa4UzWyq5mnCuu43huI8dTD X-Received: by 2002:a05:6a00:14ce:b0:68f:cdb8:ae33 with SMTP id w14-20020a056a0014ce00b0068fcdb8ae33mr30699511pfu.10.1697034062421; Wed, 11 Oct 2023 07:21:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697034062; cv=none; d=google.com; s=arc-20160816; b=rQ13P974Nq6k6nfmaUFQ04J1CisOaJsD0GrQifkK+DarQmUNpHiMu1KRzHOxIjbjR+ AVRr4lnX3VeShkFWp5IqNOggTRsupnmW6Bv8C3W1ZQ7ce/fZE4M39UG4H0njYG/nDwNn Yz41ow3Pt8tcqd3x+ILhGlCcXBr5ZT/hr+NFzj7XYR2bjnIOru115Gc+H8vpxOZtuTWo FIT+ea7jt2CPkMLs79deDaF2Odt1DhLaU3A0piclptUJA8BzsqLMt1W2zW6GWYww9TeF /1Vx4Rc43/ebLCQ2kPbYq+/2jFWr57UR5/2dPj8aY2QafgYUrc/CdCmnmqvUdbTBfLno lGoQ== 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=giWFgglIwvl79cFsu43H0+4WKJFrU3jVnmUoXzCqgBA=; fh=G7xIlxeEPgHHIZZka0W+xRxbh5KUW+GCJLe2eB0d0o0=; b=JsFVmv+Ltf7z7kSa/Ks//mDqCEJp9FrvlkPRp43kiVYnw5HrvFYdUKxxfDTXlhNwxs 0DfSaloWGW7XVZ63/x1LZLe5uJEsYGbDes7WChEcexH2I9YrBgBsc5+T/vGLClCWGnaY i43B1Dkxj7wc5SpcLd2R/24V2gcZPuLcl1PDJla7lVDwcZvmapJOATqLVthRWSiLrWu2 uZ5XHYI5IX7YefWUoGpqPfr4rLzgi+gVGjhixlc9HzMiDQ0AtqhyD33C5+NTVWbgySda QORgb51VDD2sw9wTYjJb936m5a2Z0LcDCpeIfuwarAq8QuRzuGVn7INjvQFVI8jrcEXM OdWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=BhimHCpi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id d5-20020a056a00244500b0068fce0c7193si12496593pfj.282.2023.10.11.07.21.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 07:21:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=BhimHCpi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id 7C8E380D6534; Wed, 11 Oct 2023 07:20:37 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234906AbjJKOUY (ORCPT + 99 others); Wed, 11 Oct 2023 10:20:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232420AbjJKOUX (ORCPT ); Wed, 11 Oct 2023 10:20:23 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90E60A4; Wed, 11 Oct 2023 07:20:21 -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=giWFgglIwvl79cFsu43H0+4WKJFrU3jVnmUoXzCqgBA=; b=BhimHCpistBqcNILTpqmB95VgU 7PmFSmnPRvQQyRpFA0g7FVo0LbKL5mLZwxk/6dbjL+y/CSOGsKpPgP9QBf1R85Lcb7iXfpVCC3p9j uQUMiBKlRc+vbq1Fktephy4/45HG9+hQRSjxyNzaWWPv4mBrSIXcl8AqE+imo/sUd6Oia6/wG7jNQ NuVuioo4VIDTezY7pjFo+uV6eqmRDBsi8kf3JlR9roMTFRFib4KOxUv6a04qCfR0BuytGa6g7yzn3 0uyvgrPPgjUp3HzKHrRJ4vn9efOIJnnevO4/9BMPcATcav/BS8x5jOrtQNUy6fy3BTyjBA0+5iOwe oBwI4MVg==; 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 1qqa4C-00BCzx-9t; Wed, 11 Oct 2023 14:20:04 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id EE6F130036C; Wed, 11 Oct 2023 16:20:03 +0200 (CEST) Date: Wed, 11 Oct 2023 16:20:03 +0200 From: Peter Zijlstra To: Sean Christopherson Cc: Mingwei Zhang , 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 , Jim Mattson , David Dunn , Thomas Gleixner Subject: Re: [Patch v4 07/13] perf/x86: Add constraint for guest perf metrics event Message-ID: <20231011142003.GF19999@noisy.programming.kicks-ass.net> References: <20231002115718.GB13957@noisy.programming.kicks-ass.net> <20231002204017.GB27267@noisy.programming.kicks-ass.net> <20231003081616.GE27267@noisy.programming.kicks-ass.net> <20231004112152.GA5947@noisy.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Wed, 11 Oct 2023 07:20:37 -0700 (PDT) X-Spam-Level: ** On Wed, Oct 04, 2023 at 02:50:46PM -0700, Sean Christopherson wrote: > Thinking about this more, what if we do a blend of KVM's FPU swapping and debug > register swapping? > > A. Load guest PMU state in vcpu_enter_guest() after IRQs are disabled > B. Put guest PMU state (and load host state) in vcpu_enter_guest() before IRQs > are enabled, *if and only if* the current CPU has one or perf events that > wants to use the hardware PMU > C. Put guest PMU state at vcpu_put() > D. Add a perf callback that is invoked from IRQ context when perf wants to > configure a new PMU-based events, *before* actually programming the MSRs, > and have KVM's callback put the guest PMU state > No real objection, but I would suggest arriving at that solution by first building the simple-stupid thing and then making it more complicated in additinoal patches. Hmm?