Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp3370845pxb; Thu, 10 Feb 2022 20:13:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJzTIqRRuvu0ousno9HtC2G67/qK7bY5I0MzziwkVhK+cTJwS2DNKDhjxuuVKXXdflExdM+N X-Received: by 2002:aa7:c2d8:: with SMTP id m24mr11779588edp.435.1644552810607; Thu, 10 Feb 2022 20:13:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644552810; cv=none; d=google.com; s=arc-20160816; b=RxIABYtSJ67m+u8n6NNpwx686poAUr+GmsLWew9DKjtarj0bnGR/T00MakLRKD8B6n az9IjV9WG/NLakSmsxlT1EHNw+z6Y/ez978MgFzauNACve+/8/NhzNI1ug0StL7BWAGo GW6trWhmnTDmMCAzuUr9/UQ2aH/tGvQ+ZfQB6WPZItBkyZpndTIYaUkKhRdec+8natRf 64Xrhm97JQhiK4az1eKb7qfOUKCk/z0/1maL1x+ZVUvOPhyfDPUErU2rYvg5vIHgqYEk G2Erbwompyt3QM+cAt9GNZfAAhzvW1x89Ghw8qm8CNdP4GW5e08u+9Iz8lucnX0FdZdZ nFdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=/lyjd8DzHr1ZFN7n5g+6x/ewHBndnhwtxkDtCmmE8GE=; b=My54mYdiyBeZa7BJvFMOwsY5G9wKVQmuiQBJfrsTlzQO5e7DzDzs8LfU/rxn+VV/Sy /2spdMPgQnoy7u6RQjs5QdM6TBIyt8bENNQVA10LXyb/Qu+Y88GR3L4iTZAm+srS7/Zt j93SRVS7hHXSxsIRCmF1dKlsuEgYunjM0qYcnD0F+lJitP72YtnxiRKq0Smleu/DHmDI ZH7b3kwEa3ZZLAbH+IlMfLzlHpvDJa7xwbEoN/gi9oq6vou42K6pemf8jW3WO1KZqlxm tI+xdY6pl0X9VDMnr78t+y4lNDhOjZSiJ+vY35dAfcxJit/wWGHWjyXTShsw4plPmVM/ Qa4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=L6ZgFT9W; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id js12si16914077ejc.1006.2022.02.10.20.13.03; Thu, 10 Feb 2022 20:13:30 -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=@gmail.com header.s=20210112 header.b=L6ZgFT9W; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241437AbiBJMJG (ORCPT + 99 others); Thu, 10 Feb 2022 07:09:06 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:59262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232947AbiBJMJD (ORCPT ); Thu, 10 Feb 2022 07:09:03 -0500 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A28A1098; Thu, 10 Feb 2022 04:09:05 -0800 (PST) Received: by mail-pf1-x429.google.com with SMTP id r19so9845806pfh.6; Thu, 10 Feb 2022 04:09:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:organization:in-reply-to :content-transfer-encoding; bh=/lyjd8DzHr1ZFN7n5g+6x/ewHBndnhwtxkDtCmmE8GE=; b=L6ZgFT9WhpOELHm/6zoM1fuDCVfXhqfBdI4ku2SSpeiBRDXiqcQ9mPNlvlKG3OjlVg okKbXPgxLnm8hwyzp0TAny+vACb58oxfjHsuy9TAAtr5BLi8SAS9ogw3CrJZR4Dqp/6E I8led7uMPtn0I/PV/MRTWe9Vykr96+LJucrQ+n58/JohwpIhrt5Amig8oc18y+HCUHLs aJaUPf8AUKhi39Z6I1ITdB34gX1RK++aIbqYishbcwYWTKFxUXC3q1DHgtrLdh0gXVxz g7RD3CaCV3re5K49OJ8tjQCnFRWUPTPLKTqR/P7Z3LlkS/7+OI6zcWx/uT3v28rz/t7C n7wQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:organization:in-reply-to :content-transfer-encoding; bh=/lyjd8DzHr1ZFN7n5g+6x/ewHBndnhwtxkDtCmmE8GE=; b=KwhY+WyLNSx/9tt3Xd1SftRaSP78pd8rY0M1Fe0Jd2XVPVvyrzhDAalcQcaI7j5Rky BnAXbvbXiOfPkM0JYknukiZRsQK1wUeiopVPkbUSuNpYBaXwRvkFhaW+ZWcdPGI4O0/l ZGEX6chD2KavHnsSuNQCtaF6T74iwruyZAN/SMRl92G03xG1DnIQ/uJ6qOPkJ3/hmrjU FSF/8XcEYLKgvyRAd9gNlam255i/4zeMjr/GtaXm7ClmC8H3HOihDMhpy8xIR+E2igbA BEerLZ+KWovCGUnWbMIUY7UHkqCIBP1tuvNeij0uzl/yznvFt6hv+D8Wv0dOB0K+X6Lz Ip3g== X-Gm-Message-State: AOAM533DvNS8QEzlYFMqc3DX315SDC5HslkTNzzMhiBF63mdnbih4/Pk FhVL3vgbZWC7BAADOPYytso= X-Received: by 2002:a62:506:: with SMTP id 6mr7149948pff.86.1644494944656; Thu, 10 Feb 2022 04:09:04 -0800 (PST) Received: from [192.168.255.10] ([103.7.29.32]) by smtp.gmail.com with ESMTPSA id h6sm25123612pfk.110.2022.02.10.04.09.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 10 Feb 2022 04:09:04 -0800 (PST) Message-ID: <39b64c56-bc8d-272d-da92-5aa29e54cdaf@gmail.com> Date: Thu, 10 Feb 2022 20:08:52 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.6.0 Subject: Re: KVM: x86: Reconsider the current approach of vPMU Content-Language: en-US To: Sean Christopherson , David Dunn Cc: Jim Mattson , Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Stephane Eranian , Peter Zijlstra 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> From: Like Xu Organization: Tencent In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 10/2/2022 5:00 am, Sean Christopherson wrote: > On Wed, Feb 09, 2022, Peter Zijlstra wrote: >> On Wed, Feb 09, 2022 at 04:10:48PM +0800, Like Xu wrote: >>> On 3/2/2022 6:35 am, Jim Mattson wrote: >>>> 3) TDX is going to pull the rug out from under us anyway. When the TDX >>>> module usurps control of the PMU, any active host counters are going >>>> to stop counting. We are going to need a way of telling the host perf >>> >>> I presume that performance counters data of TDX guest is isolated for host, >>> and host counters (from host perf agent) will not stop and keep counting >>> only for TDX guests in debug mode. >> >> Right, lots of people like profiling guests from the host. That allows >> including all the other virt gunk that supports the guest. We (real-world production environments) have a number of PMU use cases (system-wide or zoomed in on each guest) to characterize different guests on the host. >> >> 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. How do we balance the performance data collection needs of the 'hypervisor user space' and the 'system-wide profiler user space' ? > not to let the guest steal the PMU at will. Off by default, certain capabilities > required, etc... are all completely ok and desired, e.g. we also have use cases > where we don't want to let the guest touch the PMU. One ideological hurdle here (between upstream and vendor-defined Linux) is whether we let the host's perf be the final arbiter of PMU resource allocation, rather than not being able to recycle this resource once it has been dispatched or gifted to the (TDX or normal) guests. > > David's response in the original thread[*] explains things far better than I can do. > > [*] https://lore.kernel.org/all/CABOYuvbPL0DeEgV4gsC+v786xfBAo3T6+7XQr7cVVzbaoFoEAg@mail.gmail.com