Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp1095731rdg; Fri, 13 Oct 2023 10:03:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGliwT0sFWkM4dKhnX44Tx2v+CCuTw75e5RluokKjpB1sD6QPZOCpBTIQ0QjLsJvfVqlNBR X-Received: by 2002:a17:90a:191:b0:27d:1b37:8bfd with SMTP id 17-20020a17090a019100b0027d1b378bfdmr6028080pjc.4.1697216579951; Fri, 13 Oct 2023 10:02:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697216579; cv=none; d=google.com; s=arc-20160816; b=bjXyP+5bqF+qCvkvzuxcEsVhEE6gcRonCKNfCATsohUCSyQi1lsxDGLG891kmtqOxP CWU1oQ6xTwTWszZ3uGY/6M0qG1sGiFUC+1SNxe8cPfkWLgN3S5zAfCFTbDatllt/Skyq LuLv1YRsHgfwyrnnTo3ey3wpJaOX3XJW8fgqF6jMVHI0NCadyrfu5XqHz+lVaQXza0WD cBZDMxVJ+1S29y4dXFUHzmLdHXMbWGsDCCXnS3xUlgFNLOZafb8XPX3lqrd7IAFQYSgL zPkG2b5bjF9qWlgX2qqlROJgnn+Uta8luhzQn65hLwmAXd1HQb0ItA6iRWgcZEIbgq9v HYMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=jb2BclJUU7GtSLFO/2WDLc/5XqeRqydzOe9LedmH49A=; fh=QcHpCMPFKN5wIXcTs8y74C+z931WJJOCc7NIoE9PhW8=; b=HC1Gqe4U1zeItTqd3W+1xxXXAOBgxlniuGJF3/RiAJc5OIkE57LWoL3IL+RZejTKzr BPo8vNJBoGrpe/QIZX6R04c93mqz/iqG0nbXzwZSHICZmid3ryP39snYuYqjScGUGjFd pBhlBQhcqapwf/tboujlwvAzqkg3VXkxac0W0i1pn0p6cu0B68qkT/Eg88EVgERY90W0 BJOp4dDFjSkGcgFfwDxPqawVTM37NjQgMeS7jG1hzuHJml63WbFBM+NnhV8YwKGjznPT SOsTQm8nHwm9jTcMpQatU2/PY68FSeZSvlqIfjC2T/tSi5HXbgHHZ+iK5M6NlAHez9f8 GV0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=yMGt3yxe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id ay24-20020a17090b031800b00276b87c8b8esi442377pjb.59.2023.10.13.10.02.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 10:02:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=yMGt3yxe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id A589782D1C2B; Fri, 13 Oct 2023 10:02:57 -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 S229891AbjJMRCu (ORCPT + 99 others); Fri, 13 Oct 2023 13:02:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229683AbjJMRCt (ORCPT ); Fri, 13 Oct 2023 13:02:49 -0400 Received: from mail-pl1-x64a.google.com (mail-pl1-x64a.google.com [IPv6:2607:f8b0:4864:20::64a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6ED6CA9 for ; Fri, 13 Oct 2023 10:02:44 -0700 (PDT) Received: by mail-pl1-x64a.google.com with SMTP id d9443c01a7336-1c9c939cc94so20760445ad.1 for ; Fri, 13 Oct 2023 10:02:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1697216564; x=1697821364; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=jb2BclJUU7GtSLFO/2WDLc/5XqeRqydzOe9LedmH49A=; b=yMGt3yxemVAgOP5eqHkJfULa0vqhmzwzcWOV6aoVaAnScuQwaGifzk/gG0O8BlmVuz 4+7gXkG8ZLohgyc2XB/Wv5BuLT2Obk2w4Lc7Hl/oZOKk0GteJN/0JULJejy6xbnJhDmU 6qrZsLlmxpxv5nuYUDaAdt3s+pRX7mrq6JEwM5JjZNQdwP4u9eOz71b89XvlxGXxsE/7 jz+KhlhPDeNWzouC/VoEoyeIwLS0Hb2nJpCxAPfYhB1i1/ho/eI8+TyY+O3mXzVqKdJo 6wiB6INFSDoK+NRwaZoIBTEBJ8ALpOP3+VSWK+B+RMDK22XkuHG7lQHn7/aiPBgpRXTv q8zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697216564; x=1697821364; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=jb2BclJUU7GtSLFO/2WDLc/5XqeRqydzOe9LedmH49A=; b=waJ6KSWETtTMuBdzaFrTLnenPBFypF5cOxYEdyRQ7LCLxTOd3VnfYo/53ptUKDSMve IrKe2/DpANnJm/RR3V0XUED1M87iKNMvwIBXjevKmCp5tpVgX3QpNNGmNle96is42f0l saG8OHXodiZ7J55LouOJxUZBme2IW7Fofpr9DMuCVrBxJnopcZwD6H0MqrQsoOoYdtuH QP2YqTJaqC6c4oyvXUAjvR727tts2P91Z37L/ZaQujz7cYbv4k7EaG+MMLWRqrAr6PgN 7cZeHk6ZL2qBKp06/YnzwTryybkD/cxfMyRuC4DmCmQj16S39gPVVFMtFJ1LJbJdueZp 0Wug== X-Gm-Message-State: AOJu0YzqMtoH73jHDRyIqXZAwByXETVQOUvvACJTapliSHv5c+y1j+xU gID+lEE6d51LYMaBPZjfBEiWQol3J70= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:903:189:b0:1c8:922e:e018 with SMTP id z9-20020a170903018900b001c8922ee018mr398841plg.13.1697216563840; Fri, 13 Oct 2023 10:02:43 -0700 (PDT) Date: Fri, 13 Oct 2023 10:02:42 -0700 In-Reply-To: <20231011142003.GF19999@noisy.programming.kicks-ass.net> Mime-Version: 1.0 References: <20231002204017.GB27267@noisy.programming.kicks-ass.net> <20231003081616.GE27267@noisy.programming.kicks-ass.net> <20231004112152.GA5947@noisy.programming.kicks-ass.net> <20231011142003.GF19999@noisy.programming.kicks-ass.net> Message-ID: Subject: Re: [Patch v4 07/13] perf/x86: Add constraint for guest perf metrics event From: Sean Christopherson To: Peter Zijlstra 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 Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL 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]); Fri, 13 Oct 2023 10:02:57 -0700 (PDT) On Wed, Oct 11, 2023, Peter Zijlstra wrote: > 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? Yeah, for sure.