Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp2451637ybh; Mon, 9 Mar 2020 06:13:37 -0700 (PDT) X-Google-Smtp-Source: ADFU+vscUkgUeEzi7QmQ+PikdA+TsmhwUwaouVKMbDHM7DAYXDjdgabIweBpF6a46vprG8eOA0U8 X-Received: by 2002:a9d:554c:: with SMTP id h12mr13441805oti.16.1583759617082; Mon, 09 Mar 2020 06:13:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583759617; cv=none; d=google.com; s=arc-20160816; b=h6ah61vj5vmQ3lGQIPzFT6d99uSvfMvtJENsPui4+ZFUQt62siBuctYirJOIqBj7Jt HW998ViowtH5LyKb/g5nDGwA1MSqbz1K73xh9PMzn0KqUj02j2L3d4XqMtLryrXOPiQ5 Er+i7pt8y02dItY5sxNQkwpc8ANuURs6Mol9DFcUY2JUB6CGzF2rZ+eZe26OOCy7Re3M b3jH1QAIPbgkFDiTLINSHTOxtpiwXhACHuikKBEKtenUmf2PFX7NNjqVpGg5VHGoEbSr YVFTqdXwemUyRvg7Od6tXb+2pFLbwqIn7q5A+W1GNpXUE3AIBN0oaTft/dEnIG/L30eV I1Dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=EkCa0HZ1JgQ0m3hlKreC9GLgOBunF9xMamm6M4sA9Z4=; b=gXpt2GZiWEXXg7f5t+H3VE7Fsdluyil4ax7Q0gg0BqeLnW3H1YfdJKSV+0WpKTqlT5 q1mWCldqIt1mH/26PcqbYdFlfFNyvP+p0FO3ISJVxNwhpf1WpEOKOeaJ8XrxvpGvmT0S E8asPJAcMiX2tQnGbj2NiPt7sJx9ptBNDumAMOPIhrzqRurJC/cNVL2eeQQsYP7C1fws 6kNVOnxFj1xie8Pl8emKB5EIIqolxBzqj4vxYM37De5MBvcSH5GRPSKKZlBXHsPA2w18 53n23fRXkjgCcRdGXLPvY4ObaPvOflH3cR5AQ5U0qXsmYbhXRRrYStKc8sTAwN81b4gO O+eQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k7si1143519otn.251.2020.03.09.06.13.23; Mon, 09 Mar 2020 06:13:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726523AbgCINMs (ORCPT + 99 others); Mon, 9 Mar 2020 09:12:48 -0400 Received: from mga04.intel.com ([192.55.52.120]:23411 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725956AbgCINMs (ORCPT ); Mon, 9 Mar 2020 09:12:48 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Mar 2020 06:12:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,533,1574150400"; d="scan'208";a="442740252" Received: from linux.intel.com ([10.54.29.200]) by fmsmga006.fm.intel.com with ESMTP; 09 Mar 2020 06:12:46 -0700 Received: from [10.251.21.146] (kliang2-mobl.ccr.corp.intel.com [10.251.21.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by linux.intel.com (Postfix) with ESMTPS id 036345802A3; Mon, 9 Mar 2020 06:12:43 -0700 (PDT) Subject: Re: [PATCH v1 01/11] perf/x86/core: Support KVM to assign a dedicated counter for guest PEBS To: Peter Zijlstra Cc: Luwei Kang , x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, mingo@redhat.com, acme@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@redhat.com, namhyung@kernel.org, tglx@linutronix.de, bp@alien8.de, hpa@zytor.com, pbonzini@redhat.com, sean.j.christopherson@intel.com, vkuznets@redhat.com, wanpengli@tencent.com, jmattson@google.com, joro@8bytes.org, pawan.kumar.gupta@linux.intel.com, ak@linux.intel.com, thomas.lendacky@amd.com, fenghua.yu@intel.com, like.xu@linux.intel.com References: <1583431025-19802-1-git-send-email-luwei.kang@intel.com> <1583431025-19802-2-git-send-email-luwei.kang@intel.com> <20200306135317.GD12561@hirez.programming.kicks-ass.net> <20200309100443.GG12561@hirez.programming.kicks-ass.net> From: "Liang, Kan" Message-ID: <97ce1ba4-d75a-8db2-ea2f-7d334942b4e6@linux.intel.com> Date: Mon, 9 Mar 2020 09:12:42 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <20200309100443.GG12561@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/9/2020 6:04 AM, Peter Zijlstra wrote: > On Fri, Mar 06, 2020 at 09:42:47AM -0500, Liang, Kan wrote: >> >> >> On 3/6/2020 8:53 AM, Peter Zijlstra wrote: >>> On Fri, Mar 06, 2020 at 01:56:55AM +0800, Luwei Kang wrote: >>>> From: Kan Liang >>>> >>>> The PEBS event created by host needs to be assigned specific counters >>>> requested by the guest, which means the guest and host counter indexes >>>> have to be the same or fail to create. This is needed because PEBS leaks >>>> counter indexes into the guest. Otherwise, the guest driver will be >>>> confused by the counter indexes in the status field of the PEBS record. >>>> >>>> A guest_dedicated_idx field is added to indicate the counter index >>>> specifically requested by KVM. The dedicated event constraints would >>>> constrain the counter in the host to the same numbered counter in guest. >>>> >>>> A intel_ctrl_guest_dedicated_mask field is added to indicate the enabled >>>> counters for guest PEBS events. The IA32_PEBS_ENABLE MSR will be switched >>>> during the VMX transitions if intel_ctrl_guest_owned is set. >>>> >>> >>>> + /* the guest specified counter index of KVM owned event, e.g PEBS */ >>>> + int guest_dedicated_idx; >>> >>> We've always objected to guest 'owned' counters, they destroy scheduling >>> freedom. Why are you expecting that to be any different this time? >>> >> >> The new proposal tries to 'own' a counter by setting the event constraint. >> It doesn't stop other events using the counter. >> If there is high priority event which requires the same counter, scheduler >> can still reject the request from KVM. >> I don't think it destroys the scheduling freedom this time. > > Suppose your KVM thing claims counter 0/2 (ICL/SKL) for some random PEBS > event, and then the host wants to use PREC_DIST.. Then one of them will > be screwed for no reason what so ever. > The multiplexing should be triggered. For host, if both user A and user B requires PREC_DIST, the multiplexing should be triggered for them. Now, the user B is KVM. I don't think there is difference. The multiplexing should still be triggered. Why it is screwed? > How is that not destroying scheduling freedom? Any other situation we'd > have moved the !PREC_DIST PEBS event to another counter. > All counters are equivalent for them. It doesn't matter if we move it to another counter. There is no impact for the user. In the new proposal, KVM user is treated the same as other host events with event constraint. The scheduler is free to choose whether or not to assign a counter for it. Thanks, Kan