Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp5510393ybf; Thu, 5 Mar 2020 02:00:11 -0800 (PST) X-Google-Smtp-Source: ADFU+vuBbk3vgpZrPGSypZG6hPBiMf6WzRKOgsOna3NDpsDno9Zuw11ZHB32UmqVDSTobWNZwWg6 X-Received: by 2002:a9d:554c:: with SMTP id h12mr3930561oti.16.1583402411838; Thu, 05 Mar 2020 02:00:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583402411; cv=none; d=google.com; s=arc-20160816; b=mdOebg2KbopAOVthuyQ3ujvKxM0x6sXYCis0kgCfRopMtlsT/HvxEX8zwUgXjHDfGj /QDuoQiOzIyj21CUYZNIhswP69ef+cldxKps6bUe+G19XNEQm22w9DOzqXja0oVOpk4p HY5R4Uhkz3SgqhX3BvlvmzbVbE7zqpsocQP8ZQ6DnDHI8IpsCZt3wtP9BVnZ+xs6elQ/ MSMFoa35sMbLwgFFVj2pKOyuSH3jAiXGiLCI4fwxBmtvHVrsSo+Ecn6rwAin9HzoMjBa QO+vLQTf5UdVMXqDR6q30DDFOZQ/jyd42IMG/qpfZPeN3xexiFYV7vLDSe0OIZwrHKMI vddQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=UgTbX0Z/mhTxIBQQkmgRD0OZkLsEPg4yoqKX2TeyZ5w=; b=TjGgPLtAeqrzcl6rR4STT9jUI+tYjGzf4e1q/iKw2BzmG4SGxRUA2f3hG/CeqbmGjB 1n5BeEOs5J1eYmixZsTnsIsMqorIzo0Ux2Zg8Z+LYdWewRwqgpIkr1LaVoGsjKJ2V+Gf T2/3deWdDfSyNP8aM52BFp/+asFIK2oLSGEnVU0TYsqKBGF0vptenp8tPnYnAvZph+8/ BbziX43QXK8UpK1DHpXOE7UU4csPUy/6dK5CZ3JgzqjsAc2ousB4sdFugEOvHdRjDlfE WEt+28uiIQEFFeAbnITFs2gcoGITKhfjRyGm2J7Mi5kbNhtyM3i3+y4wLARpCNG3vApn l2Jg== 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 f14si3031417ots.196.2020.03.05.01.59.58; Thu, 05 Mar 2020 02:00:11 -0800 (PST) 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 S1727185AbgCEJ7S (ORCPT + 99 others); Thu, 5 Mar 2020 04:59:18 -0500 Received: from mga06.intel.com ([134.134.136.31]:18619 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727085AbgCEJ7S (ORCPT ); Thu, 5 Mar 2020 04:59:18 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Mar 2020 01:59:17 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,517,1574150400"; d="scan'208";a="234366513" Received: from snr.bj.intel.com ([10.240.193.90]) by orsmga008.jf.intel.com with ESMTP; 05 Mar 2020 01:59:11 -0800 From: Luwei Kang To: x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: peterz@infradead.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, kan.liang@linux.intel.com, like.xu@linux.intel.com Subject: [PATCH v1 04/11] KVM: x86/pmu: Decouple event enablement from event creation Date: Fri, 6 Mar 2020 01:56:58 +0800 Message-Id: <1583431025-19802-5-git-send-email-luwei.kang@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1583431025-19802-1-git-send-email-luwei.kang@intel.com> References: <1583431025-19802-1-git-send-email-luwei.kang@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kan Liang KVM needs to specially configure the event before enabling the event, e.g. set event to assign a dedicated counter and handle auto-reload flags. Set disabled = 1 when allocating the event. So perf will not enable the event by default. Then enable the event explicitly. Previously, the process is creating and enabling. Now, it's creating, KVM configure, and enabling. Signed-off-by: Kan Liang --- arch/x86/kvm/pmu.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/kvm/pmu.c b/arch/x86/kvm/pmu.c index bcc6a73..b4f9e97 100644 --- a/arch/x86/kvm/pmu.c +++ b/arch/x86/kvm/pmu.c @@ -109,6 +109,7 @@ static void pmc_reprogram_counter(struct kvm_pmc *pmc, u32 type, .exclude_user = exclude_user, .exclude_kernel = exclude_kernel, .config = config, + .disabled = 1, }; attr.sample_period = (-pmc->counter) & pmc_bitmask(pmc); @@ -136,6 +137,7 @@ static void pmc_reprogram_counter(struct kvm_pmc *pmc, u32 type, pmc->perf_event = event; pmc_to_pmu(pmc)->event_count++; + perf_event_enable(event); clear_bit(pmc->idx, pmc_to_pmu(pmc)->reprogram_pmi); } -- 1.8.3.1