Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp3068921pxb; Thu, 10 Feb 2022 11:29:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJxeMinfyvm5VcJ6TOesgAuD2310YxP7N6iHWDLRZVlkNJh+qrrlZzXlM2quO1UbdPgo/aC+ X-Received: by 2002:a05:6a00:1253:: with SMTP id u19mr9036378pfi.8.1644521371575; Thu, 10 Feb 2022 11:29:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644521371; cv=none; d=google.com; s=arc-20160816; b=dtgwBiBhzvfqxzKmUM4cOps2Vxu7c/M8LST1JxCBnW2mLTSDlmjPiu2lleD3WWbtX1 N5B0EgzPWEPNROUbC8U44ZGekB7JZp2V4oTmDSGQRCzR8gX3m0YB4W3ifSippsvV65qI YUNw/a1BjSZRS4vpK5z8qK6wxgyS9YZZCt27si0Jx7Edk9sSv1k0nvQytmw3K2Dolowj ECfFtTHM82DKytxKzDgc2Qq2UkwR1a2OH2H4DOSNbkXptw0zQ5G9mlRyK74mShBRF42j 5NNsk5h+PB1Hq8AcfIt4mE3kA7Yp/gsqrcKTjlkTQpxXZMI+JrvPKVoMpXqz5aXPrdGX VrTA== 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=1lVmIdPT7KTxg61LkVafGnAu8y+soi2FYSLquMI2dHQ=; b=TfClwIOM2IqkUvej5DfJJOO+ZRqB7yMIRPF04nCKZkHm4/Pi1O5FqDdhRbRxHznuLJ Rpr3X2h1wYitu17fyT8eVLpkXxpbE8zDWGJEsPe6kuq29u9xCIM4Xykd6XAA2V6LJARt rvO33OBjxK0sl9CU3YY/oR4LQfB/b5io64cxp7cncf/xpvCGwEEpLwvxYYwx9y9rCzyy 0SaHYD+oYnZ6cMiC9JtHe+ZmKHAfL/f9mNY7E7oeVX3zc778T736zzjWWnZRF0AuGcdx IAgsdVJ87ilHWtGmtuJwwHzrwW6Et+bkQQJ6LLGy/XQSXLoHibCMebqgjUdIQeZcPsLx Efeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=V7JKyk1u; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w70si18756668pgd.802.2022.02.10.11.29.19; Thu, 10 Feb 2022 11:29:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=V7JKyk1u; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245055AbiBJRMR (ORCPT + 99 others); Thu, 10 Feb 2022 12:12:17 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:58542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236851AbiBJRMQ (ORCPT ); Thu, 10 Feb 2022 12:12:16 -0500 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3668E6D for ; Thu, 10 Feb 2022 09:12:16 -0800 (PST) Received: by mail-pf1-x42c.google.com with SMTP id i6so9473683pfc.9 for ; Thu, 10 Feb 2022 09:12:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=1lVmIdPT7KTxg61LkVafGnAu8y+soi2FYSLquMI2dHQ=; b=V7JKyk1udAsyqRsAu366UMQjbG28qOhKcaKeq4l10ARRqPSsh+jXlPKbzBOS6Xi9Wr yxuYaCadvljSPqOWiwC38Ocpi+nMAZHSW3nQvRE0sXwtlFXxaKykVie4d4Q8ouhStvtO 1iAu6Xtf3OpaZYuECrk/FC3w30aid9ax/yug1flPF1mlC9nzje/GF13WTmwmZeIJ0cjF vGxDwNR7WAkosoOxxuWfR4oUY+jBym15Os/6V6KykL5QSG2bhe4fsYBK2P7fC5QXhqll IpWFksA7iCtkNzE8pG0Ce1hnfWKDtQrF63p6hECr3x5NpMcERD/Vk6I/vRpo+FQxU5UG Gkcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=1lVmIdPT7KTxg61LkVafGnAu8y+soi2FYSLquMI2dHQ=; b=R+/9wYmt6Is0XJgfU2Hmq+q7KA/R1pOOEqV+pRhDZR+2FMfn5/GXiuXeNOPfAUrrHC G5xnJ1FoXq7g4bwz8TvXT4M47R51WbEB5szvgQoGhqQjgBMyu84mYrIlmmL4KHFDnvcJ u6CrZgkw+HKVJDSoE2PDYm5ecnabTieuKm28Cdf2zQcQmzsmMqOk732VmuqnBibSrhw4 RrhBkWsSQhmZFlCo/nOvDjLuKeadmLBvZgvrUTbbh2qe7bc1KPPB5zzQbT/QnCTlJmQA s1fX5AGo3GqMjWi//APt3/HF6ycrK1OfVNNdkSMZYGJ+EJ/PmIu/NP/fVK3M/WO6NqRf Aycg== X-Gm-Message-State: AOAM532wT1/LiXQnlHnaOl9iJeXVlnSiPhojsYwKJtcCIxdbxqFw1Kif tbGGAl+myomqJUdR6M/eywJkCw== X-Received: by 2002:a63:5503:: with SMTP id j3mr3148876pgb.378.1644513136146; Thu, 10 Feb 2022 09:12:16 -0800 (PST) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id l12sm25221731pfc.182.2022.02.10.09.12.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 09:12:15 -0800 (PST) Date: Thu, 10 Feb 2022 17:12:11 +0000 From: Sean Christopherson To: Like Xu Cc: David Dunn , Jim Mattson , Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Stephane Eranian , Peter Zijlstra Subject: Re: KVM: x86: Reconsider the current approach of vPMU Message-ID: References: <20220117085307.93030-1-likexu@tencent.com> <20220117085307.93030-3-likexu@tencent.com> <20220202144308.GB20638@worktop.programming.kicks-ass.net> <2db2ebbe-e552-b974-fc77-870d958465ba@gmail.com> <39b64c56-bc8d-272d-da92-5aa29e54cdaf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <39b64c56-bc8d-272d-da92-5aa29e54cdaf@gmail.com> X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 10, 2022, Like Xu wrote: > On 10/2/2022 5:00 am, Sean Christopherson wrote: > > On Wed, Feb 09, 2022, Peter Zijlstra wrote: > > > Guests must not unilaterally steal the PMU. > > > > The proposal is to add an option to allow userspace to gift the PMU to the guest, > > Please define the verb "gift" in more details. Add a knob that allows host userspace to control toggle between host perf having sole ownership of the PMU, versus ownership of the PMU being "gifted" to KVM guests upon VM-Entry and returned back to the host at VM-Exit. IIUC, it's the same idea as PT's PT_MODE_HOST_GUEST mode, just applied to the PMU. By default, the host would have sole ownership, and access to the knob would be restricted appropriately. KVM would disallow creation any VM that requires joint ownership, e.g. launching a TDX guest would require the knob to be enabled. > How do we balance the performance data collection needs of the > 'hypervisor user space' and the 'system-wide profiler user space' ? If host userspace enables the knob and transitions into a joint ownership mode, then host userspace is explicitly acknowledging that it will no longer be able to profile KVM guests. Balancing between host and guest then gets factored into VM placement, e.g. VMs that need or are paying for access to the PMU can only land on systems that are configured for joint ownership. If profiling the guest from the host is important, then place those guests only on hosts with sole ownership.